求助于API高手!(100分)

  • 主题发起人 主题发起人 icefireren
  • 开始时间 开始时间
I

icefireren

Unregistered / Unconfirmed
GUEST, unregistred user!
&nbsp; 能不能告诉小弟关于更改当前窗体中菜单颜色的API函数?其效果与使用WINDOWS的更改菜单功能效果相同!急啊!<br>&nbsp; 先谢谢了! <br>
 
直接的函数可能是没有的,你可参考以下的几个win32api,截获 WM_DRAWITEM 消息试试看<br><br>函数功能:该函数改动一个菜单项的信息。<br><br>&nbsp; &nbsp; 函数原型:BOOL SetMenultemlnfo(HMENU hMenu,UINT uitem,BOOL fByPosition,LPMENUITEMINFO lpmii);<br><br>&nbsp; &nbsp; 参数:<br><br>&nbsp; &nbsp; hMenu:包含菜单项的菜单的句柄。<br><br>&nbsp; &nbsp; ultem:将被修改的菜单项的标识符或位置。此参数的含义由参数fByPosition确定。<br><br>&nbsp; &nbsp; FByPosition:用于指定参数ultem的含义的值。如果此参数值为FALSE,则参数ultem<br>是菜单项的标识符,否则,表示菜单项的位置。<br><br>&nbsp; &nbsp; lpmii:指向结构MENUITEMINFO的指针。该结构含有菜单项的信息,并且.指定将被修<br>改的菜单项的属性。<br><br>&nbsp; &nbsp; 返回值:如果函数调用成功,返回非零值:如果函数调用失败,返回值是零。若想获得<br>更多的错误信息,请调用GetLastError函数。<br><br>&nbsp; &nbsp; 备注:为了使键盘加速键能控制位图或自己绘制的菜单项,菜单的拥有者必须处理<br>WM_MENUCHAR消息。参见自绘制菜单和WM_MENUCHAR消息。Windows CE环境下,只有下列值<br>对参数lpmii指向的MENUITEMINFO结构中的fMask成员有效:MIIM_DATA;MIIM_;MIIM_TYPE;<br>如果MIIM-TYPE被指定,结构MENUITEMINFO的fType成员必须为菜单项的当前类型,也就<br>是说,该类型不能被改变。<br><br>he MENUITEMINFO structure contains information about a menu item. <br><br>typedef struct tagMENUITEMINFO {<br>&nbsp; &nbsp; UINT &nbsp; &nbsp;cbSize; &nbsp;<br>&nbsp; &nbsp; UINT &nbsp; &nbsp;fMask; <br>&nbsp; &nbsp; UINT &nbsp; &nbsp;fType; <br>&nbsp; &nbsp; UINT &nbsp; &nbsp;fState; <br>&nbsp; &nbsp; UINT &nbsp; &nbsp;wID; <br>&nbsp; &nbsp; HMENU &nbsp; hSubMenu; <br>&nbsp; &nbsp; HBITMAP hbmpChecked; <br>&nbsp; &nbsp; HBITMAP hbmpUnchecked; <br>&nbsp; &nbsp; DWORD &nbsp; dwItemData; <br>&nbsp; &nbsp; LPTSTR &nbsp;dwTypeData; <br>&nbsp; &nbsp; UINT &nbsp; &nbsp;cch; <br>} MENUITEMINFO, FAR *LPMENUITEMINFO; <br>&nbsp;<br><br>Members<br><br>cbsize<br><br>Size of structure, in bytes.<br><br>fMask<br><br>Members to retrieve or set. This member can be one or more of these values:<br><br>Value Meaning<br>MIIM_CHECKMARKS Retrieves or sets the hbmpChecked and hbmpUnchecked members.<br>MIIM_DATA Retrieves or sets the dwItemData member.<br>MIIM_ID Retrieves or sets the wID member.<br>MIIM_STATE Retrieves or sets the fState member.<br>MIIM_SUBMENU Retrieves or sets the hSubMenu member.<br>MIIM_TYPE Retrieves or sets the fType and dwTypeData members.<br>&nbsp;<br><br>fType<br><br>Menu item type. This member can be one or more of these values:<br><br>Value Meaning<br>MFT_BITMAP Displays the menu item using a bitmap. The low-order word of the dwTypeData member is the bitmap handle, and the cch member is ignored.<br>MFT_MENUBARBREAK Places the menu item on a new line (for a menu bar) or in a new column (for a drop-down menu, submenu, or shortcut menu). For a drop-down menu, submenu, or shortcut menu, a vertical line separates the new column from the old.<br>MFT_MENUBREAK Places the menu item on a new line (for a menu bar) or in a new column (for a drop-down menu, submenu, or shortcut menu). For a drop-down menu, submenu, or shortcut menu, the columns are not separated by a vertical line.<br>MFT_OWNERDRAW Assigns responsibility for drawing the menu item to the window that owns the menu. The window receives a WM_MEASUREITEM message before the menu is displayed for the first time, and a WM_DRAWITEM message whenever the appearance of the menu item must be updated. If this value is specified, the dwTypeData member contains an application-defined 32-bit value.<br>MFT_RADIOCHECK Displays checked menu items using a radio-button mark instead of a check mark if the hbmpChecked member is NULL.<br>MFT_RIGHTJUSTIFY Right-justifies the menu item and any subsequent items. This value is valid only if the menu item is in a menu bar.<br>MFT_SEPARATOR Specifies that the menu item is a separator. A menu item separator appears as a horizontal dividing line. The dwTypeData and cch members are ignored. This value is valid only in a drop-down menu, submenu, or shortcut menu.<br>MFT_STRING Displays the menu item using a text string. The dwTypeData member is the pointer to a null-terminated string, and the cch member is the length of the string.<br>&nbsp;<br><br>The MFT_BITMAP, MFT_SEPARATOR, and MFT_STRING values cannot be combined with one another.<br><br>fState<br><br>Menu item state. This member can be one or more of these values:<br><br>Value Meaning<br>MFS_CHECKED Checks the menu item. For more information about checked menu items, see the hbmpChecked member.<br>MFS_DEFAULT Specifies that the menu item is the default. A menu can contain only one default menu item, which is displayed in bold.<br>MFS_DISABLED Disables the menu item so that it cannot be selected, but does not gray it.<br>MFS_ENABLED Enables the menu item so that it can be selected. This is the default state.<br>MFS_GRAYED Disables the menu item and grays it so that it cannot be selected.<br>MFS_HILITE Highlights the menu item.<br>MFS_UNCHECKED Unchecks the menu item. For more information about unchecked menu items, see the hbmpUnchecked member.<br>MFS_UNHILITE Removes the highlight from the menu item. This is the default state.<br>&nbsp;<br><br>wID<br><br>Application-defined 16-bit value that identifies the menu item.<br><br>hSubMenu<br><br>Handle to the drop-down menu or submenu associated with the menu item. If the menu item is not an item that opens a drop-down menu or submenu, this member is NULL.<br><br>hbmpChecked<br><br>Handle to the bitmap to display next to the item if it is checked. If this member is NULL, a default bitmap is used. If the MFT_RADIOCHECK type value is specified, the default bitmap is a bullet. Otherwise, it is a check mark.<br><br>hbmpUnchecked<br><br>Handle to the bitmap to display next to the item if it is not checked. If this member is NULL, no bitmap is used.<br><br>dwItemData<br><br>Application-defined value associated with the menu item.<br><br>dwTypeData<br><br>Content of the menu item. The meaning of this member depends on the menu item type: the MFT_BITMAP, MFT_SEPARATOR, or MFT_STRING values.<br><br>cch<br><br>Length of the menu item text, when information is received about a menu item of the MFT_STRING type. This value is zero for other menu item types. This member is ignored when the content of a menu item is set.<br><br>&nbsp;<br><br>Remarks<br><br>The MENUITEMINFO structure is used with the GetMenuItemInfo, InsertMenuItem, and SetMenuItemInfo functions.
 
看不太懂:)
 
API好象没戏只能自画.
 
直接的函数没有!只有在TmenuItem控件的OnDrawItem事件中自己画!
 
我这有分API大全,或许能帮上你!!<br>如有兴趣给我发个QQ<br>7345321
 

Similar threads

S
回复
0
查看
835
SUNSTONE的Delphi笔记
S
S
回复
0
查看
797
SUNSTONE的Delphi笔记
S
D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
1K
DelphiTeacher的专栏
D
后退
顶部