Window messages

Menu related
A lot of this information was posted by Martin Lafaix (http://lafaix.online.fr) in OS/2-NGs, so credits probably belong to him :-). He wrote: "Those interested in menu stuff can read the relevant code parts in xwp."

All pointers used by BYPOS messages are *not* thunked by PM when the messages are sent, so you *must* do the conversion yourself, using something like :

(HIUSHORT(p) << 3) | 7))
 * 1) define MAKE_16BIT_POINTER(p) ((PVOID)MAKEULONG(LOUSHORT(p), \

There are also some undocumented menu window styles:

MS_ROOT (0x00000008L) menu is the root of the menu hierarchy MS_POPUP (0x00000010L) menu is a popup-menu


 * 1) define MM_MENUCHAR 0x003f

Non-mnemonic menu char pressed.
 * mp1 : window handle of menu currently displayed
 * mp2 :
 * SHORT1FROMMP(mp2) : character
 * SHORT2FROMMP(mp2) : unused

Returns how PM should deal with this invalid character:


 * MRFROM2SHORT(0, 0)       :  character is invalid (beep)
 * MRFROM2SHORT(0, 1)       : cancel the menu
 * MRFROM2SHORT(position, 2) : select the menu item specified by

position

Any other return code means to ignore the character and do nothing. Normally, this message is passed to WinDefWindowProc, which returns 0L.

This message is sent from the menu code to its owner when the WM_CHAR message is being processed, and the alphanumeric key pressed does not match any of the mnemonics in the displayed menu. It allows the application to specify which menu item should be selected in this case.

(Source: newsgroup)


 * 1) define MM_DISMISSMENU                 0x0187


 * 1) define WM_0196   0x0196

MM_SUMMON (cause menu to be displayed)


 * 1) define MM_DISMISS 0x0197

Cause menu to be hidden


 * 1) define MM_STARTTRACKING 0x0198

Capture mouse and begin tracking


 * 1) define MM_SUMMONCHAIN 0x0199

Display menu and all owner menus


 * 1) define WM_019a  0x019a

MM_DISMISSCHAIN (hide menu and all owners menus)


 * 1) define WM_019b  0x019b

MM_ISCHAINENABLED (are menu and all all owners enabled ?)


 * 1) define WM_019c   0x019c

MM_QUERYMENUSAVEDFOCUS (query window to receive focus at end)


 * 1) define WM_019d   0x019d

MM_SETMENUSAVEDFOCUS (set window to receive focus at end)


 * 1) define WM_019e   0x019e

MM_SELECTITEMBYPOS (set selection state by its position)


 * mp1 :
 * MIT_FIRST : first item in the menu
 * MIT_LAST : last item in the menu
 * MIT_NONE : deselect all items in the menu
 * other : position of item in the menu.

TRUE = dismiss the menu and post WM_COMMAND, WM_SYSCOMMAND or WM_HELP message FALSE = do not dismiss the menu
 * mp2 :
 * SHORT1FROMMP : reserved and set to zero
 * SHORT2FROMMP :

Returns TRUE if the selection was made, or MIT_NONE was specified. Returns FALSE if the item is not selectable, the item was deselected, or MIT_NONE was not specified.

This message will set the selection state in the specified menu. If the item being selected is in a submenu that is in a submenu that is not currently displayed, then the menu is summoned and displayed. If the item selected is in a submenu, the item is selected and the selection state of the menu owning the submenu is also set. This process continues up the menu hierarchy until the top-level menu is reached.

(Source: newsgroup)


 * 1) define WM_019f    0x019f

???


 * 1) define MM_MATCHMNEMONIC 0x01f0

Find match of mnemonic char in menu

number of submenu levels to search 0 = none 1 = top-level (this menu) 2 = top+first submenu 3 = top+first 2 submenus (etc.) -1 = all
 * mp1 :
 * SHORT1FROMMP(mp1) : character to match
 * SHORT2FROMMP(mp1) :
 * mp2 : pointer to HWND of menu where match found

Returns both the index of the item in the menu that matched and the level of the match : MRFROM2SHORT (hwndmenu, index). In addition, contained the mnemonic.
 * mp2 is updated to contain the window handle of the menu that

This message is sent withing the menu code when the WM_CHAR is being processes and the menu code is trying to find a mnemonic match for the character pressed. This message is not sent to the owner window, so you must subclass the menu window in order to receive this message.

(Source: newsgroup)


 * 1) define MM_DELETEITEMBYPOS 0x01f1

Delete a menu item by its position


 * mp1 : position of item to delete
 * mp2 : unused

Returns the number of items remaining in the menu.

This message will only delete an item in the menu specified. It also destroys any submenu windows and deletes the bitmap associated with the menu item if the bitmap was not created by the application.

(Source: newsgroup)


 * 1) define MM_REMOVEITEMBYPOS 0x01f2

Remove a menu item by its position


 * mp1 : position of item to remove
 * mp2 : unused

Returns the number of items remaining in the menu

This message will only remove an item in the menu specified. This message does not destroy any submenus or delete any bitmaps associated with the menu item.

(Source: newsgroup)


 * 1) define WM_01f3   0x01f3

MM_QUERYITEMBYPOS: Query MENUITEM by its position


 * mp1 : menuitem index
 * mp2 : PMENUITEM (16-bit pointer)

Returns TRUE if the request is successful

