Jump to content

Click Tab / GUI resizes


sotl
 Share

Recommended Posts

Is there anyway to resize a gui window upon clicking a tab. So.. lets say the program opens by default on Tab1 and the GUI size is 300x300. Clicking Tab2 will resize the GUI to 350x600. Clicking Tab1 will resize the GUI to 300x300.

Possible?

Link to comment
Share on other sites

#include <GUIConstants.au3>

$Form1 = GUICreate("Tabbed Notebook Dialog", 413, 298, 303, 219)

$PageControl1 = GUICtrlCreateTab(8, 8, 280, 250)
$TabSheet1 = GUICtrlCreateTabItem("TabSheet1")
$TabSheet2 = GUICtrlCreateTabItem("TabSheet2")

GUISetState()

do
    $nMsg = GUIGetMsg()
    $pos = WinGetPos($Form1)
    $cpos = ControlGetPos($Form1,"",$PageControl1)
    if GUICtrlRead($PageControl1) = 0 then 
        WinMove($Form1,"",$pos[0],$pos[1],300,300)
        ControlMove($Form1,"",$PageControl1,$cpos[0],$cpos[1],280,250)
    elseif GUICtrlRead($PageControl1) = 1 then 
        WinMove($Form1,"",$pos[0],$pos[1],350,600)
        ControlMove($Form1,"",$PageControl1,$cpos[0],$cpos[1],330,550)
    EndIf
until $nMsg = $GUI_EVENT_CLOSE

[font="Impact"]Never fear, I is here.[/font]

Link to comment
Share on other sites

hmmm... thank you for posting that. It's giving me more ideas. I was using GUICtrlSetPos() to resize the tab area and WinMove() to resize the GUI. Nice avatar btw.

Edited by sotl
Link to comment
Share on other sites

Here is some code I'm using in my program if anyone is interested.. It makes the gui window resize in a smooth "rolling" fashion for a bit of visual flare. It does it in 20 pixel steps since 1 to 5, although smoother, is a little slow when resizing to a very large window even with Sleep(0). change the red parts to match your code. If you're not using tabs then delete the GUICtrlSetPos lines. Calling the function with a value of 0 for x or y will result in no change for that axis.

For some reason WinGetPos gets a different window size than what I specified in GUICreate. I had to use the traytip function below in a while loop to get the true size of the window. For example I specified a window size of 244 x 128, but WinGetPos picks up 250 x 160. So make sure the real GUI size is a multiple of 10 and when you call the function use steps of 20 or it may resize indefinitely. Comments/code tweaks are welcome :shocked:

$winsize = WinGetPos($s_GUI)

Traytip($winsize[2],$winsize[3],30)

Func RESIZE($X, $Y)

$xD = 0

$yD = 0

$winsize= WinGetPos($Your_window_variable_here)

If $X > $winsize[2] Then $xD = 20

If $X < $winsize[2] And $X >= 1 Then $xD = -20

If $Y > $winsize[3] Then $yD = 20

If $Y < $winsize[3] And $Y >= 1 Then $yD = -20

$xdone = False

$ydone = False

Do

If $xD = 0 Then $xdone = True

If $xdone = False Then

$winsize[2] += $xD

WinMove($s_GUI,"",default,default,$winsize[2],$winsize[3])

GUICtrlSetPos($Your_Tab_Variable_here,3,3,$winsize[2]-10,$winsize[3]-35)

If $winsize[2] = $X Then $xdone = True

EndIf

Until $xdone = True

Do

If $yD = 0 Then $ydone = True

If $ydone = False Then

$winsize[3] += $yD

WinMove($s_GUI,"",default,default,$winsize[2],$winsize[3])

GUICtrlSetPos($Your_Tab_Variable_here,3,3,$winsize[2]-10,$winsize[3]-35)

If $winsize[3] = $Y Then $ydone = True

EndIf

Until $ydone = True

EndFunc

Edited by sotl
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...