Windows programming

Moderators: None (Apply to moderate this forum)
Number of threads: 3670
Number of posts: 9122

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
CMenu/menus, a tough question for smarties Posted by dalaptop on 8 Apr 2001 at 5:56 PM
I'm trying to make an owner-draw menu in C++ and I'm having a lot of trouble. I'm using MFC's CMenu class and I'm trying InsertMenu();

mymenu->InsertMenu(0, MF_BYPOSITION|MF_OWNERDRAW, ID_RED, "Red");

After doing this, my OnDrawItem function retrieves a DRAWITEMSTRUCT as one of it's argumens and the structure contains a variable called itemData, which is a unsigned integer that contains the fourth parameter of InsertMenu. In my OnDrawItem, I do:

CString data = (LPCTSTR) lpdis->itemData; (lpdis is the DRAWITEMSTRUCT structure).

this works fine if I implement InsertMenu() like above, but when I fill InsertMenu with the fourth parameter being a variable that contains the string I want it to be, it doesn't work. Basically, I need figuring out why this works:

mymenu->InsertMenu(0, MF_BYPOSITION|MF_OWNERDRAW, ID_RED, "Red");

and not this:

CString red = "red";
mymenu->InsertMenu(0, MF_BYPOSITION|MF_OWNERDRAW, ID_RED, red);

If you have any hints or suggestions, please help me.

Report
Re: CMenu/menus, a tough question for smarties Posted by ColdShine on 12 Apr 2001 at 4:00 AM
I don't program in MFC, but I know a little of. Try this:
CString red = "red";
mymenu->InsertMenu(0, MF_BYPOSITION | MF_OWNERDRAW, ID_RED, (LPCTSTR)red);
Or this:
CString red = "red";
mymenu->InsertMenu(0, MF_BYPOSITION | MF_OWNERDRAW, ID_RED, (LPTSTR)red);
There's only a capital C of difference, but may help...
________
ColdShine





 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.