Hey Guys, this is somewhat related to another post in here but my specific question was "answered" and so I thought I would make a new post that is referencing the same code, with slightly different issues.
Setup: I am using a label docked to the main GUI to set the size of a child GUI.
Issue: When I slowly drag the borders, I can see my green label kind of peeking out from behind the GUI, not a huge problem I guess. If I drag the border very quicky I can get the offset to be really big (200-300 pixels)
** Edit - I just realized that the child of the child GUI actually does not display this same "lag" or difference in sizing. hmmmm
*discaimer! - Melba if you see this, I know you have Aero disabled so I understand if you don't want anything to do with this one! haha
Setup: Using windows message WM_WINDOWPOSCHANGING. This should give me a message "While" the window is changing. There is a WM_WINDOWPOSCHANGED, which should fire after the change happens.
Issue: Upon a normal maximize/restore methods (double clicking title bar, or using the buttons) the window behaves. Upon an Aero Snap maximize/restore the update only happens AFTER I let go of my left click. So while dragging the window down from its maximized state the child GUI's remain maximized until I let go of the left click mouse button and it resizes. I really want this to resize the second it unsnaps from the maximized state.
**Edit - This is due to the way I am handling the flags parameter of the WINDOWPOS Struct. I'm masking only using 1 of the members and it only sees that once the LMB is released. So I am basically misusing the message because im not very familiar with it I have experimented with bitOR(member1, member2, member3) because im thinking SWP_FRAMECHANGED is not the only member I should be masking against "flags" (although it works somewhat)
Here is my code.
#include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> $iGuiWidth = 660 $iGUIHeight = 320 $DividerOffset = 244 Global $aGUIPos Global $hgui, $hgui1, $hguiInner1, $cLabel_1, $cLabel_2, $cLabel_3, $iOFfset_X1, $iOFfset_Y1 Global $bSysMsg = False GUI() GUIRegisterMsg($WM_SIZE, "_WM_SIZE") GUIRegisterMsg($WM_WINDOWPOSCHANGING, "_WM_WINDOWPOSCHANGING") Func GUI() $hgui = GUICreate("test", $iGuiWidth, $iGUIHeight, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_POPUP)) GUISetBkColor(0x666666) $cLabel_1 = GUICtrlCreateLabel("I am the label", 4, 65, $iGuiWidth - 7, 250) GUICtrlSetBkColor(-1, 0x00FF00) GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKTOP, $GUI_DOCKBOTTOM, $GUI_DOCKWIDTH, $GUI_DOCKRIGHT)) GUICtrlSetState(-1, $GUI_DISABLE) GUISetState() $hgui1 = GUICreate("", $iGuiWidth - 7, $iGUIHeight - 70, -1, 60, $WS_POPUP, $WS_EX_MDICHILD, $hgui) GUISetBkColor(0x888888) GUISetState() $Divider = GUICtrlCreateLabel('', $DividerOffset, 0, 5, 250) GUICtrlSetBkColor(-1, 0xFF0000) GUICtrlSetResizing(-1, BitOR($GUI_DOCKWIDTH, $GUI_DOCKLEFT, $GUI_DOCKTOP, $GUI_DOCKBOTTOM)) GUICtrlSetCursor(-1, 13) GUISetState() $cLabel_2 = GUICtrlCreateLabel("I am the label", 249, 25, 403, 225) GUICtrlSetBkColor(-1, 0x0000FF) GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKTOP, $GUI_DOCKBOTTOM, $GUI_DOCKWIDTH, $GUI_DOCKRIGHT)) GUICtrlSetState(-1, $GUI_DISABLE) GUISetState() $hGuiInner1 = GUICreate("", 403, 225, 252,28, $WS_POPUP, $WS_EX_MDICHILD, $hgui1) GUISetBkColor(0x555555) GUISetState() _GetGuiPos($hgui,0,1) _GetGuiPos($hgui1,2,3) ;~ _GetGuiPos(hgui2,3,4) For $i = 0 to 5 ConsoleWrite("$aguipos[" & $i & "]:=" & $aguipos[$i] & @LF) Next EndFunc ;==>GUI While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Quit() EndSwitch If $bSysMsg Then $bSysMsg = False _Resize_GUIs() EndIf WEnd Func Quit() Exit EndFunc ;==>Quit Func _Resize_GUIs() ;GUI1 $aWin1 = WinGetPos($hgui) $aRet1 = ControlGetPos($hgui, "", $cLabel_1) WinMove($hgui1, "", $aWin1 + $aGUIPos + $aRet1, $aWin1 + $aGUIPos + $aRet1, $aRet1, $aRet1) $aWin2 = WinGetPos($hgui1) $aRet2 = ControlGetPos($hgui1, "", $cLabel_2) WinMove($hguiInner1, "", $aWin2 + $aGUIPos + $aRet2, $aWin2 + $aGUIPos + $aRet2, $aRet2, $aRet2) ;~ $aWin3 = WinGetPos($hgui) ;~ $aRet3 = ControlGetPos($hgui, "", $cLabel_3) ;~ WinMove($hgui1, "", $aWin3 + $aGUIPos + $aRet3, $aWin3 + $aGUIPos + $aRet3, $aRet3, $aRet3) EndFunc ;==>_Resize_GUIs func _WM_WINDOWPOSCHANGING($hWnd, $msg, $wParam, $lParam) Local $winpos_Struct = DllStructCreate("hwnd hwnd;hwnd hwndInsertAfter;int x;int y;int cx;int cy;uint flags", $lParam) $MaximizeOrRestore = bitand(DllStructGetData($winpos_Struct, "flags"), $SWP_FRAMECHANGED) if $MaximizeOrRestore > 0 then $bSysMsg = True endif EndFunc Func _WM_SIZE($hWnd, $msg, $wParam, $lParam) _Resize_GUIs() Return $GUI_RUNDEFMSG EndFunc ;==>_WM_SIZE Func _Exit($s_Msg) MsgBox(0, "Error", $s_Msg) Exit EndFunc Func _GetGuiPos($hTargGUI,$iArrayEle1,$iArrayEle2) $aWin = WinGetPos($hTargGUI) Local $tPoint = DllStructCreate("int X;int Y") DllStructSetData($tPoint, "X", 0) DllStructSetData($tPoint, "Y", 0) _WinAPI_ClientToScreen($hTargGUI, $tPoint) $aGUIPos[$iArrayEle1] = DllStructGetData($tPoint, "X") - $aWin $aGUIPos[$iArrayEle2] = DllStructGetData($tPoint, "Y") - $aWin EndFunc