AutoHotkey Community

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

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: October 29th, 2005, 1:16 am 
Offline

Joined: March 24th, 2005, 11:50 am
Posts: 398
Location: germany
I use a Gui with multiple Picture-controls.
Formerly, I used version 1.0.40.00, and needed about 6000mS to display it. Now, wih th new version, I need about 9000mS.
Following I have a testscript, wait, till the gui is build, then move one slider, and wait until all pictures are build. A message-box will pop up, and tell you the needed time.
Put the following bitmap in the SkriptDir
Image
and rename it to leer_15.bmp


Code:
SetBatchLines  -1
SetControlDelay, 0
Gui, Add, Slider, gHorizont vHorizont range0-121 tooltip x46 y634 w910 h20, 25
Gui, Add, Slider,  gVertikal vVertikal range0-131 vertical tooltip x26 y34 w20 h600, 25
Loop, Read, test_kurz.txt
   {
   StringSplit, OutputArray, A_loopreadline, %A_Tab%
   %OutputArray1% := A_loopreadline . "`n"
   %OutputArray1%_Kord := OutputArray2
;x := OutputArray2
;msgbox, % x
   }
loop, 60
{
ter := A_index * 15 + 40
x_koord := horizont + A_index
   loop, 38
   {
      Picture_Index += 1
      bbb := A_index * 15 + 30
      y_koord := vertikal + A_index
   
      if %x_koord%_%y_koord%_Kord =
      {
      grr := %x_koord%_%y_koord%   
         Gui, Add, Picture, vpict%Picture_Index% x%ter% y%bbb% w15 h15 , %A_ScriptDir%\leer_15.bmp
      }

   }

}

Gui, Show, x173 y100 h690 w983, start mit part
WinGet, active_id, ID, A

Return


;************************************************************

Del_array:
loop, 160
{
x_kord = %A_index%
loop, 160
{
y_kord = %A_index%
X%x_kord%_%y_kord% =
%x_kord%_%y_kord% =
}
}
return

;************************************************************
Horizont:
Zeit = %A_TickCount%
gosub, mapper
Zeit := A_TickCount - Zeit
Gui, Show, x173 y100 h700 w1000, start mit part
msgbox, % zeit
return

Vertikal:
Zeit = %A_TickCount%
gosub, mapper
Zeit := A_TickCount - Zeit

Gui, Show, x173 y100 h700 w1000, start mit part
msgbox, % zeit
return


;************************************************************

Mapper:

Picture_Index = 0
Loop, Read, test_kurz.txt
   {

   StringSplit, OutputArray, A_loopreadline, %A_Tab%
   ; msgbox,    _%OutputArray1%_
   %OutputArray1% := %OutputArray1% .  A_loopreadline . "`n"

   }
loop, 60
{
ter := A_index * 10 + 25
x_koord := horizont + A_index
   loop, 38
   {
      Picture_Index += 1
      
      y_koord := vertikal + A_index

      
      if %x_koord%_%y_koord% =
      {
      grr := %x_koord%_%y_koord%   
         Guicontrol,,  pict%Picture_Index%, %A_ScriptDir%\leer_15.bmp
         
      }

   }

}
return
;************************************************************

GuiClose:
ExitApp


Last edited by garath on October 29th, 2005, 11:19 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 29th, 2005, 2:06 am 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
It turns out the slow-down is due to the following change in v1.0.40.01:
Quote:
Fixed GuiControl to properly redraw Picture controls and transparent Text controls when they are given new contents.
Since I don't think that change can be safely undone, here is a solution that should make drawing much faster in both versions:
Quote:
....
x_koord := horizont + A_index
Gui +LastFound
SendMessage, 0xB, false ; 0xB is WM_SETREDRAW

....
SendMessage, 0xB, true
}
return
On my system, the above change makes both v1.0.40.00 and 03 quite a bit faster. It also makes 00 and 03 perform much closer to each other.

When the window had drawing disabled using the above method, it won't behave like a normal window. To work around this, you could pop up another GUI window that is owned by the main window. It would tell the user to please wait until the drawing completes, then disappear when the it finishes.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 29th, 2005, 10:42 am 
Offline

Joined: March 24th, 2005, 11:50 am
Posts: 398
Location: germany
Thanks, Chris, for the quick reply, added your improvement to my bigger skript, works 3 times faster, now. :)
After drawing all Pictures in the backround, I need to update the gui, to display the changes. Therefore I used:
Code:
Gui,show, hide
Gui, Show

Is there a better way to redraw a Gui?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 29th, 2005, 10:44 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
Oops, I put the SendMessage too low (you might have already noticed). To achieve even better performance, put the first SendMessage above the outer loop and the second one beneath the outer loop (right before "return").

You can also achieve the same boost in performance (or slightly better) by hiding the window while updating its picture controls (in other words, SendMessage wouldn't be necessary). Hiding it might be better because it allows you to show a small status window in place of the main window saying, "Please wait while the window is updated..."

Quote:
Is there a better way to redraw a Gui?
To cause a window to repaint without having to use WinMove or WinHide/Show, try the following:
Gui +LastFound
WinSet Redraw


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 31st, 2005, 7:26 pm 
Offline

Joined: March 24th, 2005, 11:50 am
Posts: 398
Location: germany
I saw the wrong postion of the "send message", but I understood, how to use it ;-)
Winset Redraw is the right way to update a Window, thanks for the tip.

I use a transparent window with the same dimensions in front of the changing window to catch all mouse events, which would fall through the changing window to the windows behind. I don`t want it hidden, because it would flicker each time, i move a slider. so, it only freezes a short time.


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 15 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