Jump to content

Recommended Posts

Posted (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

#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 by MattyD
  • Moderators
Posted

MattyD,

I think you are over-complicating it a bit. :idea: 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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted

It looks as if some twat didn't look closely enough at the documentation :idea: . 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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...