Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

Problems with GuiMsg


  • Please log in to reply
13 replies to this topic

#1 peterbonge

peterbonge

    Seeker

  • Active Members
  • 14 posts

Posted 12 June 2004 - 10:35 PM

I've problems with closing my gui with the red X:

GuiCreate("Titel") ... GuiWaitClose() If GuiRead() = $butMove then ... If GuiRead() = $butCopy then ... If GuiRead() = $butConfig Then ... If GuiRead() = $butCancel OR GuiMsg(0) = -3 Then Exit


With the build before 10th June this worked fine. Now it doesn't. If I change the code to "GuiMsg() = -3" (without the 0) it works, but I have to click twice on the X (or once on the X and once on any other button. Am I doing something wrong or is this a bug?

Edit: Now I've noticed that with "GuiMsg() = -3" all other buttons doesn't work anymore. They are all closing the gui, but only after 2 clicks. Maybe I must solve this with If...ElseIf...Else...EndIf.
Closing a gui when not using GuiWaitClose() is no problem. Strange...

Edited by peterbonge, 12 June 2004 - 10:52 PM.

Regards,Peter Bonge







#2 SlimShady

SlimShady

    AutoIt lover

  • Active Members
  • PipPipPipPipPipPip
  • 2,383 posts

Posted 12 June 2004 - 10:58 PM

Talking about closing Guis...
When I click on a button the Gui hides itself and the specified function runs.
I use this workaround:
           GUIShow()             AddCat();user defined function


And the Gui window returns like it was before.

Edited by SlimShady, 12 June 2004 - 11:01 PM.


#3 Holger

Holger

    AutoIt Spammer

  • Developers
  • 1,384 posts

Posted 12 June 2004 - 11:37 PM

Hmmm...I'm using the 10th build and have no problem.
I used this:
GuiCreate("Titel") $butMove = GuiSetControl("button","Move",50,10,70,22) $butCopy = GuiSetControl("button","Copy",50,40,70,22) $butConfig = GuiSetControl("button","Config",50,70,70,22) $butCancel = GuiSetControl("button","Cancel",50,100,70,22) GuiWaitClose() If GuiRead() = $butMove then Msgbox(0,"","Move clicked") If GuiRead() = $butCopy then Msgbox(0,"","Copy clicked") If GuiRead() = $butConfig Then Msgbox(0,"","Config clicked") If GuiRead() = $butCancel OR GuiMsg(0) = -3 Then Exit

I'm using WinXPSP1 and all works fine :D

Edit: what happens if you use the example from the help file?:
Plain Text         
#include "GUIConstants.au3" $title="My advanced GUI" GUICreate($title); will create a dialog box that when displayed is centered GUISetControl("button", "my clicking button", 10,10) GUISetControlNotify() GUISetControl("button", "my closing button", 10,50) GUISetControlEx(-1,$GUI_FOCUS)  ; the focus is on this button and Click will hide the GUI GUIShow()      ; display the dialog box timeout 10 seconds AdLibEnable("CheckChange") WinWaitClose($title)  ; GuiWaitClose cannot be used to wait AdlibDisable() exit Func CheckChange () $n = GUIMsg(0)      ; get the current state and return immediately Select case $n>0     MsgBox(0,"", "the button " & GUIRead() & " has been clicked",2) Case $n=-1     MsgBox(0,"", "dialog box being closed by timeout",2)     exit      ; or GuiDelete to stop the waiting WinWaitClose case $n=-2     MsgBox(0,"", "dialog box is hidden",2)     GuiDelete()      ; will stop the waiting of WinWaitClose and close the script case $n=-3     MsgBox(0,"", "dialog box being closed by red button",2)     exit      ; or GuiDelete to stop the waiting WinWaitClose case $n=-4     MsgBox(0,"", "dialog box minimized",2) case $n=-5     MsgBox(0,"", "dialog box restaured",2) case $n=-6     MsgBox(0,"", "dialog box maximize",2) case $n=0 ; no change case else     MsgBox(0,"", "unknown return from GUIMsg",2) EndSelect EndFunc


Do you use "GUINotifyMode"?

Edited by Holger, 12 June 2004 - 11:51 PM.


#4 SlimShady

SlimShady

    AutoIt lover

  • Active Members
  • PipPipPipPipPipPip
  • 2,383 posts

Posted 12 June 2004 - 11:51 PM

Forgot to mention: I'm using the version that was available on the 6th of June.
I had the same problems with your example.
This works better:
AutoItSetOption("GUINotifyMode", 1) GuiCreate("Titel") $butMove = GuiSetControl("button","Move",50,10,70,22) $butCopy = GuiSetControl("button","Copy",50,40,70,22) $butConfig = GuiSetControl("button","Config",50,70,70,22) $butCancel = GuiSetControl("button","Cancel",50,100,70,22) GUIShow() While 1 If GUIMsg(0) <> 0 Then If GuiRead() = $butMove then Msgbox(0,"","Move clicked") If GuiRead() = $butCopy then Msgbox(0,"","Copy clicked") If GuiRead() = $butConfig Then Msgbox(0,"","Config clicked") If GuiRead() = $butCancel OR GuiMsg(0) = -3 Then Exit EndIf Sleep(100) WEnd


I used the second example you posted, and that one works fine.

Edited by SlimShady, 12 June 2004 - 11:56 PM.


#5 Holger

Holger

    AutoIt Spammer

  • Developers
  • 1,384 posts

Posted 13 June 2004 - 12:26 AM

