MattyD Posted May 17, 2010 Posted May 17, 2010 (edited) Hi brains trust, Basically what i'm trying to do is add parameters to the resize messages before windows gets its paws on them. I have the actual limits bit working but it seems to break everything else in the process! Just wondering if I could pretty please get a nudge in the right direction. (I can live with calling a function when GuiGetMsg() returns $GUI_EVENT_RESIZED but wheres the fun in that...) Cheers Matt expandcollapse popup#include <WinAPI.au3> #include <WindowsConstants.au3> Opt("MustDeclareVars", 1) Global Const $GWL_WNDPROC = -4 Global Const $tagMINMAXINFO = "int Reservedx; int Reservedy; int MaxSizex; int MaxSizey; int MaxPositionx; int MaxPositiony; int MinTrackSizex; int MinTrackSizey; int MaxTrackSizex; int MaxTrackSizey" Global $pPrevWndProc Global $hCallback = DllCallbackRegister("_WinProc", "int", "hwnd;uint;word;long") Global $hWnd = GUICreate("test", -1, -1, -1, -1, $WS_SIZEBOX) _Hook() GUISetState() Local $Msg While 1 $Msg = GUIGetMsg() Switch $Msg Case -3 ConsoleWrite("Exiting!" & @CRLF) Exit EndSwitch WEnd Func _Hook() $pPrevWndProc = _WinAPI_SetWindowLong($hWnd, $GWL_WNDPROC, DllCallbackGetPtr($hCallback)) OnAutoItExitRegister("_Unhook") EndFunc Func _Unhook() Local $temp $temp = _WinAPI_SetWindowLong($hWnd, $GWL_WNDPROC, $pPrevWndProc) EndFunc Func _WinProc($hWnd, $iMsg, $iwParam, $ilParam) Sleep(10) If $iMsg = $WM_GETMINMAXINFO Then Local $tMINMAXINFO = DllStructCreate($tagMINMAXINFO, $ilParam) DllStructSetData($tMINMAXINFO, "MinTrackSizex", 200) DllStructSetData($tMINMAXINFO, "MinTrackSizey", 200) DllStructSetData($tMINMAXINFO, "MaxTrackSizex", 500) DllStructSetData($tMINMAXINFO, "MaxTrackSizey", 500) Return _WinAPI_DefWindowProc($hWnd, $iMsg, $iwParam, $ilParam) Else Return _WinAPI_DefWindowProc($hWnd, $iMsg, $iwParam, $ilParam) EndIf EndFunc Edited May 17, 2010 by MattyD
Moderators Melba23 Posted May 20, 2010 Moderators Posted May 20, 2010 MattyD, I think you are over-complicating it a bit. Here is how I limit the resizing: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $GUIMINWID = 300, $GUIMINHT = 100;set your restrictions here Global $GUIMAXWID = 800, $GUIMAXHT = 500 GUIRegisterMsg($WM_GETMINMAXINFO, "WM_GETMINMAXINFO") $hGUI = GUICreate("Test", 500, 500, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX)) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func WM_GETMINMAXINFO($hwnd, $Msg, $wParam, $lParam) $tagMaxinfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $lParam) DllStructSetData($tagMaxinfo, 7, $GUIMINWID) ; min X DllStructSetData($tagMaxinfo, 8, $GUIMINHT) ; min Y DllStructSetData($tagMaxinfo, 9, $GUIMAXWID ); max X DllStructSetData($tagMaxinfo, 10, $GUIMAXHT ) ; max Y Return 0 EndFunc ;==>WM_GETMINMAXINFO I hope that helps - even it is perhaps less fun! 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
MattyD Posted May 23, 2010 Author Posted May 23, 2010 It looks as if some twat didn't look closely enough at the documentation . Thanks Melba, this function opens quite a few doors. The exercise though was really just an excuse to play a bit more with callbacks. Not having overly much luck with them so far... ahh well... thanks again, Matt
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