AutoHotkey Community

It is currently May 27th, 2012, 11:27 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: August 15th, 2009, 10:46 pm 
Offline

Joined: November 24th, 2005, 8:16 am
Posts: 851
Hi everybody,

When drawing a GUI control with no specific width and height, it takes only the amount of space it needs automatically.

Then, when changing its value, the original width and height stay the same (as expected of course).

I was wondering, if there is a way to tell AHK to redraw this control, and recalculate the space this control needs.

Here is a code to demonstrate:
Code:
#SingleInstance Force
Gui Font, s16
Gui Add, Text,vT1 border -wrap, hello world i am here
Gui Show, w400

Sleep 2000
GuiControl,,T1,1234
;GuiControl Move, T1, x20

Return
ESC::ExitApp


After changing the value to "1234" I would like to make this control take less space.
I was hoping I can do this with GuiControl Move or MoveDraw, but was unsuccessful.

Possible?

_________________
Sector-Seven - Freeware tools built with AutoHotkey


Report this post
Top
 Profile  
Reply with quote  
PostPosted: August 15th, 2009, 11:30 pm 
Offline

Joined: August 21st, 2006, 7:07 pm
Posts: 2925
Location: The Shell
afaict you have to use WinMove to resize GUI windows. That would mean you'd have to give yours a name I think.

Code:
....
Gui Show, w400, MyWindow
Sleep 2000
GuiControl,,T1,1234

WinMove, MyWindow,,, , *Number*, *Number


You can get an example from My NetStat here:

http://www.autohotkey.com/forum/viewtop ... highlight=

Specifically:
Code:
....
   WinMove, fgDisplay,,,, %stWidth1%, %stHeight%
   WinMove, bgDisplay,,,, %stWidth1%, %stHeight%


I think there may be even a better way than my script if you figure out the amount of rows and update the control or window with an R[n] instead of W[n]. Still not 100% sure though. In my case I tried some janky char to gui size math :oops: but it works :lol:..


hth

_________________
Imageparadigm.shift:=(•_•)┌П┐RTFM||^.*∞


Report this post
Top
 Profile  
Reply with quote  
PostPosted: August 16th, 2009, 8:54 pm 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
Icarus wrote:
I was hoping I can do this with GuiControl Move or MoveDraw, but was unsuccessful.


You may use GuiControl,Move to resize the control after finding the Control's new size with Laszlo's GetTextSize()


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 16th, 2009, 9:01 pm 
Offline

Joined: November 24th, 2005, 8:16 am
Posts: 851
Heh... thats a cheap but neat trick. :)
I may use it, thanks - just hoping the creation and destruction of that extra GUI window is not too overkill.

_________________
Sector-Seven - Freeware tools built with AutoHotkey


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 16th, 2009, 9:15 pm 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
Icarus wrote:
thats a cheap but neat trick. :)


You may also want to refer Sean's GetTextExtentPoint() posted in the same topic


Report this post
Top
 Profile  
Reply with quote  
PostPosted: November 28th, 2011, 6:28 pm 
Offline

Joined: June 14th, 2009, 7:48 pm
Posts: 331
TLM wrote:
afaict you have to use WinMove to resize GUI windows.
there may be even a better way than my script if you figure out the amount of rows and update the control or window with an R[n] instead of W[n]. Still not 100% sure though. In my case I tried some janky char to gui size math :oops: but it works :lol:..
hth
SKAN wrote:
Icarus wrote:
I was hoping I can do this with GuiControl Move or MoveDraw, but was unsuccessful.
You may use GuiControl,Move to resize the control after finding the Control's new size with Laszlo's GetTextSize()
I would like a listview to adapt size according to the content in it.
ListView help
Eg - Listview window size would be larger (Height and width) if there is 30 rows of text than only 3 lines; also will be centered or positionned as instructed.
I searched for some time and found this thread.
GuiControl, Move is not working for me (I may use it uncorrectly).
WinMove seems to work, although I feel there might be better solutions.
I found how to get widht :


To set size, I need to find height (number of rows)
Code:
Rows:=LV_GetCount() ; gives rows count but rows height (size) is needed
   Loop % LV_GetCount("Column") ; gives Columns numbers and size
{
    SendMessage, 4125, A_Index - 1, 0, SysListView321  ; 4125 is LVM_GETCOLUMNWIDTH.
    EnvAdd, Width, (Width + ErrorLevel)
    }
 WinMove, Code List, , , , Width, Rows * 15 ; added arbitrary number (pixel?) for row size
   GuiControl +BackgroundBlack +Redraw, MyListView

If someone can help, It'll be of great relief. :oops:

_________________
AHK No BlanK AHK No Comments and more


Last edited by awannaknow on November 29th, 2011, 10:31 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 28th, 2011, 8:13 pm 
Offline

Joined: August 7th, 2011, 1:23 pm
Posts: 754
[EDIT] reposted here

_________________
Win7 - Firefox 10.0.2 - AHK_L 1.1.07.00
Please bear with me and my English which is so bad at times that even I don't understand myself


Last edited by Odlanir on November 29th, 2011, 9:46 am, edited 2 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 29th, 2011, 6:21 pm 
Offline

Joined: June 14th, 2009, 7:48 pm
Posts: 331
Continued with Odlanir here : ListView help

_________________
AHK No BlanK AHK No Comments and more


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], Yahoo [Bot] and 19 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group