Sign in to follow this  
Followers 0
darzanmihai

Create initially hiden controls?

17 posts in this topic

How could I create initially hiden controls? I do not need to create the control and then make it hiden, I need it to be created hiden already.

How could I do this?

Thx in advance.


I do not like stupid and idiot people that write idiot things...If you are one, do not write.

Share this post


Link to post
Share on other sites



You set the state of the control after you make it, but BEFORE you show the GUI. Example:

$button1 = GUICtrlCreateButton("button", 3, 3, 20, 20)
GUICtrlSetState($button1, $GUI_HIDE)
GUISetState()

I know what you say, but I need this control created after the gui was shown, so I need it to be already hiden.


I do not like stupid and idiot people that write idiot things...If you are one, do not write.

Share this post


Link to post
Share on other sites

I know what you say, but I need this control created after the gui was shown, so I need it to be already hiden.

Create and destroy them in runtime, look up GUICtrlDelete()...

Share this post


Link to post
Share on other sites

Create and destroy them in runtime, look up GUICtrlDelete()...

I do not need it to be deleted, I only need the control to be hiden in the moment I create it.

The script I have, creates controls and then when I push a button, it deletes the existing controls (Guictrldelete) and creates other controls, but some of those I need them to be hiden already. If I hide them after creating them, they can bee seen for a flash of a seccond and it is not cool.

Thx for replay


I do not like stupid and idiot people that write idiot things...If you are one, do not write.

Share this post


Link to post
Share on other sites

Is this a GUI you are making?

Yes, I am making a GUI :)

Thx for replay


I do not like stupid and idiot people that write idiot things...If you are one, do not write.

Share this post


Link to post
Share on other sites

Here is what you do. Make the control beforehand, but hide it first and also have it located off the screen. Have it as a dummy control so to speak. You can use GUICtrlSetPos to move the control into position you need, then use GUICtrlSetData to set the text of the control. Once you do this, you can show it if needed. That way you won't get the flicker.

Share this post


Link to post
Share on other sites

Here is what you do. Make the control beforehand, but hide it first and also have it located off the screen. Have it as a dummy control so to speak. You can use GUICtrlSetPos to move the control into position you need, then use GUICtrlSetData to set the text of the control. Once you do this, you can show it if needed. That way you won't get the flicker.

Why didn't think of that?

Thank you very much!


I do not like stupid and idiot people that write idiot things...If you are one, do not write.

Share this post


Link to post
Share on other sites

Why didn't think of that?

Thank you very much!

Whell....my gui has got a picture as background, and by doing as you suggested, I will still get the flicker. This is an example script to demonstrate that flicker:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>

#Region ### START Koda GUI section ### Form=
$GuiWidth = 633
$GuiHeight = 447
$Form1 = GUICreate("Form1",$GuiWidth ,$GuiHeight , -1, -1)
$Pic2 = GUICtrlCreatePic(@WindowsDir & "\ServicePackFiles\i386\Sample1.jpg", 0, 0, $GuiWidth, $guiHeight, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS))
    GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlCreateInput("", $GuiWidth +10, $GuiHeight+10,100,23)

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$inp = GUICtrlCreateInput("", $GuiWidth +10, $GuiHeight+10,100,23)
GUICtrlSetState(-1,$GUI_HIDE)
Local $w=0,$h=0 , $i=0
While 1
    
    GUICtrlSetPos($inp,$w,$h)
    $w+=5
    If $w> $GuiWidth+10 Then 
        $w=0
        $h+=5
    EndIf
    If $w>$GuiWidth and $h>$GuiHeight Then Exit
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

I do not like stupid and idiot people that write idiot things...If you are one, do not write.

Share this post


Link to post
Share on other sites

as i said...

Create and destroy them in runtime...

if needed, save values to variables and set them with GuiCtrlSetData() instantly after creation...

Share this post


Link to post
Share on other sites

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>

$GuiWidth = 633
$GuiHeight = 447
$Form1 = GUICreate("Form1",$GuiWidth ,$GuiHeight , -1, -1)
$Pic2 = GUICtrlCreatePic(@WindowsDir & "\ServicePackFiles\i386\Sample1.jpg", 0, 0, $GuiWidth, $guiHeight, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS))
GUICtrlSetState(-1, $GUI_DISABLE)
$button = GUICtrlCreateButton("Show Input",20,200)
GUISetState(@SW_SHOW)

