Jump to content

xMsgBox


ProgAndy
 Share

Recommended Posts

Some time ago, i found an example in VB on how to chage the names of the Buttons in a MsgBox. Many people want this functionality, so I converted it to AutoIt and here it is:

;### EXAMPLE
#include "CustomMsgBox.au3"
$REturn = xMsgBox(16+0x200,"Title","Text","Butt 1","The 2nd","The3rd",Default,34,"C:\vista.ico")
MsgBox(0, 'ReturnValue:', $REturn)

CustomMsgBox.au3

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

Excellent. Much better than fooling around with other methods.

Looks like this method could also be used with others... InputBox, FileOpenDialog, FileSaveDialog, FileSelectFolder ??

Edited by mrRevoked
Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet()
Link to comment
Share on other sites

Well, i think, that's right :P You just have to know the Control IDs and the change the texts :(

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

  • 5 months later...

Great job ProgAndy!

;===============================================================================
;
; Function Name:   xMsgBox
; Description:: Shows a Message Box with Cutsom Buttons and Optioinal a custom Icon
; Parameter(s): $lFlagType  -> MSgBox Flags
;                 $sPrompt    -> Text
;                 $sTitle      -> Title
;                 $sButtonText1 -> Button1, "" = default Buttons
;                 $sButtonText2 -> Button2, "" = only 1 Button, if Button 1 defined
;                 $sButtonText3 -> Button2, "" = 2 Buttons if Button 1 and 2 defined
;                 $lLeft        -> Left Position of MsgBox
;                 $lTop      -> Top Position of MsgBox
;                 $sIconPath    -> Optional: Path of Icon for MsgBox, Default: Empty
;                 $hwndThreadOwner -> Optional: Handle of owner window
;                 
; Requirement(s):  v3.2.12.0 or higher
; Return Value(s): If no custom ButtonTexts: default MsgBox
;             1 named Button: Closing and Button = 1
;             2 named Buttons: Button1 = 6, Button2 = 7
;             3 named Buttons: Button1 = 6, Button2 = 7, Button3 = 2
;                 For 2 and 3 Buttons: Closing MsgBox = 2 (cancel) [ ! 3rd named Button is the same ! ]
; Author(s):   Prog@ndy 
;
;===============================================================================

Where can I find more help to this code?

:D

Edited by Recce
Link to comment
Share on other sites

  • 5 months later...

Hi

Are you still working on this??

If so, can we have a timeout built in?

ie

$REturn = xMsgBox(16+0x200,"Title","Text","Butt 1","The 2nd","The3rd",Default,34,"C:\vista.ico",10)

would give me a 10 second timeout defaulting to button 1

No, i do'nt work on this anymore.

To add the timeout, simply add $iTimeout = 0 to the parameterlist of the function.

Func xMsgBox($lFlagType, _
    $sTitle, $sPrompt, _
    $sButtonText1 = "" , $sButtonText2 = "" , _
    $sButtonText3 = "" , _
    $lLeft = 0, $lTop = 0, _
    $sIconPath = "", _
    $iTimeout = 0, _
    $hwndThreadOwner = 0)

Then change the following:

$xMsgBox = MsgBox($lButtons, $sTitle,$sPrompt,0,$hWndOwner )
; to
$xMsgBox = MsgBox($lButtons, $sTitle,$sPrompt,$iTimeout,$hWndOwner )
Edited by ProgAndy

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

  • 2 years later...

$msg1 = XMSGBOX(64 + 256, "Permissions Restorer", "Set permissions for: ", "Registry", "Folder", "File")

"Registry" returns = 6

"Folder" returns = 7

"File" returns = 2

When I press the "x" (close) button, it returns value = 2 (the same as the "File"-button).

Is there a way that instead of giving the value of 2, the "x" -button can just straight forward EXIT?

(PS: the FILE and CLOSE (x) now have the same return value of 2....and as thus stuffs around my code :graduated:

thx folks

Link to comment
Share on other sites

You will have to modify the code to use AbortRetryIgnore as the buttons which will be changed instead of YesNoCancel for three buttons. This will require some work, and I'm not in the mood do to it :graduated:

Why don't you try the I'll upload a new release, soon.

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

Error! in code CustomMsgBox.au3

Change.. OnAutoItExitFunction() to OnAutoItExitRegister()

For run script sample

#include "CustomMsgBox.au3"
While 1
$Return = xMsgBox(16+0x200,"Title","Text","Yes","No","Cancel",Default,34,"C:\Program Files\AutoIt3\Icons\au3.ico")
MsgBox(0, 'ReturnValue:', 'ID Button = '&$Return)
If $Return = 2 Then ExitLoop
WEnd

OR

#include "CustomMsgBox.au3"
Do
$Return = xMsgBox(16+0x200,"Title","Text","Yes","No","Cancel",Default,34,"C:\Program Files\AutoIt3\Icons\au3.ico")
MsgBox(0, 'ReturnValue:', 'ID Button = '&$Return)
Until $Return = 2
Edited by Laymanball

My Sample Script

Download: VistaDesktopIconsChangerForXp.au3 (Com,Doc and Bin only) http://www.4shared.com/rar/NMHYL5Igba/VistaDesktopIconsChangerForXp_.html

                     VistaDesktopIconsChangerForXp.exe (Resources) http://www.4shared.com/rar/nzs7Mb1gba/VistaDesktopIconsChangerForXp_.html

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...