Re: MAKEINTRESOURCE revisited
- Posted by Euman <euman at bellsouth.net> Apr 28, 2001
- 390 views
> Euman wrote: > > I'll try this but, Im not sure this is what we should be doing. > > Im still not sure what it is you are trying to do. > > Are you: > > 1. Trying to create a menu in your program and then display it > and process commands? NO, the menu exist already e.g: -- time submenu IDM_TIME = c_func(CreateMenu, {}) junk = c_func(AppendMenu, {IDM_TIME, MF_BYPOSITION + MF_STRING + MF_ENABLED, IDM_MILTIME, alloc_string("&Military Time\tF5")}) junk = c_func(AppendMenu, {IDM_TIME, MF_BYPOSITION + MF_STRING + MF_ENABLED, IDM_STDTIME, alloc_string("&Standard Time\tF6")}) -- options menu IDM_OPTIONS = c_func(CreateMenu, {}) junk = c_func(AppendMenu, {IDM_OPTIONS, MF_BYPOSITION + MF_STRING + MF_ENABLED + MF_POPUP, IDM_TIME, alloc_string("&Time")}) IDM_OPTION (a POPUP) is the main window menu, IDM_TIME is also POPUP spun off of IDM_OPTION if IDM_TIME is moused then IDM_MILTIME and IDM_STDTIME are dropdown menuitems. OK now that I have the menu setup and a valid menu[id] Windows has a function to LOAD a menu which in this case, I want to load IDM_TIME (because it is a created menu.) the function > LoadMenu = link_c_func(user32, "LoadMenuA", {C_POINTER, C_POINTER},C_LONG) or, in C HMENU LoadMenu( HINSTANCE hInstance, // handle to module LPCTSTR lpMenuName // menu name or resource identifier ); The definition given by Microsoft in the Platform SDK states: > lpMenuName [in] Pointer to a null-terminated string that contains the name of the menu resource. Alternatively, this parameter can consist of the resource identifier in the low-order word and zero in the high-order word. To create this value, use the MAKEINTRESOURCE macro. Heres the infamous MAKEINTRESOURCE again. this macro is used to loadAccelerators, bitmaps, icons, menu and just about any resource that could be available to your program. I know that it would be nice to have a resource compiler at this point and since we dont we have one we have to work around this (refer back to how i created the menu) After I went to MSDN and searched throught their documents related to the subject, I came across SetProp BOOL SetProp( HWND hWnd, // handle to window LPCTSTR lpString, // atom or string HANDLE hData // handle to data ); SetProp(hwnd, "TIME_MENU", IDM_TIME); My understanding (correct me if Im wrong) is that SetProp is essentially a pointer system give SetProp a string identifyer and the address to the data and your set. Now I assumed that we can SetProp I could use xLoadMenu (below) like this: Mnu = c_func(xLoadMenu, {hThisInst, "TIME_MENU"}) "TIME_MENU" would now point to IDM_TIME I hope you understand now what it is Im trying to do because I dont think I know a better way to explain it. Thanks for your Help! Euman euman at bellsouth.net \ > --Al