Jump to content
Sign in to follow this  
Vaeb

Buttons are hidden behind the Picture

Recommended Posts

Hi every1!

I've got this part of a script:

Func main2()
GUISetState(@SW_HIDE, $SGui)
$Gui1 = GUICreate("Stockwerk", "701", "661")
GUICtrlCreatePic(@ScriptDir & "\System\bild2.bmp", "5", "5", "691", "631")
$og1 = GUICtrlCreateButton("Obergeschoss 1", "50", "50")
GUICtrlSetOnEvent($og1, "Obergeschosse")
$og2 = GUICtrlCreateButton("Obergeschoss 2", "50", "150")
GUICtrlSetOnEvent($og2, "Obergeschosse")
$og3 = GUICtrlCreateButton("Obergeschoss 3", "50", "250")
GUICtrlSetOnEvent($og3, "Obergeschosse")
$og4 = GUICtrlCreateButton("Obergeschoss 4", "50", "350")
GUICtrlSetOnEvent($og4, "Obergeschosse")
$og5 = GUICtrlCreateButton("Obergeschoss 5", "50", "450")
GUICtrlSetOnEvent($og5, "Obergeschosse")
$og6 = GUICtrlCreateButton("Obergeschoss 6", "50", "550")
GUICtrlSetOnEvent($og6, "Obergeschosse")
$ort1 = GUICtrlCreateButton("ort1", "150", "290")
GUICtrlSetOnEvent($ort1, "ort1")
GUICtrlSetState($ort1, $GUI_DISABLE)
$ort3 = GUICtrlCreateButton("ort3", "384", "465")
GUICtrlSetOnEvent($ort3, "ort3")
GUICtrlSetState($ort3, $GUI_DISABLE)
$ort2 = GUICtrlCreateButton("ort2", "220", "470")
GUICtrlSetOnEvent($ort2, "ort2")
GUICtrlSetState($ort2, $GUI_DISABLE)
$Exit = GUICtrlCreateMenu("Beenden")
GUICtrlCreateMenuitem("Exit", $Exit)
GUICtrlSetOnEvent(-1, "ExitMenu")
GUISetOnEvent($GUI_EVENT_CLOSE, "Exit2")
GUISetState(@SW_SHOW, $Gui1)
EndFunc
 
 
While 1
    Sleep(100)
WEnd
 
Func Obergeschosse()
            $Gui1 = GUIGetMsg()
                Switch $Gui1
                    Case $og1
                            $msgn = "ers"
                            $n = "1"
                            GUICtrlCreatePic(@ScriptDir & "\System\bild1", "5", "5", "691", "631")
                            GUICtrlSetState($og1 And $og2 And $og3 And $og4 And $og5 And $og6, $GUI_DISABLE)
                            GUICtrlSetState($ort1 And $ort3, $GUI_ENABLE)
                    Case $og2
                            $msgn = "zwei"
                            $n = "2"
                            GUICtrlCreatePic(@ScriptDir & "\System\bild1.bmp", "5", "5", "691", "631")
                            GUICtrlSetState($og1 And $og2 And $og3 And $og4 And $og5 And $og6, $GUI_DISABLE)
                            GUICtrlSetState($ort1 And $ort2 And $ort3, $GUI_ENABLE)
                EndSwitch
EndFunc

And the problems are:

1. The buttons sometimes hide behind the picture.

2. The buttons doesn't work when i click on them with the mouse.

3. When i click on a button, nothing happens.

Do any1 know how i can fix this?

Greets

Vaeb

Share this post


Link to post
Share on other sites

Thanks for your help.

@Zedna: Sith that part, i can now use my mouse to click the Buttons.

I still have this problem:

Nothing happens when i click on a Button.

The Picture should change and some buttons should be enabled after i clicked on a button.

Here is the actual part of the script:

