CodeTinkerer Posted December 11, 2015 Share Posted December 11, 2015 Hello again!Im looking for a way to create a Resizable Frame-less/Border-less GUI window.Using the methods found here: https://www.autoitscript.com/wiki/Moving_and_Resizing_PopUp_GUIs I can get the desired outcome I want but only for a single window. My application will be using Multiple windows I would like to have this same resizable functionality.Also when using the above linked methods when the GUI loses focus, it sometime causes a crash.Is there fast-track way to simplify getting my desired outcome? Currently I have also experimented with Bitor($WS_POPUP, $WS_SIZEBOX) Which gets me the closest without using listeners/registers but still leaves me with a nasty skinny frame.i'll be using this with XSkin if that helps any also, I have re-calibrated XSkin to get the proper image formating on the GUI and now i need the window to be resizable without a Frame/Border.Perhaps there is a way to hook the resize to the Images..... lots more thinking to do, I appreciate any assistance you would have to offer. Thanks! Link to comment Share on other sites More sharing options...
CodeTinkerer Posted December 12, 2015 Author Share Posted December 12, 2015 (edited) So in an amature fashion I have been trying to understand the functionalityCurrently I am using this script to try to get the results I want. Looks like segregation between the two windows is not going to work, leaning towards the DLL calls to be the main pivotal point in the issue. probably not utilizing it right.Thoughts?expandcollapse popup#include <GuiConstants.au3> #include <windowsconstants.au3> ;Global Const $WM_LBUTTONDOWN = 0x0201 Global Const $margin = 12; distance from edge of window where dragging is possible Global $gui1, $gui2 Global $Gui = GUICreate("Win1", 420, 200, -1, -1, $WS_POPUP) GUISetBkColor(0xf1f100) Global $chk1 = GUICtrlCreateCheckbox("allow resizing and dragging", 140, 40) GUICtrlSetResizing(-1, $GUI_DOCKWIDTH) Global $Button = GUICtrlCreateButton("Exit", 140, 90, 150, 30) GUISetState(@SW_SHOW, $Gui) Local $MainWinPos = WinGetPos($gui1) Local $locFix = $MainWinPos[0] + $MainWinPos[2] Global $gui2 = GUICreate("Win2", 420, 200, $locFix, -1, $WS_POPUP) Global $chk2 = GUICtrlCreateCheckbox("allow resizing and dragging", 140, 40) GUICtrlSetResizing(-1, $GUI_DOCKWIDTH) Global $Button2 = GUICtrlCreateButton("Exit", 140, 90, 150, 30) GUISetState(@SW_SHOW, $gui2) GUIRegisterMsg($WM_LBUTTONDOWN, "WM_LBUTTONDOWN") GUIRegisterMsg($WM_MOUSEMOVE, "SetCursor") While 1 $msg = GUIGetMsg() Select Case $msg = $Button Exit Case $msg = $Button2 Exit EndSelect WEnd ;GetMousePosType returns a code depending on the border the mouse cursor is near Func GetMousePosType() Local $cp = GUIGetCursorInfo() Local $wp1 = WinGetPos($gui1) Local $wp2 = WinGetPos($gui2) Local $sidea = 0 Local $TopBota = 0 Local $sideb = 0 Local $TopBotb = 0 If $cp Then If WinActive($gui1) Then If $cp[0] < $margin Then $sidea = 1 If $cp[0] > $wp1[2] - $margin Then $sidea = 2 If $cp[1] < $margin Then $TopBota = 3 If $cp[1] > $wp1[3] - $margin Then $TopBota = 6 Return $sidea + $TopBota ElseIf WinActive($gui2) Then If $cp[0] < $margin Then $sideb = 1 If $cp[0] > $wp2[2] - $margin Then $sideb = 2 If $cp[1] < $margin Then $TopBotb = 3 If $cp[1] > $wp2[3] - $margin Then $TopBotb = 6 Return $sideb + $TopBotb EndIf EndIf EndFunc ;==>GetMousePosType Func SetCursor() Local $curs Local $curs2 If WinActive($gui1) Then If GUICtrlRead($chk1) <> $GUI_CHECKED Then Return Switch GetMousePosType() Case 0 $curs = 2 Case 1, 2 $curs = 13 Case 3, 6 $curs = 11 Case 5, 7 $curs = 10 Case 4, 8 $curs = 12 EndSwitch GUISetCursor($curs, 1) ElseIf WinActive($gui2) Then If GUICtrlRead($chk2) <> $GUI_CHECKED Then Return Switch GetMousePosType() Case 0 $curs2 = 2 Case 1, 2 $curs2 = 13 Case 3, 6 $curs2 = 11 Case 5, 7 $curs2 = 10 Case 4, 8 $curs2 = 12 EndSwitch GUISetCursor($curs2, 1) EndIf EndFunc ;==>SetCursor Func WM_LBUTTONDOWN($hWnd, $iMsg, $StartWIndowPosaram, $lParam) Local $w1 = WinGetHandle($gui1) Local $w2 = WinGetHandle($gui2) If WinActive($gui1) Then If GUICtrlRead($chk1) <> $GUI_CHECKED Then Return $GUI_RUNDEFMSG Local $drag = GetMousePosType() If $drag > 0 Then DllCall("user32.dll", "long", "SendMessage", "hwnd", $w1, "int", $WM_SYSCOMMAND, "int", 0xF000 + $drag, "int", 0) Else DllCall("user32.dll", "long", "SendMessage", "hwnd", $w1, "int", $WM_SYSCOMMAND, "int", 0xF012, "int", 0) EndIf ElseIf WinActive($gui2) Then If GUICtrlRead($chk2) <> $GUI_CHECKED Then Return $GUI_RUNDEFMSG Local $drag = GetMousePosType() If $drag > 0 Then DllCall("user32.dll", "long", "SendMessage", "hwnd", $w2, "int", $WM_SYSCOMMAND, "int", 0xF000 + $drag, "int", 0) Else DllCall("user32.dll", "long", "SendMessage", "hwnd", $w2, "int", $WM_SYSCOMMAND, "int", 0xF012, "int", 0) EndIf Else Return $GUI_RUNDEFMSG EndIf ;F001 = LHS, F002 = RHS, F003 = top, F004 = TopLeft, F005 = TopRight, F006 = Bottom, F007 = BL, F008 = BR ;F009 = move gui, same as F011 F012 to F01F ;F010, moves cursor to centre top of gui - no idea what that is useful for. ;F020 minimizes ;F030 maximizes EndFunc ;==>WM_LBUTTONDOWN Edited December 12, 2015 by Melba23 Added code tags Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 12, 2015 Moderators Share Posted December 12, 2015 CodeTinkerer,You just need to determine which GUI is under the cursor when each handler function runs - like this:expandcollapse popup#include <GuiConstants.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> Global Const $iMargin = 12; distance from edge of window where dragging is possible Global Const $SC_DRAGMOVE = 0xF012 Global $hGUI_1, $hGUI_2 Global $hGUI_1 = GUICreate("Win1", 420, 200, Default, Default, $WS_POPUP) GUISetBkColor(0xF1F100) Global $cChk_1 = GUICtrlCreateCheckbox("allow resizing and dragging", 140, 40) GUICtrlSetResizing(-1, $GUI_DOCKWIDTH) Global $cButton_1 = GUICtrlCreateButton("Exit", 140, 90, 150, 30) GUISetState(@SW_SHOW, $hGUI_1) Local $aMainWinPos = WinGetPos($hGUI_1) Local $iLocFix = $aMainWinPos[0] + $aMainWinPos[2] Global $hGUI_2 = GUICreate("Win2", 420, 200, $iLocFix, Default, $WS_POPUP) GUISetBkColor(0x00F1F1) Global $cChk_2 = GUICtrlCreateCheckbox("allow resizing and dragging", 140, 40) GUICtrlSetResizing(-1, $GUI_DOCKWIDTH) Global $cButton_2 = GUICtrlCreateButton("Exit", 140, 90, 150, 30) GUISetState(@SW_SHOW, $hGUI_2) GUIRegisterMsg($WM_LBUTTONDOWN, "_WM_LBUTTONDOWN") GUIRegisterMsg($WM_MOUSEMOVE, "_SetCursor") While 1 Switch GUIGetMsg() Case $cButton_1, $cButton_2 Exit EndSwitch WEnd Func _SetCursor() ; Get handle of GUI under the cursor Local $hUnder = _GetUnderHandle() ; Check whether we need to do anything Switch $hUnder Case $hGUI_1 If GUICtrlRead($cChk_1) <> $GUI_CHECKED Then Return Case $hGUI_2 If GUICtrlRead($cChk_2) <> $GUI_CHECKED Then Return Case Else Return EndSwitch ; Check if cursor is near the GUI border and set the cursor type accordingly Local $iCursorID Switch _GetBorderType($hUnder) Case 0 ; Not near border $iCursorID = 2 Case 1, 2 ; Near an side $iCursorID = 13 Case 3, 6 ; Near top or bottom $iCursorID = 11 Case 5, 7 ; Near top right or bottom left $iCursorID = 10 Case 4, 8 ; Near top left or bottom right $iCursorID = 12 EndSwitch GUISetCursor($iCursorID, 1, $hUnder) EndFunc ;==>SetCursor Func _WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam) ; Get handle of GUI under the cursor Local $hUnder = _GetUnderHandle() ; Check whether we need to do anything Switch $hUnder Case $hGUI_1 If GUICtrlRead($cChk_1) <> $GUI_CHECKED Then Return $GUI_RUNDEFMSG Case $hGUI_2 If GUICtrlRead($cChk_2) <> $GUI_CHECKED Then Return $GUI_RUNDEFMSG Case Else Return $GUI_RUNDEFMSG EndSwitch ; Check if cursor is Local $iCursorType = _GetBorderType($hUnder) ; If cursor is not standard If $iCursorType = 0 Then ; We need to drag GUI if cursor not over a control Local $aCurInfo = GUIGetCursorInfo($hUnder) If $aCurInfo[4] = 0 Then ; Send resize message to GUI _SendMessage($hUnder, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0) EndIf Else ; Convert cursor type to resize code - Windows makes this extremely simple $iResizeType = 0xF000 + $iCursorType ; Send resize message to GUI _SendMessage($hUnder, $WM_SYSCOMMAND, $iResizeType, 0) EndIf EndFunc ;==>WM_LBUTTONDOWN ;_GetBorderType returns a code depending on the border the mouse cursor is near Func _GetBorderType($hUnder) ; Get location of cursor within GUI Local $aCurInfo = GUIGetCursorInfo($hUnder) ; Get size of GUI Local $aWinPos = WinGetPos($hUnder) Local $iSide = 0 Local $iTopBot = 0 ; Check if close to edges If $aCurInfo[0] < $iMargin Then $iSide = 1 If $aCurInfo[0] > $aWinPos[2] - $iMargin Then $iSide = 2 ; Check if close to top/bottom If $aCurInfo[1] < $iMargin Then $iTopBot = 3 If $aCurInfo[1] > $aWinPos[3] - $iMargin Then $iTopBot = 6 ; Return combined location Return $iSide + $iTopBot EndFunc ;==>_GetBorderType Func _GetUnderHandle() ; Create structure to hold the position Local Static $tPoint = DllStructCreate($tagPOINT) ; Set the position into the structure DllStructSetData($tPoint, "x", MouseGetPos(0)) DllStructSetData($tPoint, "y", MouseGetPos(1)) ; And get the handle of the GUI under the cursor Return _WinAPI_WindowFromPoint($tPoint) EndFuncI added lots of comments but please do ask if anything is still unclear.M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
CodeTinkerer Posted December 12, 2015 Author Share Posted December 12, 2015 (edited) Melba, Thanks for your assistance and pointing me in the right direction. I was lost. I did however attempt to do as you said and identify which window was under the cursor and modify accordingly but alas my result was sloppy dysfunctional code lol. Here is what I tried:expandcollapse popup#include <GuiConstantsEx.au3> #include <Windowsconstants.au3> #include <SendMessage.au3> #include <WinAPI.au3> #include <WinAPIsys.au3> #include <Misc.au3> Local $stPoint = DllStructCreate($tagPOINT), $aPos, $hControl, $hWin, $aLastPos[2] = [-1, -1], $sLastStr = '', $sStr HotKeySet("{ESC}", "On_Exit") ; Set distance from edge of window where resizing is possible Global Const $iMargin = 4 ; Set max and min GUI sizes Global Const $iGUIMinX = 50, $iGUIMinY = 50, $iGUIMaxX = 300, $iGUIMaxY = 300 ; Create GUI Global $hGUI = GUICreate("Y", 100, 100, -1, -1, $WS_POPUP) GUISetBkColor(0x00FFF0) GUISetState() Local $wPos = WinGetPos($hGUI) ; Create GUI Global $hGUI2 = GUICreate("Z", 100, 100, $wPos[0] + 101, -1, $WS_POPUP) GUISetBkColor(0x00FF00) GUISetState() ; Register message handlers GUIRegisterMsg($WM_LBUTTONDOWN, "_WM_LBUTTONDOWN") ; For resize/drag GUIRegisterMsg($WM_MOUSEMOVE, "_SetCursor") ; For cursor type change ;GUIRegisterMsg($WM_GETMINMAXINFO, "_WM_GETMINMAXINFO") ; For GUI size limits $hCurr_HhWnd = 0 While 1 Sleep(10) WEnd ; Set cursor to correct resizing form if mouse is over a border Func _SetCursor() Local $iCursorID Local $iCursorID2 If _GethWndhWnd() = WinGetTitle($hGUI) Then Switch _GetBorder($hGUI) Case 0 $iCursorID = 2 Case 1, 2 $iCursorID = 13 Case 3, 6 $iCursorID = 11 Case 5, 7 $iCursorID = 10 Case 4, 8 $iCursorID = 12 EndSwitch GUISetCursor($iCursorID, 1) ElseIf _GethWndhWnd() = WinGetTitle($hGUI2) Then Switch _GetBorderOther($hGUI2) Case 0 $iCursorID2 = 2 Case 1, 2 $iCursorID2 = 13 Case 3, 6 $iCursorID2 = 11 Case 5, 7 $iCursorID2 = 10 Case 4, 8 $iCursorID2 = 12 EndSwitch GUISetCursor($iCursorID2, 1) EndIf EndFunc ;==>_SetCursor ; Check cursor type and resize/drag window as required Func _WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam) Switch WinGetTitle($hWnd) Case WinGetTitle($hGUI) DragResize($hGUI) Case WinGetTitle($hGUI2) DragResize($hGUI2) EndSwitch EndFunc ;==>_WM_LBUTTONDOWN Func DragResize($hWndSample) Local $iResizeType = "" Switch WinGetTitle($hWndSample) Case WinGetTitle($hGUI) Local $iCursorType = _GetBorder($hGUI) If $iCursorType > 0 Then ; Cursor is set to resizing style $iResizeType = 0xF000 + $iCursorType _SendMessage($hGUI, $WM_SYSCOMMAND, $iResizeType, 0) Else Local $aCurInfo = GUIGetCursorInfo($hGUI) If $aCurInfo[4] = 0 Then ; Mouse not over a control DllCall("user32.dll", "int", "ReleaseCapture") _SendMessage($hGUI, $WM_NCLBUTTONDOWN, $HTCAPTION, 0) EndIf EndIf Case WinGetTitle($hGUI2) Local $iCursorType = _GetBorderOther($hGUI2) If $iCursorType > 0 Then ; Cursor is set to resizing style $iResizeType = 0xF000 + $iCursorType _SendMessage($hGUI2, $WM_SYSCOMMAND, $iResizeType, 0) Else Local $aCurInfo = GUIGetCursorInfo($hGUI2) If $aCurInfo[4] = 0 Then ; Mouse not over a control DllCall("user32.dll", "int", "ReleaseCapture") _SendMessage($hGUI2, $WM_NCLBUTTONDOWN, $HTCAPTION, 0) EndIf EndIf EndSwitch EndFunc ;==>DragResize Func _GethWndhWnd() $aPos = MouseGetPos() If $aPos[0] <> $aLastPos[0] Or $aPos[1] <> $aLastPos[1] Then DllStructSetData($stPoint, 1, $aPos[0]) DllStructSetData($stPoint, 2, $aPos[1]) $hControl = _WinAPI_WindowFromPoint($stPoint) $hWin = _WinAPI_GetAncestor($hControl, 2) $sStr = WinGetTitle($hWin) If $sLastStr <> $sStr Then ;ToolTip($sStr) ;ConsoleWrite($sStr) Return $sStr $sLastStr = $sStr EndIf $aLastPos = $aPos EndIf Sleep(15) EndFunc ;==>_GethWndhWnd ; Determines if mouse cursor over a border Func _GetBorder($blank) Local $aCurInfo = GUIGetCursorInfo() If @error Then Return -1 Local $aWinPos = WinGetPos($hGUI) Local $iSide = 0 Local $iTopBot = 0 ;x Coords If $aCurInfo[0] < $iMargin Then $iSide = 1 If $aCurInfo[0] > $aWinPos[2] - $iMargin Then $iSide = 2 ;y Coords If $aCurInfo[1] < $iMargin Then $iTopBot = 3 If $aCurInfo[1] > $aWinPos[3] - $iMargin Then $iTopBot = 6 If $iSide + $iTopBot > 0 Then ConsoleWrite("Side " & $iSide & " + TopBot " & $iTopBot & @CRLF) Return $iSide + $iTopBot EndFunc ;==>_GetBorder ; Determines if mouse cursor over a border Func _GetBorderOther($blank) Local $aCurInfo = GUIGetCursorInfo() If @error Then Return -1 Local $aWinPos = WinGetPos($hGUI2) Local $iSide = 0 Local $iTopBot = 0 ;x Coords If $aCurInfo[0] < $iMargin Then $iSide = 1 If $aCurInfo[0] > $aWinPos[2] - $iMargin Then $iSide = 2 ;y Coords If $aCurInfo[1] < $iMargin Then $iTopBot = 3 If $aCurInfo[1] > $aWinPos[3] - $iMargin Then $iTopBot = 6 If $iSide + $iTopBot > 0 Then ConsoleWrite("b - " & $iSide & " + " & $iTopBot & @CRLF) Return $iSide + $iTopBot EndFunc ;==>_GetBorderOther ; Set min and max GUI sizes Func _WM_GETMINMAXINFO($hWnd, $iMsg, $wParam, $lParam) $tMinMaxInfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $lParam) DllStructSetData($tMinMaxInfo, 7, $iGUIMinX) DllStructSetData($tMinMaxInfo, 8, $iGUIMinY) DllStructSetData($tMinMaxInfo, 9, $iGUIMaxX) DllStructSetData($tMinMaxInfo, 10, $iGUIMaxY) Return 0 EndFunc ;==>_WM_GETMINMAXINFO Func On_Exit() Exit EndFunc ;==>On_Exit Edited December 12, 2015 by CodeTinkerer Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 12, 2015 Moderators Share Posted December 12, 2015 CodeTinkerer,In the code I posted I have shown you how to determine which GUI is under the cursor - so why are you using _WinAPI_GetAncestor, returning that GUI title and than using that in a Switch structure to determine which GUI is active? What are you not telling me about what you are trying to do?M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
CodeTinkerer Posted December 12, 2015 Author Share Posted December 12, 2015 Yes, I was just showing you what I was coming up with while I waited for a response. I did in fact take your example and assimilate it into my script. after close study and documentation of corse! I really appreciate it !I plan to post the final result with resources once all the fine tuning is finished Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 12, 2015 Moderators Share Posted December 12, 2015 CodeTinkerer,Thanks for the explanation - looking forward to your final script.M23 CodeTinkerer 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
CodeTinkerer Posted January 28, 2016 Author Share Posted January 28, 2016 (edited) I have attached the progress. to achieve full expand ability of the window I have altered the XSkin.au3 to my requirements such that vertical images are of a height at 1080px and horizontal images are a width of 1920px. the window also includes a listview with a background image of 1920x1080. Looks great! Functions well! But, there is a slight flickering problem when resizing the window and its much worse in an MDI environment with a background image on the parent window. This causes bright white flashes at a frequent interval when resizing the image. I am afraid that one of my users of the application I am working on might have epilepsy and I dont want to trigger that. Is there no way to rezise the window AFTER the drag is complete? sort of like Linux style window resizing? or even windows does it at some points but I could not re-create. skinnedWindow.zip Edited January 28, 2016 by CodeTinkerer Link to comment Share on other sites More sharing options...
CodeTinkerer Posted February 21, 2016 Author Share Posted February 21, 2016 Still attempting a solution for getting rid of this flicker issue. Would anyone know of an efficient way to have the window Re sized AFTER the drag operation on the window edges? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now