[已解决]小声问下:_GUICtrlToolbar_Create建立的工具条可否移一下位置
本帖最后由 雨林GG 于 2010-12-3 10:52 编辑请教各位: 用_GUICtrlToolbar_Create建立的工具条,我想放在窗口的中央,而不想放在上方,不知有没有函数可以修改啊?
查了一下 Examples 中没找到用什么可以修改,也许是我的问题比较BC,各位不要见笑!
引用 Jhun 的《按钮下拉菜单》 http://www.autoitx.com/thread-16677-1-2.html#include <GuiToolbar.au3>
#include <GuiMenu.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
Global $hGUI
Local $hToolbar
Local Enum $idNew = 1000, $idOpen
$hGUI = GUICreate("Toolbar", 200,100)
$hToolbar = _GUICtrlToolbar_Create($hGUI)
_GUICtrlToolbar_SetExtendedStyle($hToolbar, $TBSTYLE_EX_DRAWDDARROWS)
GUISetState()
_GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
_GUICtrlToolbar_AddButton($hToolbar, $idNew, $STD_FILENEW, 0, $BTNS_DROPDOWN)
_GUICtrlToolbar_AddButton($hToolbar, $idOpen, $STD_FILEOPEN)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
While 1
If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit
WEnd
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
Local $tNMHDR, $iCode, $hMenu
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$iCode = DllStructGetData($tNMHDR, "Code")
If $iCode = $TBN_DROPDOWN Then
$hMenu = _GUICtrlMenu_CreatePopup()
_GUICtrlMenu_AddMenuItem($hMenu, "菜单1")
_GUICtrlMenu_AddMenuItem($hMenu, "菜单2")
_GUICtrlMenu_AddMenuItem($hMenu, "菜单3")
_GUICtrlMenu_TrackPopupMenu($hMenu, $hGUI)
_GUICtrlMenu_DestroyMenu($hMenu)
EndIf
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY 在父窗口中创建一个居中的子窗口,在子窗口中创建Toolbar。这样做不仅可以居中显示,还可以创建多个Toolbar。 本帖最后由 雨林GG 于 2010-7-7 20:29 编辑
超版真有招儿! 俺去试试~!~
BitOR($WS_CHILD,$WS_OVERLAPPED,$WS_POPUP),BitOR($WS_EX_MDICHILD,$WS_EX_TOOLWINDOW)
有一个问题:就是子窗体工具条上有一条线!~~~ #include <GuiToolbar.au3>
#include <GuiMenu.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
Global $hGUI
Local $hToolbar
Local Enum $idNew = 1000, $idOpen
$hGUI = GUICreate("Toolbar", 200,100)
GUISetState()
$test=GUICreate("Toolbar", 100,20,12,50,BitOR($WS_CHILD,$WS_OVERLAPPED,$WS_POPUP),BitOR($WS_EX_MDICHILD,$WS_EX_TOOLWINDOW),$hGUI)
$hToolbar = _GUICtrlToolbar_Create($test)
_GUICtrlToolbar_SetExtendedStyle($hToolbar, $TBSTYLE_EX_DRAWDDARROWS)
GUISetState()
_GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
_GUICtrlToolbar_AddButton($hToolbar, $idNew, $STD_FILENEW, 0, $BTNS_DROPDOWN)
_GUICtrlToolbar_AddButton($hToolbar, $idOpen, $STD_FILEOPEN)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
While 1
If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit
WEnd
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
Local $tNMHDR, $iCode, $hMenu
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$iCode = DllStructGetData($tNMHDR, "Code")
If $iCode = $TBN_DROPDOWN Then
$hMenu = _GUICtrlMenu_CreatePopup()
_GUICtrlMenu_AddMenuItem($hMenu, "菜单1")
_GUICtrlMenu_AddMenuItem($hMenu, "菜单2")
_GUICtrlMenu_AddMenuItem($hMenu, "菜单3")
_GUICtrlMenu_TrackPopupMenu($hMenu, $hGUI)
_GUICtrlMenu_DestroyMenu($hMenu)
EndIf
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
页:
[1]