在windows mobile 上如何修改菜单上的文字呢?
我原先也只是看别人的代码,然后copy过来自己用,有的时候弄不清楚所以然,就会出错。
通过下面的方法,我们可以修改菜单上的文字:
1
HMENU hMenu
=
NULL;
2![](https://i-blog.csdnimg.cn/blog_migrate/2f88ce130b654eb5dc6788e02dbcfc90.gif)
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);
//
删除被改写的菜单
![](https://i-blog.csdnimg.cn/blog_migrate/cbef093dcc044b2793832001e2365e43.gif)
2
![](https://i-blog.csdnimg.cn/blog_migrate/2f88ce130b654eb5dc6788e02dbcfc90.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/dbf989d57862681739b642d8621fe1f0.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/918e8df969f9f8c8d002f25cda86cade.gif)
3
![](https://i-blog.csdnimg.cn/blog_migrate/cbef093dcc044b2793832001e2365e43.gif)
4
![](https://i-blog.csdnimg.cn/blog_migrate/cbef093dcc044b2793832001e2365e43.gif)
5
![](https://i-blog.csdnimg.cn/blog_migrate/cbef093dcc044b2793832001e2365e43.gif)
6
![](https://i-blog.csdnimg.cn/blog_migrate/cbef093dcc044b2793832001e2365e43.gif)
7
![](https://i-blog.csdnimg.cn/blog_migrate/cbef093dcc044b2793832001e2365e43.gif)
8
![](https://i-blog.csdnimg.cn/blog_migrate/cbef093dcc044b2793832001e2365e43.gif)
9
![](https://i-blog.csdnimg.cn/blog_migrate/cbef093dcc044b2793832001e2365e43.gif)
通过上面的方法,我们就能修改菜单上的文字。
此外,学习一下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.