怎么在每个标签上创建不同的右键菜单
本帖最后由 omegabomb 于 2009-9-12 11:39 编辑$Tab=GUICtrlCreateTab(......)
$Tab1=GUICtrlCreateTabItem("标签一")
$Tab2=GUICtrlCreateTabItem("标签二")
用GUICtrlCreateContextMenu($Tab)只能创建整个Tab上的右键,这样在每个标签上都会有菜单。
本想用GUICtrlGetHandle来获取Tab2的Handle,发现GUICtrlGetHandle不支持TabItem。
假如只想在标签二上有右键菜单,标签一上没,怎么实现呢? 继续等待解答 顶起继续问 楼主可以尝试这样建TAB
#include <GUIConstants.au3>
#include <WindowsConstants.au3>
Dim $width = 780, $height = 650, $left = 20, $top = 8
$main_GUI = GUICreate("公交查询系统", $width, $height, -1, -1)
GUISetState()
$child1 = GUICreate("", $width - 24, $height - 84, 12, 81, BitOR($WS_CHILD, $WS_TABSTOP), -1, $main_GUI)
$contextmenu = GUICtrlCreateContextMenu ()
$newsubmenu = GUICtrlCreateMenu ("new", $contextmenu)
$textitem = GUICtrlCreateMenuitem ("text", $newsubmenu)
$fileitem = GUICtrlCreateMenuitem ("Open", $contextmenu)
$saveitem = GUICtrlCreateMenuitem ("Save", $contextmenu)
GUISetBkColor(0xFFFFFF)
;~ gonggao($gonggao)
GUISetState()
$child2 = GUICreate("", $width - 24, $height - 84, 12, 81, BitOR($WS_CHILD, $WS_TABSTOP), -1, $main_GUI)
GUISetBkColor(0xFFFFFF)
GUICtrlCreateTabItem("")
;~ xianlulist(0)
GUISetState()
GUISwitch($main_GUI)
$main_tab = GUICtrlCreateTab(10, 60, $width - 18, $height - 80)
$main_tabitem1 = GUICtrlCreateTabItem("公告")
$main_tabitem2 = GUICtrlCreateTabItem("线路查询")
GUICtrlCreateTabItem("")
GUICtrlSetFont($main_tab, 10)
GUICtrlSetState($main_tabitem1, $GUI_SHOW)
GUISwitch($child1)
While 1
$nmsg = GUIGetMsg()
Switch $nmsg
Case $main_tab
$tabidx = GUICtrlRead($main_tab)
;~ MsgBox(0,0,$tabidx)
Select
Case $tabidx = 0
GUISetState(@SW_HIDE, $child2)
GUISetState(@SW_SHOW, $child1)
Case $tabidx = 1
GUISetState(@SW_HIDE, $child1)
GUISetState(@SW_SHOW, $child2)
Case Else
EndSelect
Case $GUI_EVENT_CLOSE
exit
EndSwitch
WEnd WM_RBUTTUPUP
_WinAPI_SetWindowLong
TrackPopupMenuEx (user32.dll) 大绯狼的代码可以实现,但有点复杂,我再研究研究 讨论一下,这样可以不可以,把tabitem和内部空件做成分组(包括右键菜单),直接隐藏组或显示组
页:
[1]