qwert Posted January 4, 2017 Share Posted January 4, 2017 (edited) I have a $WS_POPUP GUI that is normally fixed size. But, occasionally, it contains text that would be easier to view if the right side (only) of the GUI could be extended. As a test of GUI resizing, I've used $WS_SIZEBOX, but that adds an unwanted frame. Is there a simple way to define a "handle" along the right side that can be used to extend the GUI horizontally. (The vertical dimension should always remain fixed.) Thanks in advance for any suggestions. BTW, I have looked at the wiki and noted the full method for detecting mouse position and responding. What I'm seeking is effectively a button along the side that would control the right-side width, only. Quote Wiki: "To resize a GUI without borders, we have to fool Windows into thinking that the borders actually exist." Edited January 4, 2017 by qwert Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 4, 2017 Moderators Share Posted January 4, 2017 qwert, How about this? expandcollapse popup#include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <SendMessage.au3> HotKeySet("{ESC}", "On_Exit") ; Set distance from edge of window where resizing is possible Global Const $iMargin = 4 ; Create GUI $hGUI = GUICreate("Y", 100, 100, -1, -1, $WS_POPUP) GUISetBkColor(0xFF0000) GUISetState() ; Register message handlers GUIRegisterMsg($WM_LBUTTONDOWN, "_WM_LBUTTONDOWN") ; For resize GUIRegisterMsg($WM_MOUSEMOVE, "_SetCursor") ; For cursor type change While 1 Sleep(10) WEnd ; Check cursor type and resize/drag window as required Func _WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam) Local $iCursorType = _GetBorder() If $iCursorType > 0 Then ; Cursor is set to resizing style $iResizeType = 0xF000 + $iCursorType _SendMessage($hGUI, $WM_SYSCOMMAND, $iResizeType, 0) EndIf EndFunc ;==>_WM_LBUTTONDOWN ; Set cursor to correct resizing form if mouse is over a border Func _SetCursor() Local $iCursorID If _GetBorder() = 2 Then $iCursorID = 13 EndIf GUISetCursor($iCursorID, 1) EndFunc ;==>_SetCursor ; Determines if mouse cursor over a border Func _GetBorder() Local $aCurInfo = GUIGetCursorInfo() Local $aWinPos = WinGetPos($hGUI) Local $iSide = 0 If $aCurInfo[0] < $iMargin Then $iSide = 1 If $aCurInfo[0] > $aWinPos[2] - $iMargin Then $iSide = 2 Return $iSide EndFunc ;==>_GetBorder Func On_Exit() Exit EndFunc ;==>On_Exit Or you might like to look at my GUIExtender UDF, the link is on my sig. M23 Skysnake 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...
qwert Posted January 4, 2017 Author Share Posted January 4, 2017 (edited) Thanks for the solution. It's concise! Although I've used some of the elements in various scripts, I don't recall seeing them in such a compact example. It helps when they're demonstrated in such clear ways. But I do have one remaining issue: can you suggest how to limit the resize action to a minimum of 100 pixels? (the initial GUI size) Or, to put it another way: is there a setting that can be made for the GUI that's easier than the method that creates a structure? ( GUIRegisterMsg($WM_GETMINMAXINFO, "_WM_GETMINMAXINFO") ; For GUI size limits ) Edited January 5, 2017 by qwert Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 5, 2017 Moderators Share Posted January 5, 2017 (edited) qwert, In my opinion the WM_GETMINMAXINFO is by far the best - why do you consider it so complicated? It takes only 7 lines: expandcollapse popup#include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <SendMessage.au3> HotKeySet("{ESC}", "On_Exit") Global $iMinX = 100 ; Line 1 ; Set distance from edge of window where resizing is possible Global Const $iMargin = 4 ; Create GUI $hGUI = GUICreate("Y", $iMinX, 100, -1, -1, $WS_POPUP) GUISetBkColor(0xFF0000) GUISetState() ; Register message handlers GUIRegisterMsg($WM_LBUTTONDOWN, "_WM_LBUTTONDOWN") ; For resize GUIRegisterMsg($WM_MOUSEMOVE, "_SetCursor") ; For cursor type change GUIRegisterMsg($WM_GETMINMAXINFO, "_WM_GETMINMAXINFO") ; Line 2 While 1 Sleep(10) WEnd ; Check cursor type and resize/drag window as required Func _WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam) Local $iCursorType = _GetBorder() If $iCursorType > 0 Then ; Cursor is set to resizing style $iResizeType = 0xF000 + $iCursorType _SendMessage($hGUI, $WM_SYSCOMMAND, $iResizeType, 0) EndIf EndFunc ;==>_WM_LBUTTONDOWN ; Set cursor to correct resizing form if mouse is over a border Func _SetCursor() Local $iCursorID If _GetBorder() = 2 Then $iCursorID = 13 EndIf GUISetCursor($iCursorID, 1) EndFunc ;==>_SetCursor ; Determines if mouse cursor over a border Func _GetBorder() Local $aCurInfo = GUIGetCursorInfo() Local $aWinPos = WinGetPos($hGUI) Local $iSide = 0 If $aCurInfo[0] < $iMargin Then $iSide = 1 If $aCurInfo[0] > $aWinPos[2] - $iMargin Then $iSide = 2 Return $iSide EndFunc ;==>_GetBorder Func _WM_GETMINMAXINFO($hwnd, $iMsg, $wParam, $lParam) ; Line 3 $tagMaxinfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $lParam) ; Line 4 DllStructSetData($tagMaxinfo, 7, $iMinX) ; min X ; Line 5 Return 0 ; Line 6 EndFunc ;==>WM_GETMINMAXINFO ; Line 7 Func On_Exit() Exit EndFunc ;==>On_Exit M23 Edited January 5, 2017 by Melba23 Added line counters 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...
qwert Posted January 5, 2017 Author Share Posted January 5, 2017 True, it's not that complicated. But I seem to recall that a normal window (that's sizable) has some minimum size. So I thought there might be a way to let the operating system handle it. I'm always seeking 'simple'. Thanks very much for your help. 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