@SlimShady: Are you sure that you don't have a problem?
If I use your example then closing over the [x] doesn't func...
And for me it's logical:
You use these lines:
... If GUIMsg(0) <> 0 Then ... If GuiRead() = $butCancel OR GuiMsg(0) = -3 Then Exit

The first GUIMsg(0) realize that you have clicked at the [x] and then goes on through the code.
Then 'it' comes to the second GUIMsg(0) and checked again for a change -> but there's no change!
So the gui will never close over [x]...
Do you see what I mean?
It's better to change the line to:
If GuiRead() = $butCancel OR GuiRead() = -3 Then Exit


P.S.: in the new build you don't need a sleep cause Jon build it in - sleep(10) if you use GUIMsg(0) :D

Edited by Holger, 13 June 2004 - 12:30 AM.


#6 Valik

Valik

    Former developer.

  • Active Members
  • PipPipPipPipPipPip
  • 18,879 posts

Posted 13 June 2004 - 12:48 AM

The problem I see, GuiWatiClose and GuiMsg() should NOT be used together. They are two completely different ways of running a GUI and shouldn't be mixed. If you need interactive or more refined control over the GUI, then GuiMsg() is your bet bet. If you want to create simple GUI's that don't need interactivity, then GuiWaitClose() is sufficient.

#7 peterbonge

peterbonge

    Seeker

  • Active Members
  • 14 posts

Posted 13 June 2004 - 08:08 PM

Yes, it's a relative simple gui with 4 buttons. So I don't want to use a loop or AdLib. My solution so far is:

GuiCreate("Titel") ... GuiWaitClose() If GuiRead() = $butMove Then    ... ElseIf GuiRead() = $butCopy Then    ... ElseIf GuiRead() = $butConfig Then    ... Else    Exit EndIf

Regards,Peter Bonge

#8 Jon

Jon

    Up all night to get lucky

  • Administrators
  • 10,294 posts

Posted 13 June 2004 - 08:27 PM

Remove the

AutoItSetOption("GUINotifyMode", 1)

At the top of your script. In the default mode each button generates a "close" event. In "notify" mode each button click just generates an event to be used with GuiMsg()

(personally I think the default Notify mode and GuiWaitClose should be removed - they are only of use for a tiny amount of scripts and are just confusing)

Edited by Jon, 13 June 2004 - 08:29 PM.


#9 jpm

jpm

    a Real GUI/debug lover

  • Developers
  • 9,549 posts

Posted 13 June 2004 - 08:59 PM

Remove the

AutoItSetOption("GUINotifyMode", 1)

At the top of your script.  In the default mode each button generates a "close" event.  In "notify" mode each button click just generates an event to be used with GuiMsg()

(personally I think the default Notify mode and GuiWaitClose should be removed - they are only of use for a tiny amount of scripts and are just confusing)

do you mean only notify?
for the guiWaitClose I was thinking it will be easier for newbies but I don't care now you leave France to win in the EUro Scoccer championship. :D
To be frank we should not have won.

#10 Valik

Valik

    Former developer.

  • Active Members
  • PipPipPipPipPipPip
  • 18,879 posts

Posted 13 June 2004 - 09:01 PM

Remove the

AutoItSetOption("GUINotifyMode", 1)

At the top of your script.  In the default mode each button generates a "close" event.  In "notify" mode each button click just generates an event to be used with GuiMsg()

(personally I think the default Notify mode and GuiWaitClose should be removed - they are only of use for a tiny amount of scripts and are just confusing)

I agree with that. Unless you are making glorified message boxes, an interactive message pump is the only way to make a GUI. GuiWaitClose() is not a good introduction to GUI scripting because it employs an entirely different mindset than GuiMsg(). It does work well for doing something simple quickly, but doesn't teach anything useable in the future when wanting to make something more advanced.

#11 CyberSlug

CyberSlug

    Overwhelmed with work....

  • MVPs
  • 3,587 posts

Posted 14 June 2004 - 12:32 PM

GuiWaitClose() is not a good introduction to GUI scripting because it employs an entirely different mindset than GuiMsg().  It does work well for doing something simple quickly, but doesn't teach anything useable in the future when wanting to make something more advanced.

I've thought the same thing.... Should we remove GuiWaitClose?
Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

#12 jpm

jpm

    a Real GUI/debug lover

  • Developers
  • 9,549 posts

Posted 14 June 2004 - 01:17 PM

I agree with that.  Unless you are making glorified message boxes, an interactive message pump is the only way to make a GUI.  GuiWaitClose() is not a good introduction to GUI scripting because it employs an entirely different mindset than GuiMsg().  It does work well for doing something simple quickly, but doesn't teach anything useable in the future when wanting to make something more advanced.

I am not sure we want to teach about the pump mechanism to newbies.
That's the reason why I implement GuiWaitClose() and GuiMsg().
If all gui are generated with the AutoBuilder everybody will have to understand the pump mechanism

#13 CyberSlug

CyberSlug

    Overwhelmed with work....

  • MVPs
  • 3,587 posts

Posted 14 June 2004 - 02:25 PM

If all gui are generated with the AutoBuilder everybody will have to understand the pump mechanism

:D That means I have to maintain AutoBuilder and fix bugs :huh2:
Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

#14 jpm

jpm

    a Real GUI/debug lover

  • Developers
  • 9,549 posts

Posted 14 June 2004 - 03:18 PM

:D That means I have to maintain AutoBuilder and fix bugs  :)

Perhaps YES it is a so good script/application :huh2:




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users