TheDcoder

Child Window Help

21 posts in this topic

#1 ·  Posted (edited)

Hello, Please look at the image below:

post-89462-0-96454600-1426600994_thumb.g

(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 by TheDcoder

AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

Some messages & Apologizes:

If I hurt you, Please accept my apologies, I never (regardless of the situation) mean to hurt anybody!!!

Also, I am very busy with my project so I will appear in the last row of the online list, if you want to contact me: Email@TheDcoder.xyz

Or you can have a nice chat with me in freenode, I use the same nick on freenode too!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites



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?


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

@JLogan3o13 Updated the question :)


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

Some messages & Apologizes:

If I hurt you, Please accept my apologies, I never (regardless of the situation) mean to hurt anybody!!!

Also, I am very busy with my project so I will appear in the last row of the online list, if you want to contact me: Email@TheDcoder.xyz

Or you can have a nice chat with me in freenode, I use the same nick on freenode too!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites

#4 ·  Posted (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 by JakeKenmode

Share this post


Link to post
Share on other sites

@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 :)


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

Some messages & Apologizes:

If I hurt you, Please accept my apologies, I never (regardless of the situation) mean to hurt anybody!!!

Also, I am very busy with my project so I will appear in the last row of the online list, if you want to contact me: Email@TheDcoder.xyz

Or you can have a nice chat with me in freenode, I use the same nick on freenode too!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites

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.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

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" 

Share this post


Link to post
Share on other sites

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!

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

@binhnx You can refer to this thread...

TD :)

Edited by TheDcoder

AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

Some messages & Apologizes:

If I hurt you, Please accept my apologies, I never (regardless of the situation) mean to hurt anybody!!!

Also, I am very busy with my project so I will appear in the last row of the online list, if you want to contact me: Email@TheDcoder.xyz

Or you can have a nice chat with me in freenode, I use the same nick on freenode too!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites

#10 ·  Posted (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 by binhnx

99 little bugs in the code

99 little bugs!

Take one down, patch it around

117 little bugs in the code!

Share this post


Link to post
Share on other sites

#11 ·  Posted (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 by JakeKenmode

Share this post


Link to post
Share on other sites

@JakeKenmode Not working....


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

Some messages & Apologizes:

If I hurt you, Please accept my apologies, I never (regardless of the situation) mean to hurt anybody!!!

Also, I am very busy with my project so I will appear in the last row of the online list, if you want to contact me: Email@TheDcoder.xyz

Or you can have a nice chat with me in freenode, I use the same nick on freenode too!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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!

Share this post


Link to post
Share on other sites

#15 ·  Posted (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 by zalomalo

My english shucks, i know it.

Share this post


Link to post
Share on other sites

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) :D. 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:

post-89462-0-96454600-1426600994_thumb.g
(click images to animate them)
After:
post-89462-0-04177800-1426687472_thumb.g
 
TD :)

 

1 person likes this

AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

Some messages & Apologizes:

If I hurt you, Please accept my apologies, I never (regardless of the situation) mean to hurt anybody!!!

Also, I am very busy with my project so I will appear in the last row of the online list, if you want to contact me: Email@TheDcoder.xyz

Or you can have a nice chat with me in freenode, I use the same nick on freenode too!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites

@binhnx A big thanks to you!! :)


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

Some messages & Apologizes:

If I hurt you, Please accept my apologies, I never (regardless of the situation) mean to hurt anybody!!!

Also, I am very busy with my project so I will appear in the last row of the online list, if you want to contact me: Email@TheDcoder.xyz

Or you can have a nice chat with me in freenode, I use the same nick on freenode too!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites

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!

Share this post


Link to post
Share on other sites

#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? :)


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

Some messages & Apologizes:

If I hurt you, Please accept my apologies, I never (regardless of the situation) mean to hurt anybody!!!

Also, I am very busy with my project so I will appear in the last row of the online list, if you want to contact me: Email@TheDcoder.xyz

Or you can have a nice chat with me in freenode, I use the same nick on freenode too!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites

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!

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now