父子窗口,如何限制子窗口不覆盖父窗口的工具列??限制子窗口的最大化范围??[已解决]
本帖最后由 kk_lee69 于 2015-3-17 23:02 编辑如图:
父子窗口,如何限制子窗口不覆盖父窗口的工具列??限制子窗口的最大化范围??
意思即是 等同 限制 父窗口的客户区范围不知有何办法可以处理??
#include <GuiToolbar.au3>
#include <GuiMenu.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
#include <GuiImageList.au3>
#include <ListViewConstants.au3>
#include <GuiListView.au3>
Opt("GUIOnEventMode", 1)
;Opt('GUIResizeMode', 802)
;Opt("GUICoordMode", 2)
$Debug_TB = False ; 檢查傳遞給函數的類名, 設置為True並輸出到一個控制項的控制碼,用於檢查它是否工作
Global $WinMain, $iMemo, $hToolbar, $hMenu, $ListViewm1, $TreeView, $ToolbarOn
Global $Inputf5, $Inputf6, $Inputf7, $Inputf8, $Inputf9, $Inputf10
Global Enum $Computer = 1000, $Network, $idSavea, $idOpen, $_IE, $_IEA, $_IEAB
Dim $aStrings
_Main()
Func _Main()
; 創建 GUI
$WinMain = GUICreate("Toolbar", 800, 505, -1, -1, $WS_MAXIMIZE + $WS_MAXIMIZEBOX + $WS_MINIMIZEBOX + $WS_SIZEBOX)
GUISetOnEvent($GUI_EVENT_CLOSE, "_exit")
;$hToolbar = _GUICtrlToolbar_Create($WinMain)
;_GUICtrlToolbar_SetExtendedStyle($hToolbar, $TBSTYLE_EX_DRAWDDARROWS)
$MenuItem1 = GUICtrlCreateMenu("MenuItem1")
$MenuItem2 = GUICtrlCreateMenu("MenuItem2", $MenuItem1)
$MenuItem6 = GUICtrlCreateMenuItem("MenuItem6", $MenuItem2)
$MenuItem3 = GUICtrlCreateMenu("MenuItem3", $MenuItem2)
$MenuItem7 = GUICtrlCreateMenuItem("MenuItem7", $MenuItem3)
$MenuItem5 = GUICtrlCreateMenuItem("MenuItem5", $MenuItem1)
$MenuItem4 = GUICtrlCreateMenuItem("MenuItem4", $MenuItem1)
$hToolbar = _GUICtrlToolbar_Create($WinMain);工具條
_GUICtrlToolbar_SetStyleCustomErase($hToolbar, True)
_GUICtrlToolbar_SetExtendedStyle($hToolbar, $TBSTYLE_EX_DRAWDDARROWS)
$hImage = _GUIImageList_Create(24, 24, 5, 3, 3)
;;_GUIImageList_AddIcon($hImage, "shell32.dll", 15, True)
_GUIImageList_AddIcon($hImage, "shell32.dll", 39, True)
_GUIImageList_AddIcon($hImage, "shell32.dll", 165, True)
_GUIImageList_AddIcon($hImage, "shell32.dll", 46, True)
_GUIImageList_AddIcon($hImage, "shell32.dll", 169, True)
_GUIImageList_AddIcon($hImage, "shell32.dll", 20, True)
_GUIImageList_AddIcon($hImage, "shell32.dll", 6, True)
_GUIImageList_AddIcon($hImage, "shell32.dll", 80, True)
_GUICtrlToolbar_SetImageList($hToolbar, $hImage)
$aStrings = _GUICtrlToolbar_AddString($hToolbar, "客戶管理")
$aStrings = _GUICtrlToolbar_AddString($hToolbar, "生產管理")
$aStrings = _GUICtrlToolbar_AddString($hToolbar, "銷售管理")
$aStrings = _GUICtrlToolbar_AddString($hToolbar, "配件管理")
$aStrings = _GUICtrlToolbar_AddString($hToolbar, "財務管理")
$aStrings = _GUICtrlToolbar_AddString($hToolbar, "管理")
$aStrings = _GUICtrlToolbar_AddString($hToolbar, "刷新")
; 添加按鈕
_GUICtrlToolbar_AddButton($hToolbar, $Computer, 0, $aStrings)
_GUICtrlToolbar_AddButton($hToolbar, $Network, 1, $aStrings)
_GUICtrlToolbar_AddButton($hToolbar, $idSavea, 2, $aStrings);, $BTNS_WHOLEDROPDOWN)
;_GUICtrlToolbar_AddButtonSep($hToolbar)
_GUICtrlToolbar_AddButton($hToolbar, $idOpen, 3, $aStrings);, $BTNS_WHOLEDROPDOWN)
_GUICtrlToolbar_AddButtonSep($hToolbar)
_GUICtrlToolbar_AddButton($hToolbar, $_IE, 4, $aStrings, $BTNS_WHOLEDROPDOWN)
;_GUICtrlToolbar_AddButtonSep($hToolbar)
_GUICtrlToolbar_AddButton($hToolbar, $_IEA, 5, $aStrings, $BTNS_WHOLEDROPDOWN)
_GUICtrlToolbar_AddButton($hToolbar, $_IEAB, 6, $aStrings);, $BTNS_WHOLEDROPDOWN)
$aSize = _GUICtrlToolbar_GetButtonSize($hToolbar)
_GUICtrlToolbar_SetButtonSize($hToolbar, $aSize, 60)
MemoWrite("Extended sytles: " & _GUICtrlToolbar_GetExtendedStyle($hToolbar))
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
GUIRegisterMsg($WM_COMMAND, "WM_COMMANDD")
GUISetState(@SW_SHOW)
Global $hNew_Child = GUICreate("Child " , 300, 300, 10, 0, BitOR($GUI_SS_DEFAULT_GUI , $WS_MAXIMIZEBOX),-1,$WinMain)
_WinAPI_SetParent($hNew_Child, $WinMain)
; GUIRegisterMsg(36, "_SetMinMax")
GUISetState()
; 迴圈直到用戶退出
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc ;==>_Main
; 寫入消息到 memo
Func MemoWrite($sMessage = "")
GUICtrlSetData($iMemo, $sMessage & @CRLF, 1)
EndFunc ;==>MemoWrite
Func _exit()
Exit
EndFunc ;==>_exit
本帖最后由 131738 于 2015-3-11 11:52 编辑
回复 1# kk_lee69
Opt("PixelCoordMode", 2)
然后调整子窗顶坐标:
Global $hNew_Child = GUICreate("Child " , 300, 300, 10, 50, BitOR($GUI_SS_DEFAULT_GUI , $WS_MAXIMIZEBOX),-1,$WinMain) 回复 2# 131738
這樣是調整位置 而已我的意思是子窗 不管是移動 或者 最大化最小化都不可以 覆蓋到 TOOLBAR 的部分 再而已吧..............;功能:控制窗口最小尺寸100 x 100,最大尺寸400 x 400
Global Const $WM_GETMINMAXINFO = 0x0024
$Gui = GUICreate("控制窗口大小", 300, 300, -1, -1, 0x00040000) ;$WS_SIZEBOX
GUISetState()
GUIRegisterMsg($WM_GETMINMAXINFO, "WM_GETMINMAXINFO")
Do
Until GUIGetMsg() = -3
Func WM_GETMINMAXINFO($hwnd, $Msg, $wparam, $lparam)
Local $tagMINMAXINFO = "int;int;int;int;int;int;int;int;int;int"
$MINMAXINFO = DllStructCreate($tagMINMAXINFO, $lparam)
DllStructSetData($MINMAXINFO, 7, 100) ;最小宽度
DllStructSetData($MINMAXINFO, 8, 100) ;最小高度
DllStructSetData($MINMAXINFO, 9, 400) ;最大宽度
DllStructSetData($MINMAXINFO, 10, 400) ;最大高度
EndFunc ;==>WM_GETMINMAXINFO 回复 4# 131738
我知道 這個 可以限制 視窗大小
也查過很多資料 包括
如何讓子表單最小化到父表單的下方的狀態列上面
這篇中提到的 WM_WINDOWPOSCHANGING
老實說 我資質愚笨 就是寫不出來....
上面語法中WM_GETMINMAXINFO這個只有最大寬度 最小寬度 最大高度 最小高度沒有xy 的位置
看起來要用 WM_WINDOWPOSCHANGING 但是 這個我手上的資料 又不鎖 滑鼠拖動的時候 不可以覆蓋到 工具列
所以還在研究~~ 本帖最后由 131738 于 2015-3-16 11:54 编辑
Global $hNew_Child = GUICreate("Child ", 300, 300, 10, 50, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX), -1, $WinMain)
_WinAPI_SetParent($hNew_Child, $WinMain)
GUISetOnEvent($GUI_EVENT_MAXIMIZE, "_S", $hNew_Child)
Func _S()
Select
Case @GUI_CtrlId = $GUI_EVENT_MAXIMIZE
$r = WinGetClientSize($WinMain)
WinMove($hNew_Child, "Child ", 0, 50, $r, $r - 50)
EndSelect
EndFunc
本帖最后由 ceoguang 于 2015-3-17 17:26 编辑
回复 5# kk_lee69 #include <GuiToolbar.au3>
#include <GuiMenu.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
#include <GuiImageList.au3>
#include <ListViewConstants.au3>
#include <GuiListView.au3>
Opt("GUIOnEventMode", 1)
;Opt('GUIResizeMode', 802)
;Opt("GUICoordMode", 2)
$Debug_TB = False ; 檢查傳遞給函數的類名, 設置為True並輸出到一個控制項的控制碼,用於檢查它是否工作
Global $WinMain, $iMemo, $hToolbar, $hMenu, $ListViewm1, $TreeView, $ToolbarOn
Global $Inputf5, $Inputf6, $Inputf7, $Inputf8, $Inputf9, $Inputf10
Global Enum $Computer = 1000, $Network, $idSavea, $idOpen, $_IE, $_IEA, $_IEAB
Dim $aStrings
_Main()
Func _Main()
; 創建 GUI
$WinMain = GUICreate("Toolbar", 800, 505, -1, -1, $WS_MAXIMIZE + $WS_MAXIMIZEBOX + $WS_MINIMIZEBOX + $WS_SIZEBOX)
GUISetOnEvent($GUI_EVENT_CLOSE, "_exit")
;$hToolbar = _GUICtrlToolbar_Create($WinMain)
;_GUICtrlToolbar_SetExtendedStyle($hToolbar, $TBSTYLE_EX_DRAWDDARROWS)
$MenuItem1 = GUICtrlCreateMenu("MenuItem1")
$MenuItem2 = GUICtrlCreateMenu("MenuItem2", $MenuItem1)
$MenuItem6 = GUICtrlCreateMenuItem("MenuItem6", $MenuItem2)
$MenuItem3 = GUICtrlCreateMenu("MenuItem3", $MenuItem2)
$MenuItem7 = GUICtrlCreateMenuItem("MenuItem7", $MenuItem3)
$MenuItem5 = GUICtrlCreateMenuItem("MenuItem5", $MenuItem1)
$MenuItem4 = GUICtrlCreateMenuItem("MenuItem4", $MenuItem1)
$hToolbar = _GUICtrlToolbar_Create($WinMain);工具條
_GUICtrlToolbar_SetStyleCustomErase($hToolbar, True)
_GUICtrlToolbar_SetExtendedStyle($hToolbar, $TBSTYLE_EX_DRAWDDARROWS)
$hImage = _GUIImageList_Create(24, 24, 5, 3, 3)
;;_GUIImageList_AddIcon($hImage, "shell32.dll", 15, True)
_GUIImageList_AddIcon($hImage, "shell32.dll", 39, True)
_GUIImageList_AddIcon($hImage, "shell32.dll", 46, True)
_GUIImageList_AddIcon($hImage, "shell32.dll", 165, True)
_GUIImageList_AddIcon($hImage, "shell32.dll", 169, True)
_GUIImageList_AddIcon($hImage, "shell32.dll", 20, True)
_GUIImageList_AddIcon($hImage, "shell32.dll", 6, True)
_GUIImageList_AddIcon($hImage, "shell32.dll", 80, True)
_GUICtrlToolbar_SetImageList($hToolbar, $hImage)
$aStrings = _GUICtrlToolbar_AddString($hToolbar, "客戶管理")
$aStrings = _GUICtrlToolbar_AddString($hToolbar, "生產管理")
$aStrings = _GUICtrlToolbar_AddString($hToolbar, "銷售管理")
$aStrings = _GUICtrlToolbar_AddString($hToolbar, "配件管理")
$aStrings = _GUICtrlToolbar_AddString($hToolbar, "財務管理")
$aStrings = _GUICtrlToolbar_AddString($hToolbar, "管理")
$aStrings = _GUICtrlToolbar_AddString($hToolbar, "刷新")
; 添加按鈕
_GUICtrlToolbar_AddButton($hToolbar, $Computer, 0, $aStrings)
_GUICtrlToolbar_AddButton($hToolbar, $Network, 1, $aStrings)
_GUICtrlToolbar_AddButton($hToolbar, $idSavea, 2, $aStrings);, $BTNS_WHOLEDROPDOWN)
;_GUICtrlToolbar_AddButtonSep($hToolbar)
_GUICtrlToolbar_AddButton($hToolbar, $idOpen, 3, $aStrings);, $BTNS_WHOLEDROPDOWN)
_GUICtrlToolbar_AddButtonSep($hToolbar)
_GUICtrlToolbar_AddButton($hToolbar, $_IE, 4, $aStrings, $BTNS_WHOLEDROPDOWN)
;_GUICtrlToolbar_AddButtonSep($hToolbar)
_GUICtrlToolbar_AddButton($hToolbar, $_IEA, 5, $aStrings, $BTNS_WHOLEDROPDOWN)
_GUICtrlToolbar_AddButton($hToolbar, $_IEAB, 6, $aStrings);, $BTNS_WHOLEDROPDOWN)
$aSize = _GUICtrlToolbar_GetButtonSize($hToolbar)
_GUICtrlToolbar_SetButtonSize($hToolbar, $aSize, 60)
MemoWrite("Extended sytles: " & _GUICtrlToolbar_GetExtendedStyle($hToolbar))
;GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
;GUIRegisterMsg($WM_COMMAND, "WM_COMMANDD")
GUISetState(@SW_SHOW)
Global $hNew_Child = GUICreate("Child ", 300, 300, 10, 0, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX), -1, $WinMain)
GUIRegisterMsg(0x46, "WM_WINDOWPOSCHANGING")
_WinAPI_SetParent($hNew_Child, $WinMain)
; GUIRegisterMsg(36, "_SetMinMax")
GUISetState()
; 迴圈直到用戶退出
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc ;==>_Main
; 寫入消息到 memo
Func MemoWrite($sMessage = "")
GUICtrlSetData($iMemo, $sMessage & @CRLF, 1)
EndFunc ;==>MemoWrite
Func _exit()
Exit
EndFunc ;==>_exit
Func WM_WINDOWPOSCHANGING($hWnd, $Msg, $wParam, $lParam)
If $hNew_Child = $hWnd Then
Local Const $tagWINDOWPOS = "hwnd hWnd;int InsertAfter;int X;int Y;int CX;int CY;int Flags"
Local $tPos = DllStructCreate($tagWINDOWPOS, $lParam)
Local $tRect = _WinAPI_GetClientRect($hToolbar)
Local $iTop = DllStructGetData($tRect, "Bottom");
If DllStructGetData($tPos, 'Y') < $iTop Then
DllStructSetData($tPos, 'Y',$iTop)
EndIf
Return 0
EndIf
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_WINDOWPOSCHANGING
上面的代码可保证无论是拖动还是最大化,都不会挡住你的ToolBar 回复 7# ceoguang
感謝 就是這個效果~~~
页:
[1]