如果用纯api来产生菜单?(100分)

  • 主题发起人 主题发起人 whaoye
  • 开始时间 开始时间
W

whaoye

Unregistered / Unconfirmed
GUEST, unregistred user!
不要告诉我用tmenuitems,<br>我希望是纯api,比如createmenu,appendmenu,<br>我什么我用的时候,总是只能显示在一行,也就是说比如标准的windows程序,<br>我做的菜单总是 只有 文件 编辑 工具......<br>而文件里面的保存,退出等等就做不出来,(也就是没有弹出项,只用主菜单)<br>是不是我用的api不正确|?那个appendmenuitems是干什么的?<br>并且,如果是我是配合createwindow来产生菜单,如何处理消息循环呢|<br>怎么知道各个菜单项目被click了呢?<br>这个和tmenuitem好象有区别,<br>如果是tmenuitem就很好处理了。
 
&nbsp;hSubMenu := CreatePopupMenu;<br>&nbsp; AppendMenu(hSubMenu, MF_ENABLED or MF_UNCHECKED or MF_STRING,<br>&nbsp; &nbsp; &nbsp; 2, '关闭');<br>&nbsp; hMenu := CreateMenu;<br>&nbsp; AppendMenu(hMenu, MF_ENABLED or MF_POPUP<br>&nbsp; &nbsp; &nbsp; or MF_UNCHECKED or MF_STRING, hSubMenu, '文件'); <br>&nbsp; SetMenu(Handle, hMenu); <br><br>要想知道哪个菜单项被单击,则要截获WM_SYSCOMMAND
 
用纯SDK编程就可以了,最直接的你可以看Win32ASM 中怎么产生菜单的教程.<br>参考网站:http://asm.yeah.net
 
GetSystemMenu取得菜单句柄<br>ModifyMenu修改菜单项<br>DeleteMenu删除菜单项<br>AppEndMenu添加菜单项<br>用户点击菜单项时范例捕获wm_SysCommand消息来触发自定义事件<br><br>The GetSystemMenu function allows the application to access the window menu (also known as the System menu or the Control menu) for copying and modifying. <br><br>HMENU GetSystemMenu(<br><br>&nbsp; &nbsp; HWND hWnd, // handle of window to own window menu &nbsp;<br>&nbsp; &nbsp; BOOL bRevert // reset flag<br>&nbsp; &nbsp;);<br><br>The ModifyMenu function has been superseded by the SetMenuItemInfo function. You can still use ModifyMenu, however, if you do not need any of the extended features of SetMenuItemInfo.<br><br>BOOL ModifyMenu(<br><br>&nbsp; &nbsp; HMENU hMnu, // handle of menu <br>&nbsp; &nbsp; UINT uPosition, // menu item to modify<br>&nbsp; &nbsp; UINT uFlags, // menu item flags <br>&nbsp; &nbsp; UINT uIDNewItem, // menu item identifier or handle of drop-down menu or submenu<br>&nbsp; &nbsp; LPCTSTR lpNewItem // menu item content <br>&nbsp; &nbsp;);<br><br>The DeleteMenu function deletes an item from the specified menu. If the menu item opens a menu or submenu, this function destroys the handle to the menu or submenu and frees the memory used by the menu or submenu. <br><br>BOOL DeleteMenu(<br><br>&nbsp; &nbsp; HMENU hMenu, // handle to menu<br>&nbsp; &nbsp; UINT uPosition, // menu item identifier or position<br>&nbsp; &nbsp; UINT uFlags // menu item flag<br>&nbsp; &nbsp;);<br><br>The AppendMenu function has been superseded by the InsertMenuItem function. You can still use AppendMenu, however, if you do not need any of the extended features of InsertMenuItem.<br><br>BOOL AppendMenu(<br><br>&nbsp; &nbsp; HMENU hMenu, // handle to menu to be changed<br>&nbsp; &nbsp; UINT uFlags, // menu-item flags<br>&nbsp; &nbsp; UINT uIDNewItem, // menu-item identifier or handle of drop-down menu or submenu<br>&nbsp; &nbsp; LPCTSTR lpNewItem // menu-item content<br>&nbsp; &nbsp;);<br><br><br>A window receives this message when the user chooses a command from the window menu (also known as the System menu or Control menu) or when the user chooses the Maximize button or Minimize button.<br><br>WM_SYSCOMMAND &nbsp;<br>uCmdType = wParam; &nbsp; &nbsp; &nbsp; &nbsp;// type of system command requested <br>xPos = LOWORD(lParam); &nbsp; &nbsp;// horizontal postion, in screen coordinates <br>yPos = HIWORD(lParam); &nbsp; &nbsp;// vertical postion, in screen coordinates <br>&nbsp;<br><br>Parameters<br><br>uCmdType<br><br>Specifies the type of system command requested. This can be one of these values:<br><br>Value Meaning<br>SC_CLOSE Closes the window.<br>SC_CONTEXTHELP Changes the cursor to a question mark with a pointer. If the user then clicks a control in the dialog box, the control receives a WM_HELP message.<br>SC_DEFAULT Selects the default item; the user double-clicked the window menu.<br>SC_HOTKEY Activates the window associated with the application-specified hot key. The low-order word of lParam identifies the window to activate.<br>SC_HSCROLL Scrolls horizontally.<br>SC_KEYMENU Retrieves the window menu as a result of a keystroke.<br>SC_MAXIMIZE (or SC_ZOOM) Maximizes the window.<br>SC_MINIMIZE (or SC_ICON) Minimizes the window.<br>SC_MONITORPOWER Windows 95 only: Sets the state of the display. This command supports devices that have power-saving features, such as a battery-powered personal computer.<br>SC_MOUSEMENU Retrieves the window menu as a result of a mouse click.<br>SC_MOVE Moves the window.<br>SC_NEXTWINDOW Moves to the next window.<br>SC_PREVWINDOW Moves to the previous window.<br>SC_RESTORE Restores the window to its normal position and size.<br>SC_SCREENSAVE Executes the screen saver application specified in the [boot] section of the SYSTEM.INI file.<br>SC_SIZE Sizes the window.<br>SC_TASKLIST Executes or activates Windows Task Manager.<br>SC_VSCROLL Scrolls vertically.<br>&nbsp;<br>xPos<br>Specifies the horizontal position of the cursor, in screen coordinates, if a window menu command is chosen with the mouse. Otherwise, the xPos parameter is not used.<br><br>yPos<br>Specifies the vertical position of the cursor, in screen coordinates, if a window menu command is chosen with the mouse. This parameter is -1 if the command is chosen using a system accelerator, or zero if using a mnenomic.<br><br>Return Values<br>An application should return zero if it processes this message.<br><br>
 
不是我想要的,可能我的意思没有说清楚。<br>算了,也拖了这么长的时间,<br>结束话题。<br>感谢你们的回答,尤其是房客。
 
后退
顶部