Jump to content

How to send resizing notifycation to my GUI?


 Share

Recommended Posts

Hi all,

I have a problem with my resizable gui...

All (almoust) controls have GUICtrlSetResizing(-1, $GUI_DOCKSIZE), so the controls will move with gui resizing.

But i want to write current size of my gui to ini file, and then read it and set the "old size" for next time GUI is launched...

The problem is, that if the last time size of gui was big, then when user trying to resize window (that it will be smaller), all controls are moved very close to each other (or hover them selfs).

Mu question is - How to send some notifycation to my GUI (maybe _SendMessage() - but what message?), that it will "know" that the window was resized (just as user resize the window manualy), and then it fit all controls automatically.

Here is example of what i mean (please look at the comments):

#include <GuiConstants.au3>

Global $Width = 500
Global $Height = 360

$Gui = GuiCreate("Test", $Width, $Height, -1, -1, $WS_SIZEBOX+$WS_MINIMIZEBOX+$WS_MAXIMIZEBOX+$WS_BORDER)
GUIRegisterMsg(0x24, "MY_WM_GETMINMAXINFO")

$LV = GUICtrlCreateListView("Column", 20, 40, $Width-40, $Height-120)

$ButtonOK = GUICtrlCreateButton("OK", 20, $Height-60, 70, 20)
GUICtrlSetResizing(-1, $GUI_DOCKSIZE)

$ButtonExit = GUICtrlCreateButton("Exit", 120, $Height-60, 70, 20)
GUICtrlSetResizing(-1, $GUI_DOCKSIZE)

;Set new window size, it will be readen from Ini-File
$NewWidth = 700
$NewHeight = 400

$WinPosArr = WinGetPos($Gui) ;Just for get the X and Y positions
WinMove($Gui, "", $WinPosArr[0], $WinPosArr[1], $NewWidth, $NewHeight)

; Here i need the notifycation, that all controls will be resized with the window.


GUISetState()

While 1
    $Msg = GUIGetMsg()
    Switch $Msg
        Case -3, $ButtonExit
            Exit
        Case Else
            
    EndSwitch
WEnd

Func MY_WM_GETMINMAXINFO($hWnd, $Msg, $wParam, $lParam)
    Local $MINMAXINFO = DllStructCreate("int;int;int;int;int;int;int;int;int;int",$lParam)
    Local $MINGuiX = 508, $MINGuiY = 368
    DllStructSetData($MINMAXINFO, 7, $MINGuiX)
    DllStructSetData($MINMAXINFO, 8, $MINGuiY)
    Return 0
EndFunc

 

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

#include <GUIConstants.au3>

Opt("MustDeclareVars", 1)

Global $main_GUI

_Main()

Func _Main()

    $main_GUI = GUICreate("Blash", 716, 561, 155, 134, BitOR($WS_MAXIMIZEBOX, $WS_SIZEBOX, $WS_THICKFRAME, $WS_OVERLAPPEDWINDOW, $WS_TILEDWINDOW, $WS_TABSTOP))
    GUISetState()
    
    GUIRegisterMsg($WM_SIZE, "_WinResized")
    
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>_Main

Func _LoWord($x)
    Return BitAND($x, 0xFFFF)
EndFunc   ;==>_LoWord

Func _HiWord($x)
    Return BitShift($x, 16)
EndFunc   ;==>_HiWord

Func _DebugPrint($s_text)
    $s_text = StringReplace($s_text, @LF, @LF & "-->")
    ConsoleWrite( _
            "!===========================================================" & @LF & _
            "+===========================================================" & @LF & _
            "-->" & $s_text & @LF & _
            "+===========================================================" & @LF)
EndFunc   ;==>_DebugPrint


;==========================================================================================
;Stores the position and size of the Snippet window for use on next startup
;Stores the X,Y coords and the Width, Height in the ~xx123Data section of the Snippets.ini
;==========================================================================================
Func _WinResized($hWndGUI, $MsgID, $wParam, $lParam)
    Local Const $SIZE_MINIMIZED = 1;The window has been minimized.
    Local Const $SIZE_MAXSHOW = 3;Message is sent to all pop-up windows when some other window has been restored to its former size.
    #forceref $hWndGUI, $MsgID, $lParam
    Local $h = _HiWord($lParam)
    Local $w = _LoWord($lParam)
    If $wParam <> $SIZE_MINIMIZED And $wParam <> $SIZE_MAXSHOW And $hWndGUI = $main_GUI Then
        _DebugPrint($w & " x " & $h)
    EndIf
    Return $GUI_RUNDEFMSG
EndFunc   ;==>_WinResized

Edited by Lobishomen

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

Thanks for the example, but i need not to check when the window is resized, i need to send this message so the window reciev (respond to) the resizing notifycation.

 

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

Sorry , I'm probly missing what your try to accomplish..

I think the problem is your setting the new size before GUISetState()

Maybe you could set the new size after GUISetState..

#include <GuiConstants.au3>

Global $Width = 500
Global $Height = 360

$Gui = GuiCreate("Test", $Width, $Height, -1, -1, $WS_SIZEBOX+$WS_MINIMIZEBOX+$WS_MAXIMIZEBOX+$WS_BORDER)
GUIRegisterMsg(0x24, "MY_WM_GETMINMAXINFO")

$LV = GUICtrlCreateListView("Column", 20, 40, $Width-40, $Height-120)

$ButtonOK = GUICtrlCreateButton("OK", 20, $Height-60, 70, 20)
GUICtrlSetResizing(-1, $GUI_DOCKSIZE)

$ButtonExit = GUICtrlCreateButton("Exit", 120, $Height-60, 70, 20)
GUICtrlSetResizing(-1, $GUI_DOCKSIZE)
GUISetState(@SW_HIDE, $Gui)

;Set new window size, it will be readen from Ini-File
$NewWidth = 700
$NewHeight = 400

$WinPosArr = WinGetPos($Gui) ;Just for get the X and Y positions
WinMove($Gui, "", $WinPosArr[0], $WinPosArr[1], $NewWidth, $NewHeight)
; Here i need the notifycation, that all controls will be resized with the window.
GUISetState(@SW_SHOW, $Gui)

While 1
    $Msg = GUIGetMsg()
    Switch $Msg
        Case -3, $ButtonExit
            Exit
        Case Else
           
    EndSwitch
WEnd

Func MY_WM_GETMINMAXINFO($hWnd, $Msg, $wParam, $lParam)
    Local $MINMAXINFO = DllStructCreate("int;int;int;int;int;int;int;int;int;int",$lParam)
    Local $MINGuiX = 508, $MINGuiY = 368
    DllStructSetData($MINMAXINFO, 7, $MINGuiX)
    DllStructSetData($MINMAXINFO, 8, $MINGuiY)
    Return 0
EndFunc

Once again sorry if I'm reading your post wrongly

Cheers

Link to comment
Share on other sites

smashly

Thanks, it works perfectly!

As we say on russian...

"All Ingeniously, is simple!"

Something like this :">

It's means that all briliant stuff must be (in most cases) simple :)

Thanks again.

 

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...