Jump to content

Show and Hide Window


dromenox
 Share

Recommended Posts

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

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

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