1. getId() does not return ids of popup menu entries
- Posted by CChris <christian.cuvier at agriculture.gouv.fr> Oct 23, 2004
- 695 views
I have a menu that has one embedded menu in it. It dislays normally. I need to interface wih the API so that I have to deal with real hwnds. Then:
integer a a=getNameId("popupname") --a small integer a=getHWND(a) --a bigger integer a=getId(a) --a is 0 !!!
I'd expect a to have the same value than on the first assignment. I'm trapping the WM_MENUSELECT message so as to prepare some dynamic submenus when "popupname" is selected. Is there any simpler way? How do I retrieve the id of that selected element, whose handle I get from GetSubMenu()? win98, win32lib 0.60.6 CChris
2. Re: getId() does not return ids of popup menu entries
- Posted by CChris <christian.cuvier at agriculture.gouv.fr> Oct 25, 2004
- 640 views
Well, I foraged through win32lib.ew and found the comment at line 12574 saying that ? about setting an id for such handles. I'd have wasted less time had the caveat been in the docs. Anyway... I worked around the problem by creating a list of the menus I was interested in, and a list of their hwnd once created. Doing the lookup myself solved the problem, so that I can invokeHandler the parent menu with a w32HChange event (params={item id, flags as per the WM_MENUSELECT message). Wouldn't that both: - solve the inconsistency about getId(), and - add the ability to track the menu item the mouse is over, prior to or without it being selected? There may have to be a new w32HMenuSel event sent to a menu item being (de)selected. w32HChange for a menu is ok, except when this is a non-win32lib menu that got items appended to it. Subclassing that menu may be simpler, don't know. Just a thought, I can post some proof of concept code if needed. CChris
3. Re: getId() does not return ids of popup menu entries
- Posted by Derek Parnell <ddparnell at bigpond.com> Oct 25, 2004
- 613 views
CChris wrote: > > Well, I foraged through win32lib.ew and found the comment at line 12574 > saying that ? about setting an id for such handles. I'd have wasted less time > had the caveat been in the docs. News flash::: The docs aren't perfect! I'm sorry you wasted so much of your time. I take full responsibility. >Anyway... I don't work on win32lib full time. I took most of the weekend off - did some gardening and spent time with the family. Sorry for the delayed response to your issue. > I worked around the problem by creating a list of the menus I was interested > in, and a list of their hwnd once created. Doing the lookup myself solved the > problem, so that I can invokeHandler the parent menu with a w32HChange event > (params={item id, flags as per the WM_MENUSELECT message). This is part of the problem. Menu Item's don't have their own hWnd as they use the parent menu's hWnd. It looks like this issue was put on delay until it needed to be resolved. > Wouldn't that both: > - solve the inconsistency about getId(), and Not quite. A hWnd can only get the parent menu id and never the menuitem's id. I will come up with something though. > - add the ability to track the menu item the mouse is over, prior to > or without it being selected? No one has ever asked for this before. I don't want to put every possible bit of functionality into Win32lib just in case somebody might want it. I am open to suggestions and ideas for improvements. I nearly always come up with something to met the requester's needs. > There may have to be a new w32HMenuSel event sent to a menu item being > (de)selected. > w32HChange for a menu is ok, except when this is a non-win32lib menu that got > items > appended to it. Subclassing that menu may be simpler, don't know. A new event type maybe a good idea. I'll think about it tonight and come up with something in the next day or two. > Just a thought, I can post some proof of concept code if needed. Not required yet, but you can always email me your ideas. I can't mind read just yet. -- Derek Parnell Melbourne, Australia
4. Re: getId() does not return ids of popup menu entries
- Posted by ChrisBurch2 <crylex at freeuk.co.uk> Oct 25, 2004
- 642 views
Hi <snipped> > > Not required yet, but you can always email me your ideas. I can't mind > read just yet. > > -- > Derek Parnell > Melbourne, Australia > All my preconceived world foundations have just been shattered. Chris
5. Re: getId() does not return ids of popup menu entries
- Posted by Derek Parnell <ddparnell at bigpond.com> Oct 26, 2004
- 626 views
I'm thinking of implementing a w32HMenuSelect event in the next version. It goes something like this ... -------w32HMenuSelect ------------------------ The event handler parameters are {ItemId, ParentID, Flags, wParam, lParam} This event is triggered when the application receives a WM_MENUSELECT message from Windows. These are received when the user selects a menu or menuitem before clicking it. ** ItemId, if greater than zero, is the Win32lib ID of the menu or menuitem selected. A value of 0 means that the menu has been closed. Values less than zero are the negative value of the Windows predefined menu item ids of the System Menu items, except that -1 is used for the System Menu itself. ** ParentId. If 'ItemId' is a win32lib id, this is the win32lib id of its parent control. If 'ItemId' is zero, this is the item id of the last one we received a message for, which is -1 if it was the system menu that closed. If 'ItemId' is a System Menu item, this is the menu text for that item. ** Flags. Can be a combination of ... - MF_BITMAP Item displays a bitmap. - MF_CHECKED Item is checked. - MF_DISABLED Item is disabled. - MF_GRAYED Item is grayed. - MF_HILITE Item is highlighted. - MF_MOUSESELECT Item is selected with the mouse. - MF_OWNERDRAW Item is an owner-drawn item. - MF_POPUP Item opens a drop-down menu or submenu. - MF_SYSMENU Item is contained in the window menu. The lParam parameter contains a handle to the menu associated with the message. ** wParam and lParam are the raw data items passed by the Windows WM_MENUSELECT message. This event is only triggered for a Window that has a menu attached. ------------------------------------------------- All comments and suggestions welcome. -- Derek Parnell Melbourne, Australia