-
Menu 's??????
Hello I've just been messing around (and I'm also new to windows) but can I plz get some help onhow to make them Menu 's at the top of the window like "File" or "Edit" or whatever plz dont tell me to go to the faq or point me to some useless site can somebody plz explain how this is done
cheers
stealth
-
Well, first..
You have to add controls AFTER you create a menu. To create a File -> Exit menu, the right above case WM_DESTROY:
type:
HMENU hMenu, hSubMenu
above switch(message)
case WM_CREATE: //Place above case WM_DESTROY:
#define CM_FILE_EXIT 10
hMenu = CreateMenu();
hSubMenu = CreatePopupMenu();
AppendMenu(hSubMenu, MF_STRING, CM_FILE_EXIT, "&Exit");
AppendMenu(hSubMenu, MF_STRING + MF_POPUP, (UINT)hSubMenu, "&File");
SetMenu(hwnd, hMenu);
break;
-
ok thanks for the help man I'll try that out
cheers
stealth
-
damn I thought that I would just copy and paste in then I would look at it and see what it does but I cant figure it out so if it's ok mate and if it's not too much trouble do u think u could let me know what the most of it does
cheers
stealth
-
Stealth was IDE are you using, cause if your using Visual C++ then just add a resource script, and use their resource dev tool to make a menu. If your using Bloodshed then make a resource script and add this code
IDC_DCX MENU DISCARDABLE
BEGIN
POPUP "&File"
BEGIN
MENUITEM "E&xit", IDM_EXIT
END
END
then add wcex.lpszMenuName = (LPCSTR)IDC_DCX; where you register your class name.
thats the easy way
-
wow man that looks pretty easy and is kinda easier to understand hmm at last I'm gettin gsoewhere oh well time to try it out and see what I get thanks alot mate oh yeah I'm not rich so I'm using DevC++
cheers
stealth
-
hmm mno sorry about this really but I still dont get it I think I need to start from the very begginning see Dev have their own little something that lets u make a window just by clicking some blimmin thing but I dont like that I would like to learn on my own how to do that and then add the menu ,well it seems like Dev gets me into bad habits so I think I should just set up this bordland if I can find it and use that I think that would be better
anyway if u can help out man thanks
cheers
stealth
-
Hey Stealth;
yeah sorry man i find that my ppl skills arnt very good, and i have a hard time explaining things. I forgot to tell you you will need to create a resource.h file and #define your menu items in that.
anyways i created a blank window for you with just a menu. i uploaded the .zip file to my site, go download that, it should be simple to understand, but please ask if you have trouble. its a vc++ project file so youll have to open the .cpp and .rc through your IDE. cya.
oh damm the link is, http://www.praxis1.vic.edu.au/home/dcola/teeeee.zip
i see you on the board now, so give it about 2 mins before you go there cause its still uplaoding.
-
ok thanks man ur a life saver I'll check this out cheers mate thanks alot
-
Try this theForger's Win32 API Programming Tutorial and learn how to do it from scratch!
p.s. Print it out so you can look at paper. I think that it helps.
-
-
Don't forget DrawMenuBar() after you have changed the menu or you will not see the changes.
PS I don't like SyntaxBubbles code (it may work though). He is adding items to a submenu that is yet to be added to the main one. Also AppendMenu() is old/not supported function. Use InsertMenuItem().