Jump to content

hide gui not working


Recommended Posts

hi guys!

i'm trying to hide all my form gui but it doens work...

the line is 126

#AutoIt3Wrapper_Add_Constants=n
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiImageList.au3>
#include <GuiButton.au3>
#include <GuiListView.au3>
#include <FontConstants.au3>
#include <Misc.au3>
#include <GuiTreeView.au3>
#include "OnEventFunc.au3"
#include <File.au3>

Opt("GUIOnEventMode", 1);<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

Global $g_aidGraphics[11]

$imagens = @ScriptDir & '\' & "gradient.bmp"

#region configuração de form
$x = 1000
$y = 600
$w =(@DesktopWidth/2)-($x/2)
$h =(@DesktopHeight/2)-($y/2)

Global $Form_imagens = GUICreate("Imagens", $x, $y, $w, $h,BitOR($WS_POPUP, $DS_SETFOREGROUND))
GUISetBkColor(0x505050)
GUICtrlSetDefColor(0xc1c1c1)
#EndRegion



#Region botoes de comando da janela
    $x_label = GUICtrlCreateLabel("X", $x - 30, 10, 20, 20, BitOr($SS_NOTIFY, $SS_CENTER, $SS_CENTERIMAGE, $SS_SUNKEN))
    ;GUISetOnEvent($GUI_EVENT_CLOSE, "close_x")
    GUICtrlSetOnEvent(-1, "close_x")
    GUICtrlSetBkColor(-1, 0x414141)
    $ctrlpos = ControlGetPos($Form_imagens, "", $x_label)
    GUICtrlCreatePic($imagens, $ctrlpos[0],$ctrlpos[1], $ctrlpos[2],$ctrlpos[3])
#EndRegion



#Region Outros
    GUICtrlCreateLabel("-- Fotos--", 10, 40, $x-20, 30, BitOr($SS_NOTIFY, $SS_CENTER, $SS_CENTERIMAGE, $SS_SUNKEN))
    GUICtrlSetBkColor(-1, 0x991010)
    GUICtrlSetFont (-1,15,$FW_HEAVY)
    GUICtrlCreateLabel("ENVIAR", 350,520, 200,60, BitOr($SS_NOTIFY, $SS_CENTER, $SS_CENTERIMAGE, $SS_SUNKEN))
    GUICtrlSetBkColor(-1, 0x991010)
    GUICtrlSetOnEvent(-1, "enviar_imgs")
#EndRegion

Local $img_src = @ScriptDir & "\imagens"

$x_img_bck = $x-20

dim $legendas[10] = ["a","b","c","d","e","f","g","h","i","j"]
$j = 0

GUICtrlCreateLabel("", 10,90, $x-20,400)
GUICtrlSetBkColor(-1, 0x414141)


GUISetState(@SW_SHOW)

dim $selection[10]
dim $selection2[10]=[0,0,0,0,0,0,0,0,0,0]
dim $senha_selection[10]=[0,0,0,0,0,0,0,0,0,0]
dim $legendas2[10]

;------------SELEÇAO
for $i = 24 to  809 step  191
    $selection[$j] = GUICtrlCreateLabel("", $i,110, 186 ,150, BitOr($SS_CENTER, $SS_CENTERIMAGE))
    GUICtrlSetBkColor(-1, 0xfff200)
    GUICtrlSetState(-1,$GUI_HIDE)
    $selection[$j+5] = GUICtrlCreateLabel("", $i,266, 186 ,150, BitOr($SS_CENTER, $SS_CENTERIMAGE))
    GUICtrlSetBkColor(-1, 0xfff200)
    GUICtrlSetState(-1,$GUI_HIDE)
    $j = $j +1
Next

$j = 0

