这就是InsertMenuItem()文档中所说的:
uItem [in]
Type: UINT
The identifier or position of the menu item before which to insert the new item. The meaning of this parameter depends on the value of fByPosition.但是,MENUITEMINFO.wID的目的是什么呢?
wID
Type: UINT
An application-defined value that identifies the menu item. Set fMask to MIIM_ID to use wID.请注意,我测试了这两个参数,而且只有wID工作!
发布于 2014-11-07 06:27:36
但是,MENUITEMINFO.wID的目的是什么呢?
uItem控制插入新菜单项的位置。wID控制新菜单项的ID。
假设您有一个带有标识符IDM_FOO、IDM_BAR和IDM_BAZ的菜单,其中包含3个项。现在,假设您希望在IDM_FOO和IDM_BAR项之间的菜单中插入第四个带有标识符IDM_BAR的项。您可以使用InsertMenuItem()在IDM_BAR (使用fByPosition == FALSE)或索引1(使用fByPosition == TRUE)之前插入它。例如:
MENUITEMINFO mii;
ZeroMemory(&mii, sizeof(mii));
mii.cbSize = sizeof(mii);
mii.fMask = MIIM_ID | /* Other flags */;
mii.wID = IDM_QUUX; // ID of new menu item to be inserted
// Fill out other fields
...
// Insert new menu item before the IDM_BAR item
InsertMenuItem(hMenuParent, IDM_BAR, FALSE, &mii);
...
// OR, insert new menu item before position 1
InsertMenuItem(hMenuParent, 1, TRUE, &mii);关于这一评论:
请注意,我测试了这两个参数,而且只有wID工作!
您必须澄清“只有wID才能工作”的含义。怎么起作用的?你到底做了什么,发生了什么,你预期会发生什么?确保您仔细阅读了这些文档,以了解这些功能和结构是如何工作的。
https://stackoverflow.com/questions/26795211
复制相似问题