Sign in to follow this  
Followers 0
dromenox

Show and Hide Window

5 posts in this topic

#1 ·  Posted (edited)

I'm trying to create a function that toggles between Hide and Show when I press F1. My code hides not only back to normal when I press F1 again. 
 
#include <Array.au3>
#include <Misc.au3>

Global $boxes[10]
Global $host = 'Calculadora'

$boxes[0] = GuiCreate('', 100, 200, 10, 10, 0x80000000, BitOR(0x00000008, 0x00000100))
GUISetBkColor($boxes[0])
GUISetState(@SW_SHOW, $boxes[0])



;$boxes[1] = GuiCreate('', 100, 200, 120, 10, 0x80000000, 0x00000008)
;GUISetBkColor($boxes[1])
;GUISetState(@SW_SHOW, $boxes[1])

HotKeySet('{F1}', 'write_show_0')
Global $show = 1

While True

WEnd

Func write_show_0()
   if $show = 1 Then
 WinSetState($boxes[0], '', '@SW_HIDE')
 $show = 0
   ElseIf $show = 0 Then
 WinSetState($boxes[0], '', '@SW_SHOW')
 $show = 1
   EndIf
EndFunc
 
Edited by dromenox

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

This works for me

#include <Array.au3>
#include <Misc.au3>

Global $boxes[10]
Global $host = 'Calculadora'

$boxes[0] = GUICreate('', 100, 200, 10, 10, 0x80000000, BitOR(0x00000008, 0x00000100))
GUISetBkColor($boxes[0])
GUISetState(@SW_SHOW, $boxes[0])



;$boxes[1] = GuiCreate('', 100, 200, 120, 10, 0x80000000, 0x00000008)
;GUISetBkColor($boxes[1])
;GUISetState(@SW_SHOW, $boxes[1])

HotKeySet('{F1}', 'write_show_0')
Global $show = 1

While True

WEnd

Func write_show_0()
    If $show = 1 Then
        WinSetState($boxes[0], '', @SW_HIDE)
        $show = 0
    Else ;If $show = 0 Then
        WinSetState($boxes[0], '', @SW_SHOW )
        $show = 1
    EndIf
EndFunc   ;==>write_show_0

REB

Edited by reb

MEASURE TWICE - CUT ONCE

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Yes, the problem is in WinSetState($boxes[0], '', '@SW_HIDE'). It's just WinSetState($boxes[0], '', @SW_HIDE)

Edit:

The same with @SW_SHOW.

Edited by SirJohann

Codes codes codes.

Share this post


Link to post
Share on other sites

Why do not you use GUISetState?

#include <Array.au3>
#include <Misc.au3>

Global $boxes[10]
Global $host = 'Calculadora'

$boxes[0] = GUICreate('', 100, 200, 10, 10, 0x80000000, BitOR(0x00000008, 0x00000100))
GUISetBkColor($boxes[0])
GUISetState(@SW_SHOW, $boxes[0])



;$boxes[1] = GuiCreate('', 100, 200, 120, 10, 0x80000000, 0x00000008)
;GUISetBkColor($boxes[1])
;GUISetState(@SW_SHOW, $boxes[1])

HotKeySet('{F1}', 'write_show_0')
Global $show = 1

While True

WEnd

Func write_show_0()
    If $show = 1 Then
        GUISetState(@SW_HIDE, $boxes[0])
        $show = 0
    ElseIf $show = 0 Then
        GUISetState(@SW_SHOW, $boxes[0])
        $show = 1
    EndIf
EndFunc   ;==>write_show_0

Share this post


Link to post
Share on other sites

thank you all, problem solved!

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