for $i = 28 to  809 step  191
    ;------------------IMAGEM
    $a = GUICreate("",184,148,$i,114,$WS_POPUP, $WS_EX_MDICHILD,$Form_imagens) ; cria o GUI vermelho
    GUISetBkColor(0x991010,$a)
    GUICtrlCreatePic($img_src & "\" & $j+1 & ".jpg", 0, 0, 184, 148)
    SetOnEventA(-1, "_select", $paramByVal, $j+1)
    GUISetState(@SW_SHOW)

    ;----------------LEGENDA
    $legendas2[$j] = GUICreate("",184,20,3,132,$WS_POPUP, $WS_EX_MDICHILD,$a)
    GUISetBkColor(0x000000,$legendas2[$j])

    GUICtrlCreateLabel($legendas[$j], 2,-1, 184 ,18) ;label da legenda
    SetOnEventA(-1, "edit", $paramByVal, $j)
    GUICtrlSetFont (-1,12,1)
    GUICtrlSetColor(-1,0xffffff)
    WinSetTrans($legendas2[$j], "", 150)
    GUISetState(@SW_SHOW)

    ;---------------SEGUNDA LINHA

    ;------------------IMAGEM
    $a = GUICreate("",184,148,$i,270,$WS_POPUP, $WS_EX_MDICHILD,$Form_imagens) ; cria o GUI vermelho
    GUISetBkColor(0x991010,$a)
    GUICtrlCreatePic($img_src & "\" & $j+6 & ".jpg", 0, 0, 184, 148)
    SetOnEventA(-1, "_select", $paramByVal, $j+6)
    GUISetState(@SW_SHOW)

    ;----------------LEGENDA
    $aa = GUICreate("",184,20,3,132,$WS_POPUP, $WS_EX_MDICHILD,$a)
    GUISetBkColor(0x000000,$aa)

    GUICtrlCreateLabel($legendas[$j], 2,-1, 184 ,18) ;label da legenda
    SetOnEventA(-1, "edit", $paramByVal, $j)
    GUICtrlSetFont (-1,12,1)
    GUICtrlSetColor(-1,0xffffff)
    WinSetTrans($aa, "", 150)
    GUISetState(@SW_SHOW)

    $j = $j +1
Next

GUISetState($Form_imagens,@SW_HIDE)

while 1
    sleep(20)
WEnd


Func _select(ByRef $a)
    if GUICtrlGetState($selection[$a-1]) ==96 then
        GUICtrlSetState($selection[$a-1],$GUI_SHOW)
        $selection2[$a-1] = 1
    Else
        GUICtrlSetState($selection[$a-1],$GUI_HIDE)
        $selection2[$a-1] = 0
    EndIf

EndFunc   ;==>funcone

func edit($a)
    $adm = true
    if $adm then

    EndIf
EndFunc


Func enviar_imgs()
    $senha_img = true

    for $t = 0 to 8
        if $selection2[$t] <> $senha_selection[$t] then
            $senha_img = false
        EndIf
    Next

    if $senha_img then
        MsgBox(0,"","Senha Correta")
    Else
        MsgBox(0,"","Senha Incorreta")
    EndIf


EndFunc

func close_x()
exit
EndFunc

 

Link to comment
Share on other sites

It doesn't work because @SW_SHOW shows the GUI not hides it.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

  • Moderators

Melque_Lima,

GUISetState($Form_imagens, @SW_HIDE)

Go and read the Help file and check the order of the parameters in that command.

M23

Edit: And you will need to hide all the child GUIs as well.

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

2 minutes ago, Melque_Lima said:

i'm trying GUISetState(@SW_HIDE,$Form_imagens) after while(1) 

the principal gui gets hide but the inside guis doenst!!

not sure, but I think you must use GUISetState for each GUI (in a loop)

 

Link to comment
Share on other sites

i've create an array gui control and a function that shows and hides the all guis thank all

 

#AutoIt3Wrapper_Add_Constants=n
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiImageList.au3>
#include <GuiButton.au3>
#include <GuiListView.au3>
#include <FontConstants.au3>
#include <Misc.au3>
#include <GuiTreeView.au3>
#include "OnEventFunc.au3"
#include <File.au3>

Opt("GUIOnEventMode", 1);<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

Global $g_aidGraphics[11]

$imagens = @ScriptDir & '\' & "gradient.bmp"

#region configuração de form
$x = 1000
$y = 600
$w =(@DesktopWidth/2)-($x/2)
$h =(@DesktopHeight/2)-($y/2)

Global $Form_imagens = GUICreate("Imagens", $x, $y, $w, $h,BitOR($WS_POPUP, $DS_SETFOREGROUND))
GUISetBkColor(0x505050)
GUICtrlSetDefColor(0xc1c1c1)
GUISetState(@SW_HIDE,$Form_imagens)
#EndRegion



#Region botoes de comando da janela
    $x_label = GUICtrlCreateLabel("X", $x - 30, 10, 20, 20, BitOr($SS_NOTIFY, $SS_CENTER, $SS_CENTERIMAGE, $SS_SUNKEN))
    ;GUISetOnEvent($GUI_EVENT_CLOSE, "close_x")
    GUICtrlSetOnEvent(-1, "close_x")
    GUICtrlSetBkColor(-1, 0x414141)
    $ctrlpos = ControlGetPos($Form_imagens, "", $x_label)
    GUICtrlCreatePic($imagens, $ctrlpos[0],$ctrlpos[1], $ctrlpos[2],$ctrlpos[3])
#EndRegion



#Region Outros
    GUICtrlCreateLabel("-- Fotos--", 10, 40, $x-20, 30, BitOr($SS_NOTIFY, $SS_CENTER, $SS_CENTERIMAGE, $SS_SUNKEN))
    GUICtrlSetBkColor(-1, 0x991010)
    GUICtrlSetFont (-1,15,$FW_HEAVY)
    GUICtrlCreateLabel("ENVIAR", 350,520, 200,60, BitOr($SS_NOTIFY, $SS_CENTER, $SS_CENTERIMAGE, $SS_SUNKEN))
    GUICtrlSetBkColor(-1, 0x991010)
    GUICtrlSetOnEvent(-1, "enviar_imgs")
#EndRegion

Local $img_src = @ScriptDir & "\imagens"

$x_img_bck = $x-20

dim $legendas[10] = ["a","b","c","d","e","f","g","h","i","j"]
$j = 0

GUICtrlCreateLabel("", 10,90, $x-20,400)
GUICtrlSetBkColor(-1, 0x414141)


;GUISetState(@SW_SHOW)

dim $selection[10]
dim $selection2[10]=[0,0,0,0,0,0,0,0,0,0]
dim $senha_selection[10]=[0,0,0,0,0,0,0,0,0,0]
dim $legendas2[10]
dim $imagens[10]

;------------SELEÇAO
for $i = 24 to  809 step  191
    $selection[$j] = GUICtrlCreateLabel("", $i,110, 186 ,150, BitOr($SS_CENTER, $SS_CENTERIMAGE))
    GUICtrlSetBkColor(-1, 0xfff200)
    GUICtrlSetState(-1,$GUI_HIDE)
    $selection[$j+5] = GUICtrlCreateLabel("", $i,266, 186 ,150, BitOr($SS_CENTER, $SS_CENTERIMAGE))
    GUICtrlSetBkColor(-1, 0xfff200)
    GUICtrlSetState(-1,$GUI_HIDE)
    $j = $j +1
Next

$j = 0

for $i = 28 to  809 step  191
    ;------------------IMAGEM
    $imagens[$j] = GUICreate("",184,148,$i,114,$WS_POPUP, $WS_EX_MDICHILD,$Form_imagens) ; cria o GUI vermelho
    GUISetBkColor(0x991010,$imagens[$j])
    GUICtrlCreatePic($img_src & "\" & $j+1 & ".jpg", 0, 0, 184, 148)
    SetOnEventA(-1, "_select", $paramByVal, $j+1)
    ;GUISetState(@SW_SHOW)

    ;----------------LEGENDA
    $legendas2[$j] = GUICreate("",184,20,3,132,$WS_POPUP, $WS_EX_MDICHILD,$imagens[$j])
    GUISetBkColor(0x000000,$legendas2[$j])

    GUICtrlCreateLabel($legendas[$j], 2,-1, 184 ,18) ;label da legenda
    SetOnEventA(-1, "edit", $paramByVal, $j)
    GUICtrlSetFont (-1,12,1)
    GUICtrlSetColor(-1,0xffffff)
    WinSetTrans($legendas2[$j], "", 150)
    ;GUISetState(@SW_SHOW)

    ;---------------SEGUNDA LINHA

    ;------------------IMAGEM
    $imagens[$j+5] = GUICreate("",184,148,$i,270,$WS_POPUP, $WS_EX_MDICHILD,$Form_imagens) ; cria o GUI vermelho
    GUISetBkColor(0x991010,$imagens[$j+5])
    GUICtrlCreatePic($img_src & "\" & $j+6 & ".jpg", 0, 0, 184, 148)
    SetOnEventA(-1, "_select", $paramByVal, $j+6)
    ;GUISetState(@SW_SHOW)

    ;----------------LEGENDA
    $legendas2[$j+5] = GUICreate("",184,20,3,132,$WS_POPUP, $WS_EX_MDICHILD,$imagens[$j+5])
    GUISetBkColor(0x000000,$legendas2[$j+5])

    GUICtrlCreateLabel($legendas[$j], 2,-1, 184 ,18) ;label da legenda
    SetOnEventA(-1, "edit", $paramByVal, $j)
    GUICtrlSetFont (-1,12,1)
    GUICtrlSetColor(-1,0xffffff)
    WinSetTrans($legendas2[$j+5], "", 150)
    ;GUISetState(@SW_SHOW)

    $j = $j +1
Next

hide_show(1)

while 1
    sleep(20)
WEnd


Func hide_show($x)

    if NOT $x then
        GUISetState(@SW_HIDE,$Form_imagens)

        for $y = 0 to 9
            GUISetState(@SW_HIDE,$imagens[$y])
            GUISetState(@SW_HIDE,$legendas2[$y])
        Next
    Else
        GUISetState(@SW_SHOW,$Form_imagens)

        for $y = 0 to 9
            GUISetState(@SW_SHOW,$imagens[$y])
            GUISetState(@SW_SHOW,$legendas2[$y])
        Next

    EndIf
EndFunc

Func _select(ByRef $a)
    if GUICtrlGetState($selection[$a-1]) ==96 then
        GUICtrlSetState($selection[$a-1],$GUI_SHOW)
        $selection2[$a-1] = 1
    Else
        GUICtrlSetState($selection[$a-1],$GUI_HIDE)
        $selection2[$a-1] = 0
    EndIf

EndFunc   ;==>funcone

func edit($a)
    $adm = true
    if $adm then

    EndIf
EndFunc


Func enviar_imgs()
    $senha_img = true

    for $t = 0 to 8
        if $selection2[$t] <> $senha_selection[$t] then
            $senha_img = false
        EndIf
    Next

    if $senha_img then
        MsgBox(0,"","Senha Correta")
    Else
        MsgBox(0,"","Senha Incorreta")
    EndIf


EndFunc

func close_x()
exit
EndFunc

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...