Jump to content



Photo

Prettier GUI Resizing UDF


  • Please log in to reply
9 replies to this topic

#1 insignia96

insignia96

    Adventurer

  • Active Members
  • PipPip
  • 101 posts

Posted 23 October 2009 - 11:35 PM

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.

AutoIt         
#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.
Posted ImageVisit my website to see all my finished releases!Releases here:UDFs:GUI ResizingColor List (Web Colors)GUIFade_NearestPower





#2 insignia96

insignia96

    Adventurer

  • Active Members
  • PipPip
  • 101 posts

Posted 24 October 2009 - 02:58 PM

58 views and no comments?
Posted ImageVisit my website to see all my finished releases!Releases here:UDFs:GUI ResizingColor List (Web Colors)GUIFade_NearestPower

#3 novi

novi

    Seeker

  • Active Members
  • 42 posts

Posted 24 October 2009 - 03:39 PM

Very useful! Thanks :)
[COLOR=green]

#4 FranckGr

FranckGr

    Seeker

  • Active Members
  • 31 posts

Posted 25 October 2009 - 10:04 AM

>> 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, 25 October 2009 - 10:05 AM.


#5 insignia96

insignia96

    Adventurer

  • Active Members
  • PipPip
  • 101 posts

Posted 25 October 2009 - 09:49 PM

>> 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
Posted ImageVisit my website to see all my finished releases!Releases here:UDFs:GUI ResizingColor List (Web Colors)GUIFade_NearestPower

#6 FranckGr

FranckGr

    Seeker

  • Active Members
  • 31 posts

Posted 27 October 2009 - 10:13 PM

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, 27 October 2009 - 10:14 PM.


#7 insignia96

insignia96

    Adventurer

  • Active Members
  • PipPip
  • 101 posts

Posted 27 October 2009 - 11:35 PM

really lol? 1 second...

Fixed the DL Link. It is good now, sry bout that. Typo.

Edited by insignia96, 27 October 2009 - 11:36 PM.

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

#8 Alek

Alek

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 330 posts

Posted 28 October 2009 - 08:30 PM

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

Example
a similar function I made a while back.

AutoIt         
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

Never fear, I is here.

#9 Dolemite50

Dolemite50

    Prodigy

  • Active Members
  • PipPipPip
  • 157 posts

Posted 30 October 2009 - 02:13 AM

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

#10 insignia96

insignia96

    Adventurer

  • Active Members
  • PipPip
  • 101 posts

Posted 24 August 2010 - 10:11 PM

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

Example
a similar function I made a while back.

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

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.
Posted ImageVisit my website to see all my finished releases!Releases here:UDFs:GUI ResizingColor List (Web Colors)GUIFade_NearestPower




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users