您的位置:程序门 -> vc/mfc -> 界面



问一个菜单的问题,如何得到菜单的hmenu句柄,谢谢


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


问一个菜单的问题,如何得到菜单的hmenu句柄,谢谢[已结贴,结贴人:hellopower]
发表于:2007-07-23 13:33:05 楼主
菜单是我创建的,我知道这个菜单的hwnd和它所属窗口的hwnd,但是如何得到菜单的hmenu句柄,因为我要enable某些菜单项,我是用win32写的,谢谢
发表于:2007-07-23 14:05:441楼 得分:10
getmenu   function

--------------------------------------------------------------------------------

the   getmenu   function   retrieves   a   handle   to   the   menu   assigned   to   the   specified   window.  

syntax

hmenu   getmenu(                     hwnd   hwnd
);
parameters

hwnd
[in]   handle   to   the   window   whose   menu   handle   is   to   be   retrieved.  
发表于:2007-07-23 14:12:162楼 得分:0
我在wince下调,好像没有这个api   ,我试过getsystemmenu,好像也不太对,谢谢
发表于:2007-07-23 14:47:403楼 得分:10
getsystemmenu
this   function   is   implemented   as   a   macro   to   maintain   compatibility   with   existing   code.   use   the   menu   handle   returned   by   this   macro   to   disable   the   close   button.   there   is   no   other   use   for   the   return   value.

hmenu   getsystemmenu(
hwnd   hwnd,  
bool   brevert   );
parameters
hwnd  
[in]   handle   to   the   window   that   will   own   a   copy   of   the   window   menu.  
brevert  
[in]   boolean   that   specifies   the   action   to   be   taken.   if   this   parameter   is   false,   getsystemmenu   returns   the   handle   to   the   copy   of   the   window   menu   currently   in   use.   the   copy   is   initially   identical   to   the   window   menu,   but   it   can   be   modified.  
if   this   parameter   is   true,   getsystemmenu   resets   the   window   menu   back   to   the   default   state.   the   previous   window   menu,   if   any,   is   destroyed.  

return   values
if   the   brevert   parameter   is   false,   the   return   value   is   the   handle   to   a   copy   of   the   window   menu.   if   the   brevert   parameter   is   true,   the   return   value   is   null.  

remarks
use   the   following   code   to   disable   the   close   button:

enablemenuitem   (getsystemmenu(hwnd,   false),   sc_close,mf_bycommand   ¦   mf_grayed);
requirements

runs   on   versions   defined   in   include   link   to  
windows   ce   os   1.0   and   later   winuser.h       menu.lib  


note       this   api   is   part   of   the   complete   windows   ce   os   package   as   provided   by   microsoft.   the   functionality   of   a   particular   platform   is   determined   by   the   original   equipment   manufacturer   (oem)   and   some   devices   may   not   support   this   api.

发表于:2007-07-23 15:05:214楼 得分:0
这个我试过了,得到的hmenu句柄是有效的,但是我调用enablemenuitem去gray   menu中的某项时返回-1,即找不到菜单项,这个菜单是我用shcreatemenubar创建的,并和我的窗口绑定,是不是用getsystemmenu得到的menu句柄不是我创建的那个menu,而是系统的menu啊?
发表于:2007-07-24 14:12:295楼 得分:0
难道在win32下(不用mfc),想更改菜单就没有方法了么?晕
发表于:2007-07-25 18:24:396楼 得分:10
this   function   retrieves   the   handle   to   the   pop-up   menu   activated   by   the   specified   menu   item.  

hmenu   getsubmenu(
    hmenu   hmenu,  
    int   npos  
);  
发表于:2007-07-25 18:59:007楼 得分:10
hmenu=getmenu(hwnd);//返回主菜单句柄
然后
enablemenuitem(hmenu,id,mf_grayed);
id是你要使其无效的那个菜单项id!
getsystemmenu返回系统菜单!   而不是你创建的菜单
发表于:2007-07-26 09:00:598楼 得分:10
hmenu   =   commandbar_getmenu(m_hwndcecommandbar,   0);
发表于:2007-07-26 10:44:099楼 得分:0
楼主     把我的方法试下啊   看行不行     应该没问题的啊!!!


快速检索

最新资讯
热门点击