Achilles Posted August 10, 2008 Share Posted August 10, 2008 I made a GUI that I only want the user to resize from the top and from the bottom. I figured out how to lock the position but can't figure out how to get rid of the mouse cursor that says you can resize. This is how I'm locking it: Func WM_GETMINMAXINFO($hWnd, $MsgID, $wParam, $lParam) #forceref $MsgID, $wParam If $hWnd = $mainGUI Then; the main GUI-limited Local $size = WinGetPos($mainGUI); Local $minmaxinfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $lParam) DllStructSetData($minmaxinfo, 9, 773); max X DllStructSetData($minmaxinfo, 7, 773); min width DllStructSetData($minmaxinfo, 8, 500); min height Return 0 Else Return 0 EndIf My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] Link to comment Share on other sites More sharing options...
smashly Posted August 11, 2008 Share Posted August 11, 2008 (edited) I've not tried, but could you use the MouseGetCursor() with a condition and _WinAPI_SetCursor() to overide the default cursor on resize? Edited August 11, 2008 by smashly Link to comment Share on other sites More sharing options...
Achilles Posted August 11, 2008 Author Share Posted August 11, 2008 (edited) I've not tried, but could you use the MouseGetCursor() with a condition and _WinAPI_SetCursor() to overide the default cursor on resize?Where would that be thought? I don't really want a loop checking every 50ms to see if the window is being resized... Another GUIRegister thing? I'll check on that now.WM_SETCURSOR might look like what I want. I don't know how to register the msg code and that though.. Edited August 11, 2008 by Achilles My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] Link to comment Share on other sites More sharing options...
martin Posted August 11, 2008 Share Posted August 11, 2008 (edited) Where would that be thought? I don't really want a loop checking every 50ms to see if the window is being resized... Another GUIRegister thing? I'll check on that now. WM_SETCURSOR might look like what I want. I don't know how to register the msg code and that though.. Example #include #include Const $GWL_WNDPROC = -4 $g1 = GUICreate("Form1", 633, 441, 193, 133, BitOR($WS_MINIMIZEBOX,$WS_SIZEBOX,$WS_THICKFRAME,$WS_SYSMENU,$WS_CAPTION,$WS_POPUP,$WS_POPUPWINDOW,$WS_GROUP,$WS_BORDER,$WS_CLIPSIBLINGS)) GUISetState(@SW_SHOW) Global $wProcNew $wProcNew = DllCallbackRegister("_MyWindowProc", "ptr", "hwnd;uint;long;ptr") Global $wProcOld $wProcOld = _WinAPI_SetWindowLong($g1, $GWL_WNDPROC, DllCallbackGetPtr($wProcNew)) guisetcursor(2) while 1 if GUIGetMsg() = -3 then exit WEnd Func _MyWindowProc($hWnd, $uiMsg, $wParam, $lParam) If $uiMsg = $WM_SETCURSOR Then $wp = WinGetPos($g1) $mp = MouseGetPos() if $mp[0] $wp[0] + $wp[2] - 20 Then GUISetCursor(2) Return 1 EndIf EndIf ;pass the unhandled messages to default WindowProc Return _CallWindowProc($wProcOld, $hWnd, $uiMsg, $wParam, $lParam) EndFunc;==>_MyWindowProc Func _CallWindowProc($lpPrevWndFunc, $hWnd, $Msg, $wParam, $lParam) Local $aRet = DllCall('user32.dll', 'int', 'CallWindowProc', 'int_ptr', $lpPrevWndFunc, 'hwnd', $hWnd, 'uint', $Msg, 'wparam', $wParam, 'lparam', $lParam) Return $aRet[0] You will still need to lock the width as you were doing because the sides can still be dragged even though the cursor doesn't change. EDIT: See better answer from rasim below Edited August 11, 2008 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Achilles Posted August 11, 2008 Author Share Posted August 11, 2008 Example #include <windowsconstants.au3> #include <winapi.au3> Const $GWL_WNDPROC = -4 $g1 = GUICreate("Form1", 633, 441, 193, 133, BitOR($WS_MINIMIZEBOX,$WS_SIZEBOX,$WS_THICKFRAME,$WS_SYSMENU,$WS_CAPTION,$WS_POPUP,$WS_POPUPWINDOW,$WS_GROUP,$WS_BORDER,$WS_CLIPSIBLINGS)) GUISetState(@SW_SHOW) Global $wProcNew $wProcNew = DllCallbackRegister("_MyWindowProc", "ptr", "hwnd;uint;long;ptr") Global $wProcOld $wProcOld = _WinAPI_SetWindowLong($g1, $GWL_WNDPROC, DllCallbackGetPtr($wProcNew)) guisetcursor(2) while 1 if GUIGetMsg() = -3 then exit WEnd Func _MyWindowProc($hWnd, $uiMsg, $wParam, $lParam) If $uiMsg = $WM_SETCURSOR Then $wp = WinGetPos($g1) $mp = MouseGetPos() if $mp[0] < $wp[0] + 20 or $mp[0] > $wp[0] + $wp[2] - 20 Then GUISetCursor(2) Return 1 EndIf EndIf ;pass the unhandled messages to default WindowProc Return _CallWindowProc($wProcOld, $hWnd, $uiMsg, $wParam, $lParam) EndFunc;==>_MyWindowProc Func _CallWindowProc($lpPrevWndFunc, $hWnd, $Msg, $wParam, $lParam) Local $aRet = DllCall('user32.dll', 'int', 'CallWindowProc', 'int_ptr', $lpPrevWndFunc, 'hwnd', $hWnd, 'uint', $Msg, 'wparam', $wParam, 'lparam', $lParam) Return $aRet[0] You will still need to lock the width as you were doing because the sides can still be dragged even though the cursor doesn't change.That works great. Thanks martin My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] Link to comment Share on other sites More sharing options...
martin Posted August 11, 2008 Share Posted August 11, 2008 That works great. Thanks martinThat's ok. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
rasim Posted August 11, 2008 Share Posted August 11, 2008 ExampleSorry, but i not understand, why need to subclassing main window #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> Const $GWL_WNDPROC = -4 $Style = BitOR($WS_MINIMIZEBOX, $WS_SIZEBOX, $WS_THICKFRAME, $WS_SYSMENU, $WS_CAPTION, $WS_POPUP, $WS_POPUPWINDOW, _ $WS_GROUP, $WS_BORDER, $WS_CLIPSIBLINGS) $g1 = GUICreate("Form1", 633, 441, 193, 133, $Style) GUIRegisterMsg($WM_SETCURSOR, "WM_SETCURSOR") GUISetState(@SW_SHOW) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Func WM_SETCURSOR($hWnd, $uiMsg, $wParam, $lParam) Local $iHit = BitAND($lParam, 0xFFFF) ;Low-order If ($iHit = 10) Or ($iHit = 11) Or ($iHit = 13) Or ($iHit = 14) Or ($iHit = 16) Or ($iHit = 17) Then Return 1 Return $GUI_RUNDEFMSG EndFunc ;==>WM_SETCURSOR Link to comment Share on other sites More sharing options...
martin Posted August 11, 2008 Share Posted August 11, 2008 Sorry, but i not understand, why need to subclassing main window #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> Const $GWL_WNDPROC = -4 $Style = BitOR($WS_MINIMIZEBOX, $WS_SIZEBOX, $WS_THICKFRAME, $WS_SYSMENU, $WS_CAPTION, $WS_POPUP, $WS_POPUPWINDOW, _ $WS_GROUP, $WS_BORDER, $WS_CLIPSIBLINGS) $g1 = GUICreate("Form1", 633, 441, 193, 133, $Style) GUIRegisterMsg($WM_SETCURSOR, "WM_SETCURSOR") GUISetState(@SW_SHOW) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Func WM_SETCURSOR($hWnd, $uiMsg, $wParam, $lParam) Local $iHit = BitAND($lParam, 0xFFFF) ;Low-order If ($iHit = 10) Or ($iHit = 11) Or ($iHit = 13) Or ($iHit = 14) Or ($iHit = 16) Or ($iHit = 17) Then Return 1 Return $GUI_RUNDEFMSG EndFunc ;==>WM_SETCURSOR Thanks rasim, that was silly of me. I used an example I had for an edit and changed it to suit the gui without thinking. Even so I didn't know about the hit-test which is obviously a much better way to decide what to do. (I must stay in and read more.) Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
rasim Posted August 11, 2008 Share Posted August 11, 2008 Thanks rasim, that was silly of me. I used an example I had for an edit and changed it to suit the gui without thinking.Even so I didn't know about the hit-test which is obviously a much better way to decide what to do. (I must stay in and read more.)OK! Anyway you - guru, i`m - noob. Link to comment Share on other sites More sharing options...
Achilles Posted August 11, 2008 Author Share Posted August 11, 2008 Sorry, but i not understand, why need to subclassing main window #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> Const $GWL_WNDPROC = -4 $Style = BitOR($WS_MINIMIZEBOX, $WS_SIZEBOX, $WS_THICKFRAME, $WS_SYSMENU, $WS_CAPTION, $WS_POPUP, $WS_POPUPWINDOW, _ $WS_GROUP, $WS_BORDER, $WS_CLIPSIBLINGS) $g1 = GUICreate("Form1", 633, 441, 193, 133, $Style) GUIRegisterMsg($WM_SETCURSOR, "WM_SETCURSOR") GUISetState(@SW_SHOW) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Func WM_SETCURSOR($hWnd, $uiMsg, $wParam, $lParam) Local $iHit = BitAND($lParam, 0xFFFF) ;Low-order If ($iHit = 10) Or ($iHit = 11) Or ($iHit = 13) Or ($iHit = 14) Or ($iHit = 16) Or ($iHit = 17) Then Return 1 Return $GUI_RUNDEFMSG EndFunc ;==>WM_SETCURSORThanks for that.. It saves the need of having two global variables and is easier to use... My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] 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