Func Obergeschosse()
            $pic111 = GUICtrlCreatePic(@ScriptDir & "\System\pic.bmp", "5", "5", "691", "631",$WS_CLIPSIBLINGS)
            GUICtrlSetState(-1,$GUI_DISABLE)
            While 1
                $msg = GUIGetMsg()
                Switch $msg
                    Case $og1
                            $msgn = "ers"
                            $n = "1"
                            GUICtrlSetState($og1, $GUI_DISABLE)
                            GUICtrlSetState($og2, $GUI_DISABLE)
                            GUICtrlSetState($og3, $GUI_DISABLE)
                            GUICtrlSetState($og4, $GUI_DISABLE)
                            GUICtrlSetState($og5, $GUI_DISABLE)
                            GUICtrlSetState($og6, $GUI_DISABLE)
                            GUICtrlSetState($place1, $GUI_ENABLE)
                            GUICtrlSetState($place2, $GUI_ENABLE)
                            ExitLoop
                    Case $og2
                            $msgn = "zwei"
                            $n = "2"
                            GUICtrlSetState($og1, $GUI_DISABLE)
                            GUICtrlSetState($og2, $GUI_DISABLE)
                            GUICtrlSetState($og3, $GUI_DISABLE)
                            GUICtrlSetState($og4, $GUI_DISABLE)
                            GUICtrlSetState($og5, $GUI_DISABLE)
                            GUICtrlSetState($og6, $GUI_DISABLE)
                            GUICtrlSetState($place1, $GUI_ENABLE)
                            GUICtrlSetState($place3, $GUI_ENABLE)
                            ExitLoop
                    Case $GUI_EVENT_CLOSE
                            Exit
                EndSwitch
            WEnd
EndFunc

Greets

Vaeb

Share this post


Link to post
Share on other sites

Thanks for your fast help!

@ Bert: I can't do that, cause th pic has to change.

@ Zedna: You was right. The pic-color changes now.

The stuff with the cases still don't work.

When I click on the button $og1, the og-buttons should be disabled and some other buttos should be enabled.

Greets

Vaeb

Share this post


Link to post
Share on other sites

Thanks for your fast help!

@ Bert: I can't do that, cause th pic has to change.

@ Zedna: You was right. The pic-color changes now.

The stuff with the cases still don't work.

When I click on the button $og1, the og-buttons should be disabled and some other buttos should be enabled.

Greets

Vaeb

Ehhh... Sorry. Didn't read your 1st post properly. Give me a sec to see :P

It has to be either GUICtrlSetOnEvent, or GUIGetMsg, so which is it going to be?

Edited by Bert

Share this post


Link to post
Share on other sites

I would like to do it by GUIGetMsg.

What have i got to change?

Remove all the GUICtrlSetOnEvent Functions, and add a case for the control into the while loop (The one in the func, you can use to replace the one with the sleep...) :P Edited by Bert

Share this post


Link to post
Share on other sites

I think I'm goin crazy :P

I tried to do what you said.

The script does strange things.

It's really not doing what I want it to do ;)

This is how the relevant part looks:

main()


While 1
    $Obg = GUIGetMsg ()
    Switch $Obg
        Case $og1
            GUICtrlSetImage ($pic111, @ScriptDir & "\System\pic2.bmp")
                            GUICtrlSetState(-1,$GUI_DISABLE)
                            $msgn = "ers"
                            $n = "1"
                            GUICtrlSetState($og1, $GUI_DISABLE)
                            GUICtrlSetState($og2, $GUI_DISABLE)
                            GUICtrlSetState($og3, $GUI_DISABLE)
                            GUICtrlSetState($og4, $GUI_DISABLE)
                            GUICtrlSetState($og5, $GUI_DISABLE)
                            GUICtrlSetState($og6, $GUI_DISABLE)
                            GUICtrlSetState($place1, $GUI_ENABLE)
                            GUICtrlSetState($place3, $GUI_ENABLE)
        Case $og2
            GUICtrlSetImage ($pic111, @ScriptDir & "\System\pic2.bmp")
                            $msgn = "zwei"
                            $n = "2"
                            GUICtrlSetState($og1, $GUI_DISABLE)
                            GUICtrlSetState($og2, $GUI_DISABLE)
                            GUICtrlSetState($og3, $GUI_DISABLE)
                            GUICtrlSetState($og4, $GUI_DISABLE)
                            GUICtrlSetState($og5, $GUI_DISABLE)
                            GUICtrlSetState($og6, $GUI_DISABLE)
                            GUICtrlSetState($place2, $GUI_ENABLE)
                            GUICtrlSetState($place3, $GUI_ENABLE)
                             
        Case $og3 = GUICtrlCreateButton("Obergeschoss 3", "50", "250")

        Case $og4 = GUICtrlCreateButton("Obergeschoss 4", "50", "350")

        Case $og5 = GUICtrlCreateButton("Obergeschoss 5", "50", "450")

        Case $og6 = GUICtrlCreateButton("Obergeschoss 6", "50", "550")
    EndSwitch
