AutoHotkey Community

It is currently May 27th, 2012, 12:04 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 10 posts ] 
Author Message
PostPosted: January 5th, 2011, 12:31 pm 
Offline

Joined: October 13th, 2009, 10:09 pm
Posts: 1389
See this example script (On Win7 32Bit):
Code:
Gui, Add, Button, gButton, Test
Gui, Show, Autosize
return

Button:
if(state)
   Gui +E0x10
else
   Gui -E0x10
state := !state
return


On my machine this makes the taskbar icon disappear for a short moment, then it will reappear. In addition, the program will lose focus and will sometimes not regain it. Is this behavior fixable?
I'm trying to avoid setting this style too often, but I need to do so at one place while my GUI is visible.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 10th, 2011, 8:32 pm 
Offline

Joined: October 13th, 2009, 10:09 pm
Posts: 1389
Has anyone been able to reproduce this bug?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 10th, 2011, 8:43 pm 
Offline

Joined: June 18th, 2008, 8:36 am
Posts: 4923
Location: AHK Forum
Does it happen using WinSet as well?
Code:
Gui, Add, Button, gButton, Test
Gui, Show, AutoSize
Gui,+LastFound
hwnd:=WinExist()
return

Button:
if(state)
   WinSet,ExStyle, +0x10,ahk_id %hwnd%
else
   WinSet,ExStyle, -0x10,ahk_id %hwnd%
state := !state
return

_________________
AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun :wink:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 10th, 2011, 8:46 pm 
Offline

Joined: October 13th, 2009, 10:09 pm
Posts: 1389
No, when using WinSet it seems to work fine.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 11th, 2011, 9:07 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
This behaviour appears to be by design:
Code:
// Hiding then showing is the only way I've discovered to make it update.  If the window
// is not updated, a strange effect occurs where the window is still visible but can no
// longer be used at all (clicks pass right through it).  This show/hide method is less
// desirable due to possible side effects caused to any script that happens to be watching
// for its existence/non-existence, so it would be nice if some better way can be discovered
// to do this.
// SetWindowPos is also necessary, otherwise the frame thickness entirely around the window
// does not get updated (just parts of it):

SetWindowPos(mHwnd, NULL, 0, 0, 0, 0, SWP_DRAWFRAME|SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE);
ShowWindow(mHwnd, SW_HIDE);
ShowWindow(mHwnd, SW_SHOWNA); // i.e. don't activate it if it wasn't before. Note that SW_SHOWNA avoids restoring the window if it is currently minimized or maximized (unlike SW_SHOWNOACTIVATE).
// None of the following methods alone is enough, at least not when the window is currently active:
// 1) InvalidateRect(mHwnd, NULL, TRUE);
// 2) SendMessage(mHwnd, WM_NCPAINT, 1, 0);  // 1 = Repaint entire frame.
// 3) RedrawWindow(mHwnd, NULL, NULL, RDW_INVALIDATE|RDW_FRAME|RDW_UPDATENOW);
// 4) SetWindowPos(mHwnd, NULL, 0, 0, 0, 0, SWP_DRAWFRAME|SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE);



Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 11th, 2011, 11:20 am 
Offline

Joined: October 13th, 2009, 10:09 pm
Posts: 1389
I haven't observed this behavior using the WinSet method, but I only did a quick test so far. Also it should maybe be tested if this problem persists in newer versions of Windows.
Apart from that, I noticed the window sometimes not getting reactivated properly. I don't have any NoActivate option set.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 12th, 2011, 4:59 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
The code I posted is an extract from the Gui command, so it does no affect the WinSet command. It does not attempt to reactivate the window - the comments imply that it should remain active if it was already. It doesn't always remain active on my Windows 7 system. I guess it's up to whether the OS activates some other window when the active one is hidden.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 12th, 2011, 12:44 pm 
Offline

Joined: October 13th, 2009, 10:09 pm
Posts: 1389
I was talking about the "Click-through" behavior mentioned in that comment in relation to the WinSet command. This is why I suggest testing if this behavior is still present in Win7 when the GUI isn't hidden and shown again.
If this problem persists in Win7, could you add the activation of the window?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 17th, 2011, 2:36 pm 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
I have changed the Gui command in v1.1.00.01 so that it behaves the same as WinSet when setting or removing styles. The following is taken from my comments in the source code:
Quote:
Update by Lexikos: I've been unable to produce the "strange effect" described above using WinSet on Win2k/XP/7, so changing this section to use the same method as WinSet. If there are any problems, at least WinSet and Gui will be consistent.


Last edited by Lexikos on July 17th, 2011, 2:38 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 17th, 2011, 2:38 pm 
Offline

Joined: October 13th, 2009, 10:09 pm
Posts: 1389
Sounds good.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 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