Sign in to follow this  
Followers 0
Nerd1337

default positions switch

7 posts in this topic

I want a msgbox that has the yes and no button that are swtiched so that the no button is first and set to default and the yes button second. I have been looking for a way to do this with a msg, but i don't see anything about it.

Share this post


Link to post
Share on other sites



There are no such controls, however you can create your own message box in a gui.

this is a modified version (for your request) from gafrost

#include <GuiConstants.au3>

$main = GUICreate("MyGUI", 392, 322)

$Button_1 = GUICtrlCreateButton("MessageBox", 140, 190, 70, 30)

GUISetState()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $Button_1
            GUISetState(@SW_DISABLE, $main)
            $iMsgBoxAnswer = _MessageBox("Test", "My MessageBox",1)
            GUISetState(@SW_ENABLE, $main)
            GUISetState(@SW_SHOW)
            Select
                Case $iMsgBoxAnswer = 1;OK
                    ConsoleWrite("User selected No" & @LF)
                Case $iMsgBoxAnswer = 2;Cancel
                    ConsoleWrite("User selected Yes" & @LF)
                    
            EndSelect
            
        Case Else
       ;;;
    EndSelect
WEnd
Exit

Func _MessageBox($Title, $Text, $Icon)
    Local $returnValue = 1
    If $Icon < 1 Or $Icon > 4 Then $Icon = 1
    $popup = GUICreate($Title, 191, 130, -1, -1, $WS_DLGFRAME, $WS_EX_TOPMOST)
    GUICtrlCreateIcon(@SystemDir & "\user32.dll",$Icon,10,10,40,40)
    GUICtrlCreateLabel($Text, 60, 10, 180, 60)
    $Btn_OK = GUICtrlCreateButton("No", 40, 70, 60, 20)
    GUICtrlSetState( -1, $GUI_DEFBUTTON)
    $Btn_Cancel = GUICtrlCreateButton("Yes", 110, 70, 60, 20)
    
    GUISetState()
    While 1
        $msg2 = GUIGetMsg()
        Select
            Case $msg2 = $Btn_OK
                ExitLoop
            Case $msg2 == $Btn_Cancel
                $returnValue = 2
                ExitLoop
        EndSelect
    WEnd
    GUIDelete($popup)
    Return $returnValue
EndFunc ;==>_MessageBox

hope it helps

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

be easier to follow if you keep the yes and no in sink with the button names.

#include <GuiConstants.au3>

$main = GUICreate("MyGUI", 392, 322)

$Button_1 = GUICtrlCreateButton("MessageBox", 140, 190, 70, 30)

GUISetState()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $Button_1
            GUISetState(@SW_DISABLE, $main)
            $iMsgBoxAnswer = _MessageBox("Test", "My MessageBox",1)
            GUISetState(@SW_ENABLE, $main)
            GUISetState(@SW_SHOW)
            Select
                Case $iMsgBoxAnswer = 1;OK
                    ConsoleWrite("User selected Yes" & @LF)
                Case $iMsgBoxAnswer = 2;Cancel
                    ConsoleWrite("User selected No" & @LF)
                    
            EndSelect
            
        Case Else
      ;;;
    EndSelect
WEnd
Exit

Func _MessageBox($Title, $Text, $Icon)
    Local $returnValue = 1
    If $Icon < 1 Or $Icon > 4 Then $Icon = 1
    $popup = GUICreate($Title, 191, 130, -1, -1, $WS_DLGFRAME, $WS_EX_TOPMOST)
    GUICtrlCreateIcon(@SystemDir & "\user32.dll",$Icon,10,10,40,40)
    GUICtrlCreateLabel($Text, 60, 10, 180, 60)
    $Btn_Cancel = GUICtrlCreateButton("No", 40, 70, 60, 20)
    GUICtrlSetState( -1, $GUI_DEFBUTTON)
    $Btn_OK = GUICtrlCreateButton("Yes", 110, 70, 60, 20)
    
    GUISetState()
    While 1
        $msg2 = GUIGetMsg()
        Select
            Case $msg2 = $Btn_OK
                ExitLoop
            Case $msg2 == $Btn_Cancel
                $returnValue = 2
                ExitLoop
        EndSelect
    WEnd
    GUIDelete($popup)
    Return $returnValue
EndFunc;==>_MessageBox

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Simple reading of the help-file will show that you can change the default button in a MsgBox with one of the flags. You can't change the order of buttons, of course, nor would you actually want to because it will be confusing. 99% of all Yes/No message boxes a user will see in their lifetime will have "Yes" on the left button and "No" on the right. Do you want to be in the 1% that changes this convention and confuses the user?

Share this post


Link to post
Share on other sites

Yes i want to confuse the user...i want them to stop and read the message box...i want them to read the warning and think about what they are agreeing to. Also, I have read the help file...i was just hoping that there was a way to do it with a msgbox...

thanks for the help guys! :whistle:

Share this post


Link to post
Share on other sites

you could always do it like Microsoft does

1: ask the question

2: ask are you sure

3: ask are you really sure your sure.

etc...


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Yes i want to confuse the user...

Rule #1 of user interaction: Don't confuse the user.

i want them to stop and read the message box...

Rule #2: Don't try to stop them by confusing them.

i want them to read the warning and think about what they are agreeing to.

Rule #3: Don't assume the user has a brain to think with.

Also, I have read the help file...i was just hoping that there was a way to do it with a msgbox...

There's not a way because it's atypical to want to do such a thing.

In case it's not obvious, poor or abnormal user interfaces are a pet peeve of mine. Things should be intuitive to use and also obey the conventions set by predecessors. Deviations from de facto standardized methods lead to more problems than they solve.

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