得到菜单的标签和得到菜单的tag不是同一个概念吧。 tag是方便你编程用的,你可以存储一些临时的数据放在里面,而不用定义变量。如下就是对tag的很好的利用在某个窗体中单击Button private sub Button_click() Form1.Tag="1" Form1.show end sub'//在Form1窗体中 private sub Form_load() select case lcase(me.tag) case "1" '//只显示属性页的第一页 case "2" '//只显示属性页的第二页 case else '//显示所有属性页 end select end sub
通过菜单句柄 可以用 Private Declare Function GetMenu Lib "user32" Alias "GetMenu" (ByVal hwnd As Long) As Long Private Declare Function GetSubMenu Lib "user32" Alias "GetMenu" (ByVal hwnd As Long) As LongPublic Declare Function SetMenuItemInfo Lib "user32" Alias "SetMenuItemInfoA" (ByVal hMenu As Long, ByVal un As Long, ByVal bool As Boolean, lpcMenuItemInfo As MENUITEMINFO) As LongPublic Declare Function GetMenuItemInfo Lib "user32" Alias "GetMenuItemInfoA" (ByVal hMenu As Long, ByVal un As Long, ByVal b As Long, lpMenuItemInfo As MENUITEMINFO) As LongPublic Type MENUITEMINFO cbSize As Long fMask As Long fType As Long fState As Long wID As Long hSubMenu As Long hbmpChecked As Long hbmpUnchecked As Long dwItemData As Long dwTypeData As String cch As Long End Type参考 http://www.jiujiang.gov.cn/hjp/vbvf/vb/MENUITEMINFO.htm
顶楼的,按照你的要求,为什么需要菜单的句柄?菜单的句柄是在要写API的时候才用得上。 你直接这样写不可以吗? if menu1.tag=1 then menu1.text=werwer elseif menu1.tag=10 then …… end if
tag是方便你编程用的,你可以存储一些临时的数据放在里面,而不用定义变量。如下就是对tag的很好的利用在某个窗体中单击Button
private sub Button_click()
Form1.Tag="1"
Form1.show
end sub'//在Form1窗体中
private sub Form_load()
select case lcase(me.tag)
case "1"
'//只显示属性页的第一页
case "2"
'//只显示属性页的第二页
case else
'//显示所有属性页
end select
end sub
可以用
Private Declare Function GetMenu Lib "user32" Alias "GetMenu" (ByVal hwnd As Long) As Long
Private Declare Function GetSubMenu Lib "user32" Alias "GetMenu" (ByVal hwnd As Long) As LongPublic Declare Function SetMenuItemInfo Lib "user32" Alias "SetMenuItemInfoA" (ByVal hMenu As Long, ByVal un As Long, ByVal bool As Boolean, lpcMenuItemInfo As MENUITEMINFO) As LongPublic Declare Function GetMenuItemInfo Lib "user32" Alias "GetMenuItemInfoA" (ByVal hMenu As Long, ByVal un As Long, ByVal b As Long, lpMenuItemInfo As MENUITEMINFO) As LongPublic Type MENUITEMINFO
cbSize As Long
fMask As Long
fType As Long
fState As Long
wID As Long
hSubMenu As Long
hbmpChecked As Long
hbmpUnchecked As Long
dwItemData As Long
dwTypeData As String
cch As Long
End Type参考
http://www.jiujiang.gov.cn/hjp/vbvf/vb/MENUITEMINFO.htm
顶楼的,按照你的要求,为什么需要菜单的句柄?菜单的句柄是在要写API的时候才用得上。 你直接这样写不可以吗? if menu1.tag=1 then
menu1.text=werwer
elseif menu1.tag=10 then
……
end if
Windows系统怎么知道
我要求在API中能使用,不是VB自带的。
谢谢大家,快帮忙!谢谢!