TheDcoder Posted March 17, 2015 Share Posted March 17, 2015 (edited) Hello, Please look at the image below: (Click for animation) Notice that the "Red" section appearing instantly before the Main GUI... Code: #include-once ; -- Created with ISN Form Studio 2 for ISN AutoIt Studio -- ; #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Include <GuiButton.au3> Global $test_gui = GUICreate("test",300,300,-1,-1,-1,-1) GUISetBkColor(0xFFFFFF,$test_gui) GUISetState(@SW_SHOW, $test_gui) Global $test_child_gui = GUICreate("test child", 150, 150, 0, 0, $WS_POPUP, $WS_EX_MDICHILD, $test_gui) GUISetBkColor(0xFF0000, $test_child_gui) GUISetState(@SW_SHOW, $test_child_gui) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd How can I prevent it? Thanks in Advance Edited March 17, 2015 by TheDcoder EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted March 17, 2015 Moderators Share Posted March 17, 2015 You can't seriously expect we'll be able to assist with only a single line of code? How about posting the whole code, or at least a reproducer, so we can see what is going on? "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
TheDcoder Posted March 17, 2015 Author Share Posted March 17, 2015 @JLogan3o13 Updated the question EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
JakeJohnson74 Posted March 17, 2015 Share Posted March 17, 2015 (edited) I just added a sleep in there. Is that what you are talking about? It's 2000ms, obviously you can tweak this, 150 "feels" natural to me. I just set it large to exaggerate it. #include-once ; -- Created with ISN Form Studio 2 for ISN AutoIt Studio -- ; #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Include <GuiButton.au3> Global $test_gui = GUICreate("test",300,300,-1,-1,-1,-1) GUISetBkColor(0xFFFFFF,$test_gui) GUISetState() Global $test_child_gui = GUICreate("test child", 150, 150, 0, 0, $WS_POPUP, $WS_EX_MDICHILD, $test_gui) GUISetBkColor(0xFF0000, $test_child_gui) sleep(2000) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Edited March 17, 2015 by JakeKenmode Link to comment Share on other sites More sharing options...
TheDcoder Posted March 17, 2015 Author Share Posted March 17, 2015 @JakeKenmode I have already tried that but I need a more logical (i.e. sleep until main GUI appears completely) solution Thanks anyway Jake TD EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted March 17, 2015 Moderators Share Posted March 17, 2015 In testing the code, just as you have it, on my WIN7 x64 box, both main and child gui show up almost instantaneously. Had I not known the nature of your topic, I would not have noticed the difference. Added either a sleep or a WinWaitActive pointed at the main GUI causes a noticeable delay in seeing the sub. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
JakeJohnson74 Posted March 17, 2015 Share Posted March 17, 2015 He is talking about the Aero interface anim on the main GUI window. The Main GUI has a Win7 Aero style applied which animates it on the way in and the child GUI he creates is within the form and so there is no additional animation on it so it displays 100% while the main GUI is still fading in. You would have to monitor Aero and wait for the animation to finish ( or something like that), and then show the child GUI if I am understanding him correctly. I think you are both right They BOTH trigger at exactly the same time. The main window appears delayed because it Aero animation lasts longer than the instant draw on the child GUI. Oddly enough - when I have run into Aero issues with Win7 the response I tend to get here is that X user says: "Oh... I don't use Aero" Link to comment Share on other sites More sharing options...
binhnx Posted March 17, 2015 Share Posted March 17, 2015 Oddly is what you've done. What makes you separate the menu to another window? 99 little bugs in the code 99 little bugs! Take one down, patch it around 117 little bugs in the code! Link to comment Share on other sites More sharing options...
TheDcoder Posted March 17, 2015 Author Share Posted March 17, 2015 (edited) @binhnx You can refer to this thread... TD Edited March 17, 2015 by TheDcoder EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
binhnx Posted March 17, 2015 Share Posted March 17, 2015 (edited) >this? Seems not relevant Edit: Read the thread. So why you need a separate window? (More clear, just add buttons - which act as menu - to your main window and everything is just fine) Edited March 17, 2015 by binhnx 99 little bugs in the code 99 little bugs! Take one down, patch it around 117 little bugs in the code! Link to comment Share on other sites More sharing options...
JakeJohnson74 Posted March 17, 2015 Share Posted March 17, 2015 (edited) @TheDcoder If this is in fact the issue you are seeing with the timing (Aero interface animation vs. the instant rendering of controls / Guis in the main form) here is an example to show that disabling Aero, loading the Main gui and the child gui are timed exactly the same. Not that you would run this sort of code found below - but to show what is happening here. #include-once ; -- Created with ISN Form Studio 2 for ISN AutoIt Studio -- ; #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Include <GuiButton.au3> DllCall("dwmapi.dll", "hwnd", "DwmEnableComposition", "uint", 0) ;Disable Aero Global $test_gui = GUICreate("test",300,300,-1,-1,-1,-1) GUISetBkColor(0xFFFFFF,$test_gui) GUISetState() Global $test_child_gui = GUICreate("test child", 150, 150, 0, 0, $WS_POPUP, $WS_EX_MDICHILD, $test_gui) GUISetBkColor(0xFF0000, $test_child_gui) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE DllCall("dwmapi.dll", "hwnd", "DwmEnableComposition", "uint", 1) ;Enable Aero Exit EndSwitch WEnd Edited March 17, 2015 by JakeKenmode Link to comment Share on other sites More sharing options...
TheDcoder Posted March 17, 2015 Author Share Posted March 17, 2015 @JakeKenmode Not working.... EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
JakeJohnson74 Posted March 17, 2015 Share Posted March 17, 2015 Ah - I just looked at your screenshot - you are in Windows 8 aren't you! My code only runs in Windows 7 MSDN says : Note This function is deprecated as of Windows 8. DWM can no longer be programmatically disabled. sorry man Link to comment Share on other sites More sharing options...
binhnx Posted March 18, 2015 Share Posted March 18, 2015 First, take a look >here (thread by @JakeJohnson74) And ensure that you are not possible to use only 1 GUI. If you can, do use 1. If you can't, continue to read. If you want all your GUI to be shown at once, you must use only 1 popup. Yes, multiple GUI but only 1 popup - your main GUI. So edit this: Global $test_child_gui = GUICreate("test child", 150, 150, 0, 0, $WS_POPUP, $WS_EX_MDICHILD, $test_gui) GUISetBkColor(0xFF0000, $test_child_gui) GUISetState(@SW_SHOW, $test_child_gui)to this: Global $test_child_gui = GUICreate("test child", 150, 150, 0, 0, BitOr($WS_CHILD, $WS_VISIBLE, $WS_CLIPCHILDREN, $WS_CLIPSIBLINGS), -1, $test_gui) GUISetBkColor(0xFF0000, $test_child_gui)Now if your child gui does not contain any control, you are OK. But it is does, you will have problem with tab select. Normally, you can press tab multiple times to navigate to every controls in your gui. But now you can't (also, it you use multiple popup child gui, you can't also). So what do you need to do now? It's quite complicated. First, you need $WS_EX_CONTROLPARENT Global $test_child_gui = GUICreate("test child", 150, 150, 0, 0, BitOr($WS_CHILD, $WS_VISIBLE, $WS_CLIPCHILDREN, $WS_CLIPSIBLINGS), $WS_EX_CONTROLPARENT, $test_gui) Run the code, and your red test_child_gui can now be dragable around your main gui. Surprise? Since AutoIt provide some hacky way to helps most people easier to script, its also make someone sad. In AutoIt, $WS_EX_CONTROLPARENT also make entire the gui dragable. So you need extra 1 step, handle WM_NCHITTEST and reset the default system behaviour: GUIRegisterMsg($WM_NCHITTEST, 'Wm_NcHittest') Func Wm_NcHittest($hWnd, $uMsg, $wParam, $lParam) If ($hWnd = $test_child_gui) Then ; Be sure to do this check or you will mess up with the msg handler like @JakeJohnson did) Return 1 EndIf Return $GUI_RUNDEFMSG EndFunc 99 little bugs in the code 99 little bugs! Take one down, patch it around 117 little bugs in the code! Link to comment Share on other sites More sharing options...
zalomalo Posted March 18, 2015 Share Posted March 18, 2015 (edited) go system properties > performance > visual effects > uncheck window animations and fades. Also, the windows sizes varies because the borders with temes and styles in windows 8. In WindowsXP the size define all the visible, in Windows8 the borders (bars) are outside the sizes correponding to winXP, in function of styles. This is a window(400,200) dont have same size of total pixels in XP than Win8. Edited March 18, 2015 by zalomalo My english shucks, i know it. Link to comment Share on other sites More sharing options...
Solution TheDcoder Posted March 18, 2015 Author Solution Share Posted March 18, 2015 Original answer from this post by binhnx, you should have a look at it if you need more information (Also to know the cons of using the following solution) . This post is made to make life easier for people who have been suffering from this problem Here is your answer: #include-once ; -- Created with ISN Form Studio 2 for ISN AutoIt Studio -- ; #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Include <GuiButton.au3> Global $test_gui = GUICreate("test",300,300,-1,-1,-1,-1) GUISetBkColor(0xFFFFFF,$test_gui) GUISetState() ; This is the faulty statement: Global $test_child_gui = GUICreate("test child", 150, 150, 0, 0, $WS_POPUP, $WS_EX_MDICHILD, $test_gui) Global $test_child_gui = GUICreate("test child", 150, 150, 0, 0, BitOr($WS_CHILD, $WS_VISIBLE, $WS_CLIPCHILDREN, $WS_CLIPSIBLINGS), -1, $test_gui) ; You should change the faulty statement to the above correct statement to avoid the "Aero Window Apperence Delay" effect.... GUISetBkColor(0xFF0000, $test_child_gui) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Before: (click images to animate them) After: TD binhnx 1 EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
TheDcoder Posted March 18, 2015 Author Share Posted March 18, 2015 @binhnx A big thanks to you!! EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
binhnx Posted March 18, 2015 Share Posted March 18, 2015 I'm happy to see your problem solved. Just a small notice: When you create a GUI with $WS_VISIBLE flag, you don't need to use GUISetState() to show it. Then the 2nd GUISetState() (after GUISetBkColor(0xFF0000, $test_child_gui)) could be safely removed. 99 little bugs in the code 99 little bugs! Take one down, patch it around 117 little bugs in the code! Link to comment Share on other sites More sharing options...
TheDcoder Posted March 18, 2015 Author Share Posted March 18, 2015 expandcollapse popup#include-once ; -- Created with ISN Form Studio 2 for ISN AutoIt Studio -- ; #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Include <GuiButton.au3> Global $test_gui = GUICreate("test",300,300,-1,-1,-1,-1) GUISetBkColor(0xFFFFFF,$test_gui) GUISetState() ; Before: Global $test_child_gui = GUICreate("test child", 150, 150, 0, 0, $WS_POPUP, $WS_EX_MDICHILD, $test_gui) Global $test_child_gui = GUICreate("test child", 150, 150, 0, 0, BitOr($WS_CHILD, $WS_CLIPCHILDREN, $WS_CLIPSIBLINGS), -1, $test_gui) ; After GUISetBkColor(0xFF0000, $test_child_gui) GUISetState(@SW_SHOW, $test_child_gui) Global $test_child_gui2 = GUICreate("test child 2", 150, 150, 0, 0, BitOr($WS_CHILD, $WS_CLIPCHILDREN, $WS_CLIPSIBLINGS), -1, $test_gui) GUISetBkColor(0x00CCFF, $test_child_gui2) GUICtrlCreateButton("My Text",20,230,100,30,-1,-1) GUICtrlCreateButton("My Text",180,230,100,30,-1,-1) Global $red = GUICtrlCreateButton("Red", 20, 230, 100, 30, -1, -1) Global $blue = GUICtrlCreateButton("Blue", 180, 230, 100, 30, -1, -1) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $red SwitchColour(1) Case $blue SwitchColour(2) EndSwitch WEnd Func SwitchColour($id) GUISetState(@SW_HIDE, $test_child_gui) GUISetState(@SW_HIDE, $test_child_gui2) If $id = 1 Then GUISetState(@SW_SHOW, $test_child_gui) Else GUISetState(@SW_SHOW, $test_child_gui2) EndIf EndFunc I made this code for testing but the buttons are not being displayed, any help? EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
binhnx Posted March 18, 2015 Share Posted March 18, 2015 You added the button to the last child? Should a GUISwitch() statement help? 99 little bugs in the code 99 little bugs! Take one down, patch it around 117 little bugs in the code! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now