Jump to content

Recommended Posts

Posted

This is a little tool i wrote as part of a larger project, but I liked how it turned out so i compiled it into a UDF. Basically all it does is it resizes your GUI with a bit more style then just having it explode open.

Functions

_Expand( $hWnd, $w_increase, $h_increase, $speed ) ; For this hWnd is the handle to the window to resize, w & h increases are the amounts to add to width and height, and speed should be a number between 1 and 10, 10 being the fastest and 1 being the slowest.

_UnExpand( $hWnd, $w_decrease, $h_decrease, $speed ) ; All parameters are the same here except w & h decreases will be taken away from the GUI, not added.

It can be downloaded in ZIP format here: http://iwowprogramming.com/files/public/Resizing%20UDF.zip

The zip includes an example script. Also here is the UDF Source Code.

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.0.0
 Author:         insignia96

 Script Function:
    Used for resizing of windows.

#ce ----------------------------------------------------------------------------





Func _Expand( $hWnd, $w_increase, $h_increase, $speed )

    Local $increase[4]

    $current = WinGetPos( $hWnd )

    $increase[0] = $w_increase
    $increase[1] = $w_increase
    $increase[2] = $increase[0] + $current[2]
    $increase[3] = $increase[1] + $current[3]

    $speed = $speed / 10

    For $i = $current[2] To $increase[2] Step $speed
        WinMove( $hWnd, "", $current[0], $current[1], $i, $current[3] )
    Next

    $current = WinGetPos( $hWnd )

    For $i = $current[3] To $increase[3] Step $speed
        WinMove( $hWnd, "", $current[0], $current[1], $current[2], $i )
    Next


EndFunc

Func _UnExpand( $hWnd, $w_decrease, $h_decrease, $speed )

    Local $decrease[4]

    $current = WinGetPos( $hWnd )

    $decrease[0] = $w_decrease
    $decrease[1] = $h_decrease
    $decrease[2] = $current[2] - $decrease[0]
    $decrease[3] = $current[3] - $decrease[1]

    $speed = $speed / 10
    $speed = $speed * -1

    For $i = $current[2] To $decrease[2] Step $speed
        WinMove( $hWnd, "", $current[0], $current[1], $i, $current[3] )
    Next

    $current = WinGetPos( $hWnd )

    For $i = $current[3] To $decrease[3] Step $speed
        WinMove( $hWnd, "", $current[0], $current[1], $current[2], $i )
    Next

EndFunc

The thing i used this for was making a GUI that expands downward, revealing advanced options, then is able to contract up.

Visit my website to see all my finished releases!Releases here:UDFs:GUI ResizingColor List (Web Colors)GUIFade_NearestPower

Posted (edited)

>> The thing i used this for was making a GUI that expands downward, revealing advanced options, then is able to contract up.

Exactly, by adding Opt("GUIResizeMode",802)

usefull script. Thanks to share

Edited by FranckGr
Posted

  On 10/25/2009 at 10:04 AM, 'FranckGr said:

>> The thing i used this for was making a GUI that expands downward, revealing advanced options, then is able to contract up.

Exactly, by adding Opt("GUIResizeMode",802)

usefull script. Thanks to share

OMFG LOL!!!!

I put a GUICtrlSetResizing( -1, 802 ) After every single control lol. I didnt know you could do that ;D

Visit my website to see all my finished releases!Releases here:UDFs:GUI ResizingColor List (Web Colors)GUIFade_NearestPower

Posted (edited)

  On 10/25/2009 at 9:49 PM, 'insignia96 said:

OMFG LOL!!!!

I put a GUICtrlSetResizing( -1, 802 ) After every single control lol. I didnt know you could do that ;D

$increase[1] = $w_increase should be $increase[1] = $h_increase in _expand function

Edited by FranckGr
Posted

Might want to try with timer, it would make the resizing much more constant.

Example

a similar function I made a while back.

Func WindowGlide($hwnd, $text, $x, $y, $width, $height, $time = 200)
    Local $OrgPos = WinGetPos($hwnd, $text)

    If @error Then
        Return SetError(1, 0, 0)
    EndIf

    Local $NewPos[4]
    Local $timer = TimerInit()
    Local $percent_done = 0

    While TimerDiff($timer) < $time
        Sleep(10)
        $percent_done = TimerDiff($timer) / $time
        $NewPos[0] = $OrgPos[0] + ($x - $OrgPos[0]) * $percent_done
        $NewPos[1] = $OrgPos[1] + ($y - $OrgPos[1]) * $percent_done
        $NewPos[2] = $OrgPos[2] + ($width - $OrgPos[2]) * $percent_done
        $NewPos[3] = $OrgPos[3] + ($height - $OrgPos[3]) * $percent_done
        WinMove($hwnd, $text, $NewPos[0], $NewPos[1], $NewPos[2], $NewPos[3])
    WEnd

    WinMove($hwnd, $text, $x, $y, $width, $height)

    Return 1
EndFunc

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

  • 9 months later...
Posted

  On 10/28/2009 at 8:30 PM, 'Alek said:

Might want to try with timer, it would make the resizing much more constant.

Example

a similar function I made a while back.

Func WindowGlide($hwnd, $text, $x, $y, $width, $height, $time = 200)
    Local $OrgPos = WinGetPos($hwnd, $text)

    If @error Then
        Return SetError(1, 0, 0)
    EndIf

    Local $NewPos[4]
    Local $timer = TimerInit()
    Local $percent_done = 0

    While TimerDiff($timer) < $time
        Sleep(10)
        $percent_done = TimerDiff($timer) / $time
        $NewPos[0] = $OrgPos[0] + ($x - $OrgPos[0]) * $percent_done
        $NewPos[1] = $OrgPos[1] + ($y - $OrgPos[1]) * $percent_done
        $NewPos[2] = $OrgPos[2] + ($width - $OrgPos[2]) * $percent_done
        $NewPos[3] = $OrgPos[3] + ($height - $OrgPos[3]) * $percent_done
        WinMove($hwnd, $text, $NewPos[0], $NewPos[1], $NewPos[2], $NewPos[3])
    WEnd

    WinMove($hwnd, $text, $x, $y, $width, $height)

    Return 1
EndFunc

Nice! This looks smoother than mine.

  On 10/30/2009 at 2:13 AM, 'Dolemite50 said:

Is it just me or do the controls flicker quite a bit?

This is a problem I never solved. After a while it seemed stupid to spend any more time on.

Visit my website to see all my finished releases!Releases here:UDFs:GUI ResizingColor List (Web Colors)GUIFade_NearestPower

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