WEnd


Func main()
Opt("GUIOnEventMode", 1)
$SGui = GUICreate("Drucker", "200", "100")
GUISetOnEvent($GUI_EVENT_CLOSE, "Exit2")
GUICtrlCreateButton("Einfach", "30", "50")
GUICtrlSetOnEvent(-1, "Basic")
GUICtrlCreateButton("Erweitert", "80", "50")
GUICtrlSetOnEvent(-1, "Advanced")
GUICtrlCreateButton("Löschen", "130", "50")
GUICtrlSetOnEvent(-1, "Delete")
GUISetState(@SW_SHOW, $SGui)
If $SGui = "Advance" Then
    $Adv = 1
Else
    $Adv = 2
EndIf
EndFunc

Func main2()
GUISetState(@SW_HIDE, $SGui)
$Gui1 = GUICreate("Stockwerk", "701", "661")
GUISetState(@SW_SHOW, $Gui1)
$pic111 = GUICtrlCreatePic(@ScriptDir & "\System\pic1.bmp", "5", "5", "691", "631",$WS_CLIPSIBLINGS )
GUICtrlSetState(-1,$GUI_DISABLE)

$place1 = GUICtrlCreateButton("place1", "150", "290")
GUICtrlSetState($place1, $GUI_DISABLE)

$place2 = GUICtrlCreateButton("place2", "384", "465")
GUICtrlSetState($place2, $GUI_DISABLE)

$place3 = GUICtrlCreateButton("place3", "220", "470")
GUICtrlSetState($place3, $GUI_DISABLE)

$og1 = GUICtrlCreateButton("Obergeschoss 1", "50", "50")
$og2 = GUICtrlCreateButton("Obergeschoss 2", "50", "150")               

$Exit = GUICtrlCreateMenu("Beenden")
GUICtrlCreateMenuitem("Exit", $Exit)
GUICtrlSetOnEvent(-1, "ExitMenu")
GUISetOnEvent($GUI_EVENT_CLOSE, "Exit2")
EndFunc

Greets

Vaeb

Share this post


Link to post
Share on other sites

I decided to do it the other way.

I didn't know that i have to change the whole script.

When I click on the button "Obergeschoss 1", the Obergeschosse buttons doesn't disable, but they should.

Isn't it possible to do it like this?

If not, do you know a better solution?

The relevant part of the script:

Opt("GUICloseOnESC", 1)
Opt("GUIOnEventMode", 1)
$Gui1 = GUICreate("Stockwerk", "701", "661")
$pic111 = GUICtrlCreatePic(@ScriptDir & "\System\pic2.bmp", "5", "5", "691", "631",$WS_CLIPSIBLINGS )
GUICtrlSetState(-1,$GUI_DISABLE)
GUISetOnEvent($GUI_EVENT_CLOSE, "Exit2")
GUICtrlCreateButton("Obergeschoss 1", "50", "50")
GUICtrlSetOnEvent(-1, "Og1")
GUICtrlCreateButton("Obergeschoss 2", "50", "150")
GUICtrlSetOnEvent(-1, "Og2")
GUICtrlCreateButton("Obergeschoss 3", "50", "250")
GUICtrlSetOnEvent(-1, "Og3")
GUICtrlCreateButton("Obergeschoss 4", "50", "350")
GUICtrlSetOnEvent(-1, "Og4")
GUICtrlCreateButton("Obergeschoss 5", "50", "450")
GUICtrlSetOnEvent(-1, "Og5")
GUICtrlCreateButton("Obergeschoss 6", "50", "550")
GUICtrlSetOnEvent(-1, "Og6")
$Waisenhausstrasse = GUICtrlCreateButton("Place1", "220", "470")
GUICtrlSetState($Place1, $GUI_DISABLE)
$Bahnhofquai = GUICtrlCreateButton("Place2", "384", "465")
GUICtrlSetState($Place2, $GUI_DISABLE)
$Bahnhofplatz = GUICtrlCreateButton("Place3", "150", "290")
GUICtrlSetState($Place3, $GUI_DISABLE)
$Exit = GUICtrlCreateMenu("Beenden")
GUICtrlCreateMenuitem("Exit", $Exit)
GUICtrlSetOnEvent(-1, "ExitMenu")
GUISetState(@SW_HIDE, $Gui1)

