现在的位置: 首页 > 综合 > 正文

如何修改菜单上的文字

2013年04月28日 ⁄ 综合 ⁄ 共 870字 ⁄ 字号 评论关闭

在windows mobile 上如何修改菜单上的文字呢?
我原先也只是看别人的代码,然后copy过来自己用,有的时候弄不清楚所以然,就会出错。
通过下面的方法,我们可以修改菜单上的文字:

1
HMENU hMenu
=
NULL;

2

    TBBUTTONINFO tbbi 

=
 

{
0
}

;

3

    tbbi.cbSize 

=
 
sizeof
(tbbi);

4

    tbbi.dwMask 

=
 TBIF_LPARAM 
|
 TBIF_BYINDEX;

5

    SendMessage(hMenuHWND, TB_GETBUTTONINFO, 

1
, (LPARAM)
&
tbbi); 
//
修改菜单项 在左边为0,在右边为1      


6

    hMenu 
=
 (HMENU)tbbi.lParam;

7

    

8

    InsertMenu(hMenu,beforeItem,MF_BYCOMMAND,afterItem,sText);    

//
加入含有欲改写文本的菜单项


9

    DeleteMenu(hMenu,beforeItem,MF_BYCOMMAND);    
//
删除被改写的菜单

通过上面的方法,我们就能修改菜单上的文字。

此外,学习一下TB_GETBUTTONINFO
消息:TB_GETBUTTONINFO
作用:This message retrieves the information for a button in a toolbar.
使用:wParam
= (WPARAM)(INT)
iID



;

            lParam
= (LPARAM)(LPTBBUTTONINFO)
lptbbi



;
参数介绍:

     iID
  Button identifier.
     lptbbi
Long pointer to a TBBUTTONINFO
structure that receives the button information. The cbSize
and dwMask
members of this structure must be filled in prior to sending this message.

抱歉!评论已关闭.