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

MsgBox


  • Please log in to reply
37 replies to this topic

#1 ileandros

ileandros

    Universalist

  • Banned (NOT IN USE)
  • 592 posts

Posted 21 January 2012 - 03:57 PM

Hello there,

Case $hButton5 MsgBox (4,"Update", " Check for updates?") if $hButton5 = 6 Then gui3() ElseIf  $hButton5 = 7 Then Exit    ; what should i add here to make the MsgBox close if i chose 7 = No? EndIf


How do i make the MsgBox close if i chose the answer 7 = no???
I feel nothing.It feels great.







#2 Melba23

Melba23

    I'm old - what's your excuse?

  • Moderators
  • 19,884 posts

Posted 21 January 2012 - 04:04 PM

ileandros,

You test the return value from the MsgBox, not the original button. The MsgBox exits automatically when you press one of its buttons: ;)
 Case $hButton5     ; Create MsgBox and wait for the user to click a button on the MsgBox     If MsgBox(4, "Update", " Check for updates?") = 6 Then         ; If the "Yes" button was pressed         gui3()     Else         ; In all other cases         Exit     EndIf

All cler? :)

M23
StringSize - Automatically size controls to fit text                                                               ExtMsgBox - A user customisable replacement for MsgBox
Toast - Small GUIs which pop out of the Systray                                                                Marquee - Scrolling tickertape GUIs
Scrollbars - Automatically sized scrollbars with a single command                                   GUIFrame - Subdivide GUIs into many adjustable frames
GUIExtender - Extend and retract multiple sections within a GUI                                      NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes
ChooseFileFolder - Single and multiple selections from specified path tree structure      Notify - Small notifications on the edge of the display
Date_Time_Convert - Easily convert date/time formats, including the language               GUIListViewEx - Insert, delete, move, drag, sort and edit ListView items

#3 ileandros

ileandros

    Universalist

  • Banned (NOT IN USE)
  • 592 posts

Posted 21 January 2012 - 04:25 PM

ileandros,

You test the return value from the MsgBox, not the original button. The MsgBox exits automatically when you press one of its buttons: ;)

Case $hButton5     ; Create MsgBox and wait for the user to click a button on the MsgBox     If MsgBox(4, "Update", " Check for updates?") = 6 Then         ; If the "Yes" button was pressed         gui3()     Else         ; In all other cases         Exit     EndIf

All cler? :)

M23

Nah this also gives the same action as the 6 =Yes :/
I feel nothing.It feels great.

#4 Melba23

Melba23

    I'm old - what's your excuse?

  • Moderators
  • 19,884 posts

Posted 21 January 2012 - 04:30 PM

ileandros,

Then post the working code you run that has the MsgBox remaining open after you press one if its buttons. :)

M23
StringSize - Automatically size controls to fit text                                                               ExtMsgBox - A user customisable replacement for MsgBox
Toast - Small GUIs which pop out of the Systray                                                                Marquee - Scrolling tickertape GUIs
Scrollbars - Automatically sized scrollbars with a single command                                   GUIFrame - Subdivide GUIs into many adjustable frames
GUIExtender - Extend and retract multiple sections within a GUI                                      NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes
ChooseFileFolder - Single and multiple selections from specified path tree structure      Notify - Small notifications on the edge of the display
Date_Time_Convert - Easily convert date/time formats, including the language               GUIListViewEx - Insert, delete, move, drag, sort and edit ListView items

#5 ileandros

ileandros

    Universalist

  • Banned (NOT IN USE)
  • 592 posts

Posted 21 January 2012 - 04:47 PM

ileandros,

Then post the working code you run that has the MsgBox remaining open after you press one if its buttons. :)

M23

Func gui3() $hGUI2 = GUICreate("iRadio v1.0",1000,600,200,50) $oIE = _IECreateEmbedded() GUICtrlCreateObj($oIE,10,10,980,580) _IENavigate($oIE,"") GUISetState(@SW_SHOW) EndFunc

I feel nothing.It feels great.

#6 Melba23

Melba23

    I'm old - what's your excuse?

  • Moderators
  • 19,884 posts

Posted 21 January 2012 - 04:49 PM

ileandros,

That is not "working code" - I mean a full script that can actually be run. :)

Make it easy for us to help you - then we all win. ;)

M23
StringSize - Automatically size controls to fit text                                                               ExtMsgBox - A user customisable replacement for MsgBox
Toast - Small GUIs which pop out of the Systray                                                                Marquee - Scrolling tickertape GUIs
Scrollbars - Automatically sized scrollbars with a single command                                   GUIFrame - Subdivide GUIs into many adjustable frames
GUIExtender - Extend and retract multiple sections within a GUI                                      NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes
ChooseFileFolder - Single and multiple selections from specified path tree structure      Notify - Small notifications on the edge of the display
Date_Time_Convert - Easily convert date/time formats, including the language               GUIListViewEx - Insert, delete, move, drag, sort and edit ListView items

#7 ileandros

ileandros

    Universalist

  • Banned (NOT IN USE)
  • 592 posts

