Jump to content

Set minimum of resizing?


PantZ4
 Share

Recommended Posts

Hi,

A while ago, a has write a function that do that, here it is:

#include <GuiConstants.au3>

$Title = "Resize Limit GUI Demo"
GUICreate($Title, 300, 250, -1, -1, $WS_SIZEBOX)

GUISetState()

While 1
    $Msg = GUIGetMsg()
    Switch $Msg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $GUI_EVENT_RESIZED
            _ResizeLimit($Title, "", 200, 200, 600, 500)
    EndSwitch
WEnd

Func _ResizeLimit($Title, $Text="", $MinWidth=150, $MinHeight=100, $MaxWidth=@DesktopWidth, $MaxHeight=@DesktopHeight)
    If Not WinExists($Title, $Text) Then Return SetError(1, 0, -1)
    Local $PosArr = WinGetPos($Title, $Text), $xPos, $yPos, $wPos, $hPos
    If IsArray($PosArr) Then
        $xPos = $PosArr[0]
        $yPos = $PosArr[1]
        $wPos = $PosArr[2]
        $hPos = $PosArr[3]
        If ($wPos <> $MinWidth And $hPos <> $MinHeight) Or ($wPos <> $MaxWidth And $hPos <> $MaxHeight) Then
            If $wPos < $MinWidth And $hPos < $MinHeight Then WinMove($Title, $Text, $xPos, $yPos, $MinWidth, $MinHeight)
            If $wPos < $MinWidth And $hPos >= $MinHeight Then WinMove($Title, $Text, $xPos, $yPos, $MinWidth, $hPos)    
            If $wPos >= $MinWidth And $hPos < $MinHeight Then WinMove($Title, $Text, $xPos, $yPos, $wPos, $MinHeight)
            
            If $wPos > $MaxWidth And $hPos > $MaxHeight Then WinMove($Title, $Text, $xPos, $yPos, $MaxWidth, $MaxHeight)
            If $wPos > $MaxWidth And $hPos <= $MaxHeight Then WinMove($Title, $Text, $xPos, $yPos, $MaxWidth, $hPos)    
            If $wPos <= $MaxWidth And $hPos > $MaxHeight Then WinMove($Title, $Text, $xPos, $yPos, $wPos, $MaxHeight)
        EndIf
    EndIf
EndFunc

This not will stop the mouse, but at the end the window not will be resized bellow the seted position (minimum and maximum).

Edited by MsCreatoR

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

I was looking for something like the OP as well, so far I've been using functions like yours MsCreator. If anybody else could weigh in here to let me know if there's maybe a DllCall or something.

Edit:

I found a reference to a WM_GETMINMAXINFO message and found this on MSDN. Perhaps something with GUIRegisterMsg could solve this.

Edited by Saunders
Link to comment
Share on other sites

Here is example for WM_GETMINMAXINFO:

#include <GUIConstants.au3>
Const $WM_GETMINMAXINFO = 0x24

GUICreate("Test GUI",500,500,-1,-1,BitOR($GUI_SS_DEFAULT_GUI,$WS_SIZEBOX))
GUISetState (@SW_SHOW)
GUIRegisterMsg($WM_GETMINMAXINFO, "MY_WM_GETMINMAXINFO")

While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend
    
Func MY_WM_GETMINMAXINFO($hWnd, $Msg, $wParam, $lParam)
    $minmaxinfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int",$lParam)
    DllStructSetData($minmaxinfo,7,400) ; min X
    DllStructSetData($minmaxinfo,8,250) ; min Y
    DllStructSetData($minmaxinfo,9,600) ; max X
    DllStructSetData($minmaxinfo,10,700) ; max Y
    Return 0
EndFunc

#cs
typedef struct {
    POINT ptReserved;
    POINT ptMaxSize;
    POINT ptMaxPosition;
    POINT ptMinTrackSize;
    POINT ptMaxTrackSize;
} MINMAXINFO;
#ce

EDIT: search forum for more examples, I posted this long time ago already

Edited by Zedna
Link to comment
Share on other sites

Zedna

Here is example for WM_GETMINMAXINFO

Wow man! it's great, i have been looking for this whole my life! thank you very mutch! :shocked:

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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