-
OD Menus
If I cannot set an ID for a top menu, how am I supposed to be able to manipulate the way it is created just like the other sub-menus?
Let's say in this code
Code:
switch(di->itemID)
{
case ID_COLOR1:
SetTextColor(di->hDC,color);
break;
case ID_COLOR2:
SetTextColor(di->hDC,color);
break;
case ID_COLOR3:
SetTextColor(di->hDC,color);
break;
case hMenu:
color = RGB(00,00,255);
SetTextColor(di->hDC,color);
break;
}
How would I be able to add a case hMenu, without getting an error? I even saw VB programs change the text xcolor of their top-menus. What should I do. I tried a whole bunch of stuff(such as typecasting), but with no result :( Thanks for helping
Amon Ra
-
Try using the ID of the menu itself (defined when you made the resource file).
-
Well...
I prefered to use the API to create my menus. here is the code
Code:
hMenu = CreateMenu();
hPopupMenu1 = CreatePopupMenu();
AppendMenu(hPopupMenu1, MF_STRING | MF_OWNERDRAW ,ID_FIRST, "");
AppendMenu(hPopupMenu1, MF_STRING | MF_OWNERDRAW,ID_SECOND, "");
AppendMenu(hPopupMenu1, MF_STRING | MF_OWNERDRAW,ID_COLOR1, "");
AppendMenu(hPopupMenu1, MF_STRING | MF_OWNERDRAW,ID_COLOR2, "");
AppendMenu(hPopupMenu1, MF_STRING | MF_OWNERDRAW,ID_COLOR3, "");
AppendMenu(hMenu,MF_POPUP ,(unsigned int)hPopupMenu1,"Voila");
SetMenu(hwnd, hMenu);
DrawMenuBar(hwnd);
UpdateWindow(hwnd);
You see for the last one, there is no ID_****. I tried to change the last line like this:
Code:
AppendMenu(hMenu,MF_POPUP | MF_OWNERDRAW ,(unsigned int)hPopupMenu1,"Voila");
Now, I could actually control the top level menu just like the other ones by putting an if() in my message handling. The problem is that now, the change applied to all the sub-menus as well.
Amon Ra