- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
help me, please, with this simple (for you) question: Is it possible to use menus in "A simple dialog Based application"? I can create the menu (I can see it when the application runs) and I can Load it (nonzero return value from the LoadMenu function). But I can't find out how to "link" the action (subroutine) with the menu item.
Thank you
V.Meistr
help me, please, with this simple (for you) question: Is it possible to use menus in "A simple dialog Based application"? I can create the menu (I can see it when the application runs) and I can Load it (nonzero return value from the LoadMenu function). But I can't find out how to "link" the action (subroutine) with the menu item.
Thank you
V.Meistr
Link Copied
7 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you very much for the sample, it works fine. I have another question: is it possible to check menu items with the CheckMenuItem routine?
As the first argument I sent there the result from the LoadMenu function. As the second argument the number of the item (from resource.fd) and as the third I tried "MF_CHECKED" and "IOR(MF_BYCOMMAND,MF_CHECKED)" (I got this from the Lawrence book (CVF: A Guide to Creating...)).
None worked.
As the first argument I sent there the result from the LoadMenu function. As the second argument the number of the item (from resource.fd) and as the third I tried "MF_CHECKED" and "IOR(MF_BYCOMMAND,MF_CHECKED)" (I got this from the Lawrence book (CVF: A Guide to Creating...)).
None worked.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yeah, but... the drop-down menus are not considered part of main menu, but they are its submenus with their own handles. Thus, you have to obtain their handles first using GetSubMenu(hParentMenu, Index) API.
Attached is my wrapper module, XFTMenu, which does this for you. The basic idea is to be used as you (wrongly) expected: have one menu & its submenus represented by a single structure, X_MENU, and operate on this structure. Sorry, no reference is written as yet (and comments are sparse as well):
Jugoslav
Attached is my wrapper module, XFTMenu, which does this for you. The basic idea is to be used as you (wrongly) expected: have one menu & its submenus represented by a single structure, X_MENU, and operate on this structure. Sorry, no reference is written as yet (and comments are sparse as well):
TYPE(X_MENU):: xMenu xMenu = XLoadMenu(IDR_MENU1) ... lret = XSetWindowMenu(Dlg%hWnd, xMenu) lret = XMenuSet(xMenu, ID_FILE_NEW, .FALSE., XMENU_ENABLE) lret = XMenuSet(xMenu, ID_FILE_NEW, .TRUE., XMENU_STATE) !Checkedetc.
Jugoslav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sorry but I still can't manage to check the menu item
Here is a part of the code:
hMenu=GetSubMenu(ghmenu,1)
iret=GetMenuItemID(hmenu,0)
IF(something) THEN
iret=CheckMenuItem(hmenu,iret,IOR(MF_BYCOMMAND,&
&MF_UNCHECKED))
ELSE
iret=CheckMenuItem(hmenu,iret,IOR(MF_BYCOMMAND,&
&MF_UNCHECKED))
ENDIF
GetSubMenu returns a number. I use it in GetMenuItemID and it returns correct value of the identifier of the menu item (the same as is in resource.fd). Return values of the CheckMenuItem functions are 0 (unchecked) and 8 (checked).
When I use this function (checkmenuitem) in an SDI Application, everything is ok, but in this dialog-based application it doesn't work.
Thank you for some help
Vit
Here is a part of the code:
hMenu=GetSubMenu(ghmenu,1)
iret=GetMenuItemID(hmenu,0)
IF(something) THEN
iret=CheckMenuItem(hmenu,iret,IOR(MF_BYCOMMAND,&
&MF_UNCHECKED))
ELSE
iret=CheckMenuItem(hmenu,iret,IOR(MF_BYCOMMAND,&
&MF_UNCHECKED))
ENDIF
GetSubMenu returns a number. I use it in GetMenuItemID and it returns correct value of the identifier of the menu item (the same as is in resource.fd). Return values of the CheckMenuItem functions are 0 (unchecked) and 8 (checked).
When I use this function (checkmenuitem) in an SDI Application, everything is ok, but in this dialog-based application it doesn't work.
Thank you for some help
Vit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hmmm, the code looks OK to me (except that you have MF_UNCHECKED in both IF branches, but I assume it's just a copypasto). Return values look sensible as well (i.e. as if it works)...
Sorry for a stupid question, but are you aware that menu indices are zero-based -- the code you posted checks the first item (0) of the second (1) submenu? Other than that, I'm running out of suggestions (a cause may be a previous bad call to SetMenuItemBitmaps, but that's a wild shot).
Jugoslav
Sorry for a stupid question, but are you aware that menu indices are zero-based -- the code you posted checks the first item (0) of the second (1) submenu? Other than that, I'm running out of suggestions (a cause may be a previous bad call to SetMenuItemBitmaps, but that's a wild shot).
Jugoslav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, MF_UNCHECKED is from copy-paste, it is OK in the program. The second thing is OK too, I realy want to check first item in second submenu (actually the return value from the GetMenuItemID function is exactly the one I want to check).
I put there a static box where the user is told whether it's checked or not. It's really not nice, but it works. ;-)
Thank you for your help Jugoslav.
Vit
I put there a static box where the user is told whether it's checked or not. It's really not nice, but it works. ;-)
Thank you for your help Jugoslav.
Vit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Just added CheckMenuItem it to MenuDialog sample (attached) and it appears to work fine... don't know what went wrong in your app.
Jugoslav
Jugoslav

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page