遍历菜单项
来源:互联网 发布:js判断控件是否隐藏 编辑:程序博客网 时间:2024/06/10 04:32
//遍历任何窗体的MenuItem
//用了两个多小时
//略做修改,就可以实现其他功能,GetMenuItemInfo提供的信息足够用了
procedure ExplorerMenuItem(MenuHandle: THandle);
var
MenuIndex: Integer;
MenuCaptionArray: array[1..255] of Char;
MenuCaptionString: String;
ItemInfo: TMenuItemInfo;
Buffer: array[0..20] of Char;
begin
for MenuIndex := 0 to GetMenuItemCount(MenuHandle) - 1 do begin
//Something todo. Here we get the caption
GetMenuString(MenuHandle, MenuIndex, @MenuCaptionArray, 255, MF_BYPOSITION);
MenuCaptionString := MenuCaptionArray;
SetLength(MenuCaptionString,StrLen(PChar(MenuCaptionString)));
ShowMessage('Menu Caption: ' + MenuCaptionString);
//Get caption ends here.
ItemInfo.cbSize := SizeOf(TMenuItemInfo);
ItemInfo.fMask := MIIM_SUBMENU;
ItemInfo.dwTypeData := Buffer;
ItemInfo.cch := SizeOf(Buffer);
GetMenuItemInfo(MenuHandle, MenuIndex, True, ItemInfo);
//submenu, calls itself
if ItemInfo.hSubMenu <> 0 then begin
ExplorerMenuItem(ItemInfo.hSubMenu);
end;
end;
end;
--lw549的专栏
//用了两个多小时
//略做修改,就可以实现其他功能,GetMenuItemInfo提供的信息足够用了
procedure ExplorerMenuItem(MenuHandle: THandle);
var
MenuIndex: Integer;
MenuCaptionArray: array[1..255] of Char;
MenuCaptionString: String;
ItemInfo: TMenuItemInfo;
Buffer: array[0..20] of Char;
begin
for MenuIndex := 0 to GetMenuItemCount(MenuHandle) - 1 do begin
//Something todo. Here we get the caption
GetMenuString(MenuHandle, MenuIndex, @MenuCaptionArray, 255, MF_BYPOSITION);
MenuCaptionString := MenuCaptionArray;
SetLength(MenuCaptionString,StrLen(PChar(MenuCaptionString)));
ShowMessage('Menu Caption: ' + MenuCaptionString);
//Get caption ends here.
ItemInfo.cbSize := SizeOf(TMenuItemInfo);
ItemInfo.fMask := MIIM_SUBMENU;
ItemInfo.dwTypeData := Buffer;
ItemInfo.cch := SizeOf(Buffer);
GetMenuItemInfo(MenuHandle, MenuIndex, True, ItemInfo);
//submenu, calls itself
if ItemInfo.hSubMenu <> 0 then begin
ExplorerMenuItem(ItemInfo.hSubMenu);
end;
end;
end;
--lw549的专栏
- 遍历菜单项
- 遍历菜单项
- 遍历所有菜单项
- C#遍历菜单项
- 遍历控件 和 菜单项
- Winform 菜单遍历
- Winform 菜单遍历
- 关于递归遍历菜单
- c#中遍历菜单
- silverlight遍历树形菜单
- MFC 遍历菜单项 获取状态 改变状态
- C#----遍历菜单项加载到TreeView中(目前只支持二级菜单)
- 遍历节点生成菜单(递归)
- ZENCART遍历二级导航菜单
- C# 遍历右键二级菜单
- 多层菜单的循环遍历
- 菜单、菜单条、菜单项
- 菜单条、菜单、菜单项
- Windows Mobile开发环境搭建指南
- 终究还是我伤了你
- 在Smartphone/Pocket PC 2003上设置提醒
- 孙伟院长在中印软件峰会上的讲话
- 点播IOD与PUSH方式(转摘)
- 遍历菜单项
- 坚持学习java
- 使用微波炉的十大忌讳
- 呵呵 CSDN好玩好玩
- 史上死得最搞笑的几位皇帝
- 利用.NET开发DB2 Everyplace应用程序
- The VS7.X Debugger doesn't work, What can I do?
- Eclipse won't build/run because it's "missing VM"
- 寻找rational rose过程中的强烈感触