$inp_value = "TestValue"

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $button
            if GUICtrlRead($button) = "Show Input" Then
                $inp = GUICtrlCreateInput("", 10, 10,100,23)
                GUICtrlSetData(-1,$inp_value)
                GUICtrlSetData($button,"Hide Input")
            Else
                GUICtrlSetData($button,"Show Input")
                GUICtrlDelete($inp)
            EndIf
    EndSwitch
WEnd

Share this post


Link to post
Share on other sites

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>

$GuiWidth = 633
$GuiHeight = 447
$Form1 = GUICreate("Form1",$GuiWidth ,$GuiHeight , -1, -1)
$Pic2 = GUICtrlCreatePic(@WindowsDir & "\ServicePackFiles\i386\Sample1.jpg", 0, 0, $GuiWidth, $guiHeight, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS))
GUICtrlSetState(-1, $GUI_DISABLE)
$button = GUICtrlCreateButton("Show Input",20,200)
GUISetState(@SW_SHOW)

$inp_value = "TestValue"

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $button
            if GUICtrlRead($button) = "Show Input" Then
                $inp = GUICtrlCreateInput("", 10, 10,100,23)
                GUICtrlSetData(-1,$inp_value)
                GUICtrlSetData($button,"Hide Input")
            Else
                GUICtrlSetData($button,"Show Input")
                GUICtrlDelete($inp)
            EndIf
    EndSwitch
WEnd

I agree with your solution, but if I use it I will have to modify a very large amount of my code, so I need another way to do this...


I do not like stupid and idiot people that write idiot things...If you are one, do not write.

Share this post


Link to post
Share on other sites

I agree with your solution, but if I use it I will have to modify a very large amount of my code, so I need another way to do this...

Does anybody have other ideeas?


I do not like stupid and idiot people that write idiot things...If you are one, do not write.

Share this post


Link to post
Share on other sites

Does anybody have other ideeas?

In the example you posted

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>

#Region ### START Koda GUI section ### Form=
$GuiWidth = 633
$GuiHeight = 447
$Form1 = GUICreate("Form1",$GuiWidth ,$GuiHeight , -1, -1)
$Pic2 = GUICtrlCreatePic(@WindowsDir & "\ServicePackFiles\i386\Sample1.jpg", 0, 0, $GuiWidth, $guiHeight, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS))
    GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlCreateInput("", $GuiWidth +10, $GuiHeight+10,100,23)

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$inp = GUICtrlCreateInput("", $GuiWidth +10, $GuiHeight+10,100,23)
GUICtrlSetState(-1,$GUI_HIDE)
Local $w=0,$h=0 , $i=0
While 1
    
    GUICtrlSetPos($inp,$w,$h)
    $w+=5
    If $w> $GuiWidth+10 Then
        $w=0
        $h+=5
    EndIf
    If $w>$GuiWidth and $h>$GuiHeight Then Exit
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd
you are constantly moving the control. Is this what you're doing in your "real" script?

Perhaps if you can outline the end result you're trying to accomplish, we can offer other ideas.

Share this post


Link to post
Share on other sites

In the example you posted you are constantly moving the control. Is this what you're doing in your "real" script?

Perhaps if you can outline the end result you're trying to accomplish, we can offer other ideas.

In my original script I have to hiddenly move about 100 controls, each control is moved only one time, but the example I made was to reproduce the efect of moving all those controls.


I do not like stupid and idiot people that write idiot things...If you are one, do not write.

Share this post


Link to post
Share on other sites

In my original script I have to hiddenly move about 100 controls, each control is moved only one time, but the example I made was to reproduce the efect of moving all those controls.

Volly almost had it right the first time, but instead of hiding the control after it's created which creates the flash, hide it WHEN it's created:

$button1 = GUICtrlCreateButton("button", 3, 3, 20, 20,$GUI_HIDE)

That way you create it where you want it, don't have to move it, and you have no flash when creating it.

Then if you have to show it later on do a GUICtrlSetState($button1,$GUI_SHOW)

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
Sign in to follow this  
Followers 0