This message will only query an item in the specified menu. This message will not retrieve the text for MIS_TEXT items; use the WM_QUERIITEMTEXTBYPOS message to retrieve the text.

Sent to menu after WM_01f5 has identified menuitem to hilite. Seen when XWP's 'Sliding menu selection' is enabled.

(Source: newsgroup)


 * 1) define MM_SETITEMBYPOS 0x01f4

Set MENUITEM by its position.


 * mp1 : Position of item in menu
 * mp2 : PMENUITEM (16-bit pointer)

Returns TRUE if the request is successful

This message will only set an item in the specified menu. The iPosition field on the MENUITEM structure is ifnored because you cannot change the position of a menu item. If the submenu or bitmap handle is changing, the previous sumbenu window handle or bitmap handle is not deleted during the handling of this message.

(Source: newsgroup)

Query the attribute by its position
 * 1) define MM_QUERYITEMATTRBYPOS    0x01f5


 * mp1 : 0 to number of items in menu. Position of the item to query.
 * mp2 : Requested attributes mask.

Returns the current state of the attributes requested.

The attributes returned are the current state values of the menu item ANDed with the attribute mask specified in mp2. It does not change any of the attributes of the menu item.

1 or more msgs sent to menu under pointer for each mouse move. Apparently used to identify which menuitem to hilite. Seen when XWP's 'Sliding menu selection' is enabled.

(Source: newsgroup)


 * 1) define MM_SETITEMATTRBYPOS 0x01f6

Set the attribute by its position


 * mp1 : position of the item to set
 * mp2 :
 * SHORT1FROMMP(mp2) : attributes mask
 * SHORT2FROMMP(mp2) : attribute flags

Teturns TRUE if the attributes were successfully modified.

Only those attributes specified by the attributes mask are modified by this message

(Source: newsgroup)


 * 1) define MM_QUERYITEMTEXTBYPOS 0x01f7

Query text of item by its position.

null termination character).
 * mp1 :
 * SHORT1FROMMP(mp1) : Position of the item to query the text.
 * SHORT2FROMMP(mp2) : Maximum nomber of bytes to copy (includes the
 * mp2 : PSTRL (16-bit pointer)

Returns the length of the string copied to PSTRL.

(Source: newsgroup)


 * 1) define MM_QUERYITEMTEXTLENGTHBYPOS 0x01f8

Query text length by its position.


 * mp1 : position of the item to query
 * mp2 : unused

Returns the length of the string.

(Source: newsgroup)


 * 1) define MM_SETITEMTEXTBYPOS 0x01f9

Set text of item by its position.


 * mp1 : position of item to query
 * mp2 : PSTRL (16-bit pointer)

Returns TRUE if the request is successful.

(Source: newsgroup)


 * 1) define MM_SETITEMHANDLEBYPOS 0x01fa

Set bitmap or ownerdraw handle by its position.


 * mp1 : position of the item to query
 * mp2 : item handle

Returns TRUE if the request is successful.

This message only applies to menu items with the MIS_BITMAP or MIS_OWNERDRAW style.

(Source: newsgroup)


 * 1) define MM_PORTHOLEINIT 0x01fb

Submenu about to be displayed

Return code ignored for this message.
 * mp1 :
 * SHORT1FROMMP(mp1) : position of submenu in the menu
 * SHORT2FROMMP(mp1) : attribute of the menu item
 * mp2 : menu handle containing the item

This message is sent from the menu code to its owner just prior to summoning a pop-up menu. Upon return from the processing of this message, PM will again retrieve the submenu handle for the selected item. This allows an application to replace the submenu just prior to the submenu being displayed.

(Source: newsgroup)


 * 1) define MM_SETITEMCHECKMARKBYPOS 0x01fc

Set checkmark bitmap by its position

FALSE bitmap is for the unchecked state
 * mp1 :
 * SHORT1FROMMP(mp1) : Position of menu item to set
 * SHORT2FROMMP(mp1) : TRUE bitmap is for the checked state
 * mp2 : Bitmap handle

Returns TRUE if the request is successful.

The checkmark can be set for both the checked or unchecked state. If a bitmap is not specified for one of the states, the system default bitmap is used.

(Source: newsgroup)


 * 1) define MM_SETITEMCHECKMARK 0x0210

Set checkmark to display for item

FALSE bitmap is for the unchecked state.
 * mp1 :
 * SHORT1FROMMP(mp1) : ID of the menu item to set
 * SHORT2FROMMP(mp1) : TRUE bitmap is for checked state
 * mp2 : bitmap handle

Returns TRUE if the request is successful.

If a bitmap is not specified for one of the states, the system default bitmap is used.


 * 1) define WM_0693     0x0693
 * mp1 : ctl id
 * mp2 : hwnd

Sent by MS_ACTIONBAR menus to owner on MBx-down.

(Source: newsgroup)

There seems to be no equivalent to MM_QUERYSELITEMID (i.e., querying the currently selected item by position). That's why, in xwp, the autohiliting behaves strangely in some netscape 4.x menus, where most items have the same ID.

(Source: newsgroup)

Misc messages

 * 1) define WM_0444    0x0444


 * mp1 : 0
 * mp2 : 0

Sent to titlebar by frame when activation state changes.


 * 1) define WM_0453     0x0453

???


 * 1) define WM_0692     0x0692


 * mp1 : 1
 * mp2 : hwnd

Periodically sent by a modal dialog to itself.