Func Og1()
    $msgn = "ers"
    $n = "1"
    GUICtrlSetImage ($pic111, @ScriptDir & "\System\pic1.bmp")
    GUICtrlSetState($og1 And $og2 And $og3 And $og4 And $og5 And $og6, $GUI_DISABLE)
    GUICtrlSetState($Place1, $GUI_ENABLE)
    GUICtrlSetState($Place2, $GUI_ENABLE)
EndFunc   ;==>Og1

Greets

Vaeb

Share this post


Link to post
Share on other sites

Maybe a simple example will help you understand how to get Buttons to work :P

#include <GUIConstants.au3>

$GUI = GUICreate("Button Test", 100, 100)

$ButtonEnable = GUICtrlCreateButton("Enable Button", 10, 10)
$ButtonDisable = GUICtrlCreateButton("Disable Button", 10, 10)
$Button = GUICtrlCreateButton("Button", 10, 50)

GUICtrlSetState($ButtonDisable, $GUI_DISABLE + $GUI_HIDE)
GUICtrlSetState($Button, $GUI_DISABLE)

GUISetState()

While 1
    $Msg = GUIGetMsg()
    Switch $Msg
    Case $ButtonEnable
        GUICtrlSetState($Button, $GUI_ENABLE)
        GUICtrlSetState($ButtonDisable, $GUI_ENABLE + $GUI_SHOW)
        GUICtrlSetState($ButtonEnable, $GUI_DISABLE + $GUI_HIDE)
    Case $ButtonDisable
        GUICtrlSetState($ButtonEnable, $GUI_ENABLE + $GUI_SHOW)
        GUICtrlSetState($Button, $GUI_DISABLE)
        GUICtrlSetState($ButtonDisable, $GUI_DISABLE + $GUI_HIDE)
    Case $Button
        MsgBox(0,"", "Button was pressed!")
    Case $GUI_EVENT_CLOSE
        ExitLoop
    EndSwitch
WEnd

GuiDelete()
Edited by D4ni

Share this post


Link to post
Share on other sites

It will not work I think.

Bert said: "It has to be either GUICtrlSetOnEvent, or GUIGetMsg"

And I need GUICtrlSetOnEvent in my script.

It does work... I just use GUIGetMsg(). I don't use both, now do I? It works fine. Why do you want to use GUIOnEvent mode?

ps. please first actually run stuff before you claim it doesn't work :P

pps. I didn't have the intention to have you use this in your program, I just hoped I could explain how GUIGetMsg() mode works ;)

~~ EDIT

Please read some documentation first man. I never used onevent, but converted my script in 2 minutes. here you go

#include <GUIConstants.au3>
$I_Say_So = False;

Opt("GUIOnEventMode", 1)  ; Change to OnEvent mode

$GUI = GUICreate("Button Test", 100, 100)

$ButtonEnable = GUICtrlCreateButton("Enable Button", 10, 10)
$ButtonDisable = GUICtrlCreateButton("Disable Button", 10, 10)
$Button = GUICtrlCreateButton("Button", 10, 50)
GUICtrlSetOnEvent($ButtonEnable, "Enable")
GUICtrlSetOnEvent($ButtonDisable, "Disable")
GUICtrlSetOnEvent($Button, "Button")
;GUICtrlSetOnEvent($GUI_EVENT_CLOSE, "Quit")

GUICtrlSetState($ButtonDisable, $GUI_DISABLE + $GUI_HIDE)
GUICtrlSetState($Button, $GUI_DISABLE)

GUISetState()

Do
    ; Nothing
Until $I_Say_So

Func Button()
    MsgBox(1,"", "Button pressed!")
EndFunc

Func Enable()
    GUICtrlSetState($Button, $GUI_ENABLE)
    GUICtrlSetState($ButtonDisable, $GUI_ENABLE + $GUI_SHOW)
    GUICtrlSetState($ButtonEnable, $GUI_DISABLE + $GUI_HIDE)
EndFunc

Func Disable()
    GUICtrlSetState($ButtonEnable, $GUI_ENABLE + $GUI_SHOW)
    GUICtrlSetState($Button, $GUI_DISABLE)
    GUICtrlSetState($ButtonDisable, $GUI_DISABLE + $GUI_HIDE)
EndFunc


Func Quit()
    Exit
EndFunc

I commented out the function associated with the $GUI_EVENT_CLOSE cause it caused my script to exit even when the button was pressed :s

Edited by D4ni

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  

×
×
  • Create New...