Posted 22 January 2012 - 01:24 AM

Ahhh yes i thought only the gui for the button :)
Here it is.
AutoIt         
#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <WindowsConstants.au3> #include <IE.au3> Global $hGUI2 = 9999, $hButton3 = 9999 ; Predeclare the variables with dummy values to prevent firing the Case statements gui1() Func gui1() $hForm1 = GUICreate("", 674, 190, 195, 130) $oIE = _IECreateEmbedded() GUICtrlCreateObj($oIE,295,35,330,110) $hButton1 = GUICtrlCreateButton("", 295, 150, 50, 25) $hButton3 = GUICtrlCreateButton("", 355, 150, 50, 25) $hButton5 = GUICtrlCreateButton("?",660,1,15,20) $hButton2 = GUICtrlCreateButton("", 40, 150, 80, 25) $hButton4 = GUICtrlCreateButton("Exit", 545, 150, 80, 25) $List1 = GUICtrlCreateList("", 40, 35, 201, 110) GUICtrlSetData(-1,"") $hGroup1 = GUICtrlCreateGroup("", 24, 16, 230, 170) GUICtrlCreateGroup("", -99, -99, 1, 1) $hGroup2 = GUICtrlCreateGroup("", 280, 16, 365, 170) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW)     While 1         $aMsg = GUIGetMsg(1) ; Use advanced parameter to get array         Switch $aMsg[1] ; check which GUI sent the message             Case $hForm1                 Switch $aMsg[0] ; Now check for the messages for $hGUI1                     Case $GUI_EVENT_CLOSE ; If we get the CLOSE message from this GUI - we exit <<<<<<<<<<<<<<<                         ExitLoop Case $hButton5 MsgBox (4,"Update", " Check for updates?") if $hButton5 = 6 Then gui3() Elseif exit EndIf Case $hButton4 MsgBox(0,"Exit","Now exiting...") Exit                 EndSwitch             Case $hGUI2                 Switch $aMsg[0] ; Now check for the messages for $hGUI2                     Case $GUI_EVENT_CLOSE ; If we get the CLOSE message from this GUI - we just delete the GUI <<<<<<<<<<<<<<<                         GUIDelete($hGUI2)                         GUICtrlSetState($hButton2, $GUI_ENABLE)                 EndSwitch         EndSwitch     WEnd EndFunc   ;==>gui1 Func gui2() $hGUI2 = GUICreate("Youtube",800,600,200,50) $oIE = _IECreateEmbedded() GUICtrlCreateObj($oIE,10,10,780,580) _IENavigate($oIE,"") GUISetState(@SW_SHOW) EndFunc Func gui3() $hGUI2 = GUICreate("iRadio v1.0",1000,600,200,50) $oIE = _IECreateEmbedded() GUICtrlCreateObj($oIE,10,10,980,580) _IENavigate($oIE,"<a href='http://www.google.gr/' class='bbc_url' title='External link' rel='nofollow external'>http://www.google.gr/"</a>) GUISetState(@SW_SHOW) EndFunc  

I feel nothing.It feels great.

#8 BrewManNH

BrewManNH

    באָבקעס מיט קודוצ׳ה

  • MVPs
  • 9,548 posts

Posted 22 January 2012 - 02:29 AM

You're not checking the return from the MsgBox, you're still using the controlID of $hButton5, which just so happens to be 6. You should also change the ElseIf back to an Else statement. Using Melba23's suggestion for the message box will fix this problem.

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 an XP machine, and I'm not going to.

 

How to ask questions the smart way!

 

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 editorGUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.
GUIToolTip UDF Demo - Demo script to show how to use the GUIToolTip UDF to create and use customized tooltips. Latin Square password generator

 

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.


#9 ileandros

ileandros

    Universalist

  • Banned (NOT IN USE)
  • 592 posts

Posted 22 January 2012 - 12:57 PM

I tried it but i didn't make it.... I posted the script above.
Please check it, try it and tell me if im doing sth wrong.
I feel nothing.It feels great.

#10 Jos

Jos

    oh joy ...

  • Developers
  • 22,534 posts

Posted 22 January 2012 - 01:29 PM

You need to run au3check on your code as it contains errors.
As to you question:


      If MsgBox(4, "Update", " Check for updates?") = 6 Then        gui3()       Else        Exit       EndIf

Edited by Jos, 22 January 2012 - 01:30 PM.

Visit the SciTE4AutoIt3 Download page for the latest versions                                                                 Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)


#11 ileandros

ileandros

    Universalist

  • Banned (NOT IN USE)
  • 592 posts

Posted 22 January 2012 - 02:01 PM

You need to run au3check on your code as it contains errors.
As to you question:


      If MsgBox(4, "Update", " Check for updates?") = 6 Then        gui3()       Else        Exit       EndIf

This doesnt work i already tried it... There are no errors.
The problem is that the gives the same resault as the

 If MsgBox(4, "Update", " Check for updates?") = 6 Then        gui3()
. It doesn't exit the MsgBox :/
I feel nothing.It feels great.

#12 Jos

Jos

    oh joy ...

  • Developers
  • 22,534 posts

Posted 22 January 2012 - 02:22 PM

Well the If I posted is correct and works fine for me.
When I click Yes it will show the Google.gr page and when I click No it will exit the script since that is what Exit does.

Visit the SciTE4AutoIt3 Download page for the latest versions                                                                 Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)


#13 ileandros

ileandros

    Universalist

  • Banned (NOT IN USE)
  • 592 posts

Posted 22 January 2012 - 03:26 PM

Well the If I posted is correct and works fine for me.
When I click Yes it will show the Google.gr page and when I click No it will exit the script since that is what Exit does.


I want the No to exit the MsgBox. I just don't know why but my script run it the same as the YES.
What the hell??? Is there another way to do it???? So i can avoid this??
I feel nothing.It feels great.

#14 Jos

Jos

    oh joy ...

  • Developers
  • 22,534 posts

Posted 22 January 2012 - 03:58 PM

I want the No to exit the MsgBox. I just don't know why but my script run it the same as the YES.
What the hell??? Is there another way to do it???? So i can avoid this??

Any button you click on the MSGBOX will exit the MsgBox().
So What exactly do you want to happen when No is clicked and the MSGbox is gone? Just display the Main GUI or something else?
.. by the way... it works best when you do not loose your temper... at least with me...

Edited by Jos, 22 January 2012 - 03:59 PM.

Visit the SciTE4AutoIt3 Download page for the latest versions                                                                 Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)


#15 Nutster

Nutster

    Developer at Large

  • Developers
  • 1,450 posts

Posted 22 January 2012 - 04:09 PM

I think you are confusing the ideas of MsgBox with your GUI window. They are separate things. When you click any button on the MsgBox (or the timeout expires), the MsgBox automatically closes and returns a value indicating why it closed (which button was pushed, etc.); the MsgBox does not stick around after that, no matter which button you pushed. The GUI that you created can still stick around after the MsgBox disappears, but that is a different story.

As an experiment, build a simple script with just a message box with Yes, No, Cancel as the buttons. Put the value returned from the MsgBox into a variable. Present that value from a Ok only message box just after that.
Dim $nRetVal $nRetVal = MsgBox(3+32, "MsgBox Test", "Please press a button.") MsgBox(64, "MsgBox Test", "The returned number from the last MsgBox was " & $nRetVal & ".")


I like to close the GUI window before exiting with GuiDelete, but that appears to be just me.

Edited by Nutster, 22 January 2012 - 04:10 PM.

David Nuttall

Nuttall Computer Consulting

An Aquarius born during the Age of Aquarius
AutoIt allows me to re-invent the wheel so much faster.

I'm off to write a wizard, a wonderful wizard of odd...


#16 ileandros

ileandros

    Universalist

  • Banned (NOT IN USE)
  • 592 posts

Posted 22 January 2012 - 04:47 PM

Thanks Nutster,

I found what the prob was. Thank to ur help.
I just add this simple
$msgbox
thing and it seems to work fine finally
Case $hButton5 $msgbox = MsgBox (4,"Update", " Check for updates?") if $msgbox = 6 Then gui3() EndIf


As simple as this. I dont know why but adding
$msgbox
solved my prob.
Thank u all for your help :)
I feel nothing.It feels great.

#17 ileandros

ileandros

    Universalist

  • Banned (NOT IN USE)
  • 592 posts

Posted 22 January 2012 - 04:48 PM

As BrewManNH said i was just using the controlID of $hButton5 and not the msgbox that was the prob.
I feel nothing.It feels great.

#18 JohnOne

JohnOne

    John

  • Active Members
  • PipPipPipPipPipPip
  • 11,251 posts

Posted 22 January 2012 - 05:08 PM

Thanks Nutster,

I found what the prob was. Thank to ur help.
I just add this simple

$msgbox
thing and it seems to work fine finally
Case $hButton5 $msgbox = MsgBox (4,"Update", " Check for updates?") if $msgbox = 6 Then gui3() EndIf


As simple as this. I dont know why but adding
$msgbox
solved my prob.
Thank u all for your help :)

That is exactly the same a M23 provided, except the Exit

Case $hButton5     ; Create MsgBox and wait for the user to click a button on the MsgBox     If MsgBox(4, "Update", " Check for updates?") = 6 Then         ; If the "Yes" button was pressed         gui3()     Else         ; In all other cases         Exit     EndIf



#19 ileandros

ileandros

    Universalist

  • Banned (NOT IN USE)
  • 592 posts

Posted 22 January 2012 - 11:32 PM

That is exactly the same a M23 provided, except the Exit


Nah dude. If u check it better u will find the difference.
That is what it makes it work fine :)
I feel nothing.It feels great.

#20 JohnOne

JohnOne

    John

  • Active Members
  • PipPipPipPipPipPip
  • 11,251 posts

Posted 22 January 2012 - 11:37 PM

Are you suggesting MsgBox Returns a different value when a variable is waiting to receive it?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users