Jump to content
Melba23

Extended Message Box - New Version: 2 Aug 18

Recommended Posts

It works very Melba!


UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Share this post


Link to post
Share on other sites

guinness,

It works very Melba!

¿Qué? ;):)

M23

Edit: Added the correct Spanish punctuation (because my wife saw it and complained!) And I think I know what you mean, so thanks. :D

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

What is the definition of Melba? Toast? Or maybe it's a 'Jamie Oliver' slang term for 'well.' So the checkbox addition is working very Melba.

Note: You got my point, I simply messed up! :)


UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Share this post


Link to post
Share on other sites

[NEW VERSION] - 26 Dec 11

Added an option to show a "Do not display again" checkbox. If this is checked than the return value is negative allowing you to set a flag within your script. See header for _ExtMsgBoxSet function to see how to add it to the $iStyle parameter - non-scriptbreaking if you do not want to use it. :D

Thanks to Allow2010 for the feature request. :)

New UDF, updated example and zip in first psot. ;)

M23


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

This is nice simple solution to a sticky problem. I have a little ReRun utility that pops up kind of a toolbar. It's lame if the MsgBox pops up in the center of the screen if the toolbar is down near the taskbar. Default style is very easy to use without a lot of reading. :)

Thanks. ;)

Share this post


Link to post
Share on other sites

Melba23,

I just found your _ExtMsgBox

and I have to say that I love it.

it will save me a lot of time :oops:

I have one question : when I use the "Do not show again" I can't seem to get the color of the text correct.. it always in black. and knowing my GUI is a console wrapper and the common background is black... I can't read it.

I stripped the code to leave only the part which is problematic

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include "EXTMSGBOX.AU3"

Global $hGUI = GUICreate('GUI Log', 200, 200)
GUISetBkColor(0x000000)
GUISetState(@SW_SHOW)

$sPause = "Y"
$iFontsize = 12
$sFont = "Arial"

_Pause()


While 1
    Sleep(10)
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd


Func _Pause()
    If StringUpper(StringLeft($sPause, 1)) = 'Y' Then
        ConsoleWrite($sPause)
        _ExtMsgBoxSet(16, 1, 0x000000, 0x00FF00, $iFontsize, $sFont)
        ; IF I CHANGE THE BACKGROUNG COLOR THE "DO NOT SHOW AGAIN" is visible...
        $sMsg = 'PROCESS PAUSED' & @LF & @LF & 'Press on the button or wait for the timeout. Use the checkbox to avoid pausing again'
        $iRetValue = _ExtMsgBox(128, "continue", "Video Conversion", $sMsg, 30, $hGUI)
        If $iRetValue < 0 Then $sPause = 'N'
        _ExtMsgBoxSet(Default)
        ConsoleWrite($sPause)
    EndIf
EndFunc   ;==>_Pause

did I miss something ?

Thanks in advance,

R

Share this post


Link to post
Share on other sites

ok,

I figured it out.

thanks to another topic on which you already gave the answer :oops:

I slightly modified

; Create checkbox if required
    If BitAND($iEMB_Style, 16) Then
        $hCheckbox = GUICtrlCreateCheckbox(" Do not show again", 10 + $iIcon_Reduction, $iLabel_Vert + $iLabel_Height + 10, $iMsg_Width - (10 + $iIcon_Reduction), 20)
        ; Set font if required
        If Not BitAND($iEMB_Style, 4) Then GUICtrlSetFont(-1, $iEMB_Font_Size, 400, 0, $sEMB_Font_Name)
;################
       ;modif
        If $iEMB_Col <> Default Then
            DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($hCheckbox), "wstr", 0, "wstr", 0)
            GUICtrlSetColor(-1, $iEMB_Col)
        EndIf
        ;end modif
;################
    EndIf

seriously these functions are sweet.

R

Edited by redia

Share this post


Link to post
Share on other sites

redia,

You missed nothing. The checkbox control can only have coloured text when you remove the theme - which renders the checkbox itself as a flat, boring square - so it is currently black text only. I will amend the UDF to use a label with the same text colour as the rest of the GUI and then post a new version. Thanks for the report. :oops:

M23

Edit: I was called away to dinner and I missed your last post - I see you already know what I just told you. But I will still modify the UDF so look out for a new version soon. :bye:

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

redia,

You missed nothing. The checkbox control can only have coloured text when you remove the theme - which renders the checkbox itself as a flat, boring square - so it is currently black text only. I will amend the UDF to use a label with the same text colour as the rest of the GUI and then post a new version. Thanks for the report. :oops:

yup, you are 100% right and it makes sense.

until you release a new udf I will use my small tweak

if you like reports, I have another thing that I faced while using your udf.

when I use a long term, and/or big fonts the text does not fit in the button.

maybe you can have the button's size grow/shrink depending on its content.

thanks again for this. I will keep an eye for your updates.

Cheers,

R

Edited by redia

Share this post


Link to post
Share on other sites

redia,

when I use a long term, and/or big fonts the text does not fit in the button. maybe you can have the button's size grow/shrink depending on its content

That has been suggested before and the answer is "No" because it would make the size of the GUI to hold the buttons too difficult to calculate. The solution I came up with was to use the $iStyle parameter of _ExtMsgBox_Set as it explains in the function header:

; Parameters ....: $iStyle      -> 0 (Default) - Taskbar Button, TOPMOST, button in user font, no tab expansion, no checkbox
;                                  Combine following to change:
;                                   1  = Button does not appear on TaskBar
;                                   2  = TOPMOST Style not set
;                                   4  = Buttons use default font

So add 4 to that parameter value (i.e. make it 20 in your case) and you get both the button text and the checkbox text in the default font and size. The current beta I am working on will set the colour of the checkbox text to that of the main text - the buttons will remain uncoloured as there is a bug deep in the AutoIt code that really does not like coloured buttons. :bye:

The new version should be ready tomorrow after I have tested it some more - check back then and see if you like it. :oops:

M23


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

redia,

Try this beta version to see if it meets your needs. As I explained above, the checkbox font colour is now set by the main text colour so you should always see it - its size, along with that of the button text, is determined by the $iStyle parameter, And the checkbox remains its normal self and not the flat 2D version: :oops:

See released version in first post.

Any comments from other readers would also be welcome. :bye:

M23

Edit: Beta code removed

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

[NEW VERSION] 28 Feb 12

The "Do not display again" checkbox text remained in the system default colour (usually black) which meant that it became invisible if the ExtMsgBox had a dark background. Code changed so that the text is now in the same colour as the main text and so always visible when used.

Thanks to redia for the report. :oops:

New UDF and zip in the first post. :bye:

M23


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

VasiliyRS,

In a compiled script, if you set the $hWin parameter to another GUI handle, the ExtMsgBox uses the icon of that GUI in its title bar. If you do not specify a GUI in that parameter, then the ExtMsgBox uses the ever-present but hidden AutoIt GUI as a parent and so displays the AutoIt icon. :bye:

I am not sure that I can create a title bar without an icon (i.e with the title starting right at the left edge) but I can certainly code the UDF so that you get a blank icon like this: :doh:

Would that do? :oops:

M23


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

In a compiled script, if you set the $hWin parameter to another GUI handle, the ExtMsgBox uses the icon of that GUI in its title bar. If you do not specify a GUI in that parameter, then the ExtMsgBox uses the ever-present but hidden AutoIt GUI as a parent and so displays the AutoIt icon.

I use
$hGui = GUICreate('test', 500, 300)
GUISetIcon("C:\Windows\System32\imageres.dll", -76)
for my main gui but if i set

_ExtMsgBox ($MB_ICONEXCLAMATION, "ok", "bla-bla", $sMsg, 0, $hGui)
i still get autoit icon in a title bar, did i miss something?

Share this post


Link to post
Share on other sites

VasiliyRS,

To the best of my knowledge, using GUISetIcon only changes the icon for that particular GUI and does not not add the icon to the program resources. So when you set the GUI as the parernt to the ExtMsgBox, it still looks for the first icon in the resource table which is unchanged. If you add the following line to the top of your script you reset the icon used by all the GUIs and child dialogs of the program:

#AutoIt3Wrapper_Icon=Full_Path_Of_The_Icon.ico

When I do that I get the required icon in the ExtMsgBox - when I use GUISetIcon I do not. :bye:

But if you want no icon at all - try this beta version. If you create the ExtMsgBox with no parent and set the horizontal coordinate to a negative value, the ExtMsgBox will use the Absolute value of the coordinate, but will not have an icon:

#include-once

; #INDEX# ============================================================================================================
; Title .........: ExtMsgBox
; AutoIt Version : v3.2.12.1 or higher
; Language ......: English
; Description ...: Generates user defined message boxes centred on an owner, on screen or at defined coordinates
; Remarks .......:
; Note ..........:
; Author(s) .....: Melba23, based on some original code by photonbuddy & YellowLab, and KaFu (default font data)
; ====================================================================================================================

;#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7

; #INCLUDES# =========================================================================================================
#include "StringSize.au3"

; #GLOBAL CONSTANTS# =================================================================================================
Global Const $MB_ICONSTOP   = 16 ; Stop-sign icon
Global Const $MB_ICONQUERY  = 32 ; Question-mark icon
Global Const $MB_ICONEXCLAM = 48 ; Exclamation-point icon
Global Const $MB_ICONINFO   = 64 ; Icon consisting of an 'i' in a circle

; #GLOBAL VARIABLES# =================================================================================================
; Default settings
Global $aEMB_FontData = _GetDefaultEMBFont()
Global $iDef_EMB_Font_Size = $aEMB_FontData[0]
Global $sDef_EMB_Font_Name = $aEMB_FontData[1]
$aEMB_FontData = 0
Global $iDef_EMB_BkCol = DllCall("User32.dll", "int", "GetSysColor", "int", 15) ; $COLOR_3DFACE = 15
$iDef_EMB_BkCol = BitAND(BitShift(String(Binary($iDef_EMB_BkCol[0])), 8), 0xFFFFFF)
Global $iDef_EMB_Col   = DllCall("User32.dll", "int", "GetSysColor", "int", 8) ; $COLOR_WINDOWTEXT = 8
$iDef_EMB_Col = BitAND(BitShift(String(Binary($iDef_EMB_Col[0])), 8), 0xFFFFFF)
; Current settings
Global $iEMB_Style = 0
Global $iEMB_Just  = 0
Global $iEMB_BkCol = $iDef_EMB_BkCol
Global $iEMB_Col   = $iDef_EMB_Col
Global $sEMB_Font_Name = $sDef_EMB_Font_Name
Global $iEMB_Font_Size = $iDef_EMB_Font_Size

; #CURRENT# ==========================================================================================================
; _ExtMsgBoxSet: Sets the GUI style, justification, colours and font for subsequent _ExtMsgBox function calls
; _ExtMsgBox:    Generates user defined message boxes centred on an owner, on screen or at defined coordinates
; ====================================================================================================================

; #INTERNAL_USE_ONLY#=================================================================================================
; _GetDefaultEMBFont: Determines Windows default MsgBox font size and name
; ====================================================================================================================

; #FUNCTION# =========================================================================================================
; Name...........: _ExtMsgBoxSet
; Description ...: Sets the GUI style, justification, colours and font for subsequent _ExtMsgBox function calls
; Syntax.........: _ExtMsgBoxSet($iStyle, $iJust, [$iBkCol, [$iCol, [$sFont_Size, [$iFont_Name]]]])
; Parameters ....: $iStyle      -> 0 (Default) - Taskbar Button, TOPMOST, button in user font, no tab expansion, no checkbox
;                                  Combine following to change:
;                                   1  = Button does not appear on TaskBar
;                                   2  = TOPMOST Style not set
;                                   4  = Buttons use default font
;                                   8  = Expand Tabs to ensure adequate sizing of GUI
;                                   16 = "Do not display again" checkbox
;                   >>>>>>>>>>     Setting this parameter to 'Default' will reset ALL parameters to default values <<<<
;                  $iJust       -> 0 = Left justified (Default), 1 = Centred , 2 = Right justified
;                                  + 4 = Centred single button.  Note: multiple buttons are always centred
;                                  ($SS_LEFT, $SS_CENTER, $SS_RIGHT can also be used)
;                   $iBkCol     -> The colour for the message box background.  Default = system colour
;                   $iCol       -> The colour for the message box text.  Default = system colour
;                                  Omitting a colour parameter or setting -1 leaves it unchanged
;                                  Setting a colour parameter to Default resets the system message box colour
;                   $iFont_Size -> The font size in points to use for the message box. Default = system font size
;                   $sFont_Name -> The font to use for the message box. Default = system font
;                                  Omitting a font parameter or setting font size to -1 or font name to "" = unchanged
;                                  Setting a font parameter to Default resets the system message box font and size
; Requirement(s).: v3.2.12.1 or higher
; Return values .: Success - Returns 1
;                  Failure - Returns 0 and sets @error to 1 with @extended set to parameter index number
; Remarks .......;
; Author ........: Melba23
; Example........; Yes
;=====================================================================================================================
Func _ExtMsgBoxSet($iStyle = 0, $iJust = 0, $iBkCol = -1, $iCol = -1, $iFont_Size = -1, $sFont_Name = "")

    ; Set global EMB variables to required values
    Switch $iStyle
        Case Default
            $iEMB_Style = 0 ; Button on TaskBar and $WS_EX_TOPMOST
            $iEMB_Just = 0 ; $SS_LEFT
            $iEMB_BkCol = $iDef_EMB_BkCol
            $iEMB_Col = $iDef_EMB_Col
            $sEMB_Font_Name = $sDef_EMB_Font_Name
            $iEMB_Font_Size = $iDef_EMB_Font_Size
            Return
        Case 0 To 31
            $iEMB_Style = $iStyle
        Case Else
            Return SetError(1, 1, 0)
    EndSwitch

    Switch $iJust
        Case 0, 1, 2, 4, 5, 6
            $iEMB_Just = $iJust
        Case Else
            Return SetError(1, 2, 0)
    EndSwitch

    Switch $iBkCol
        Case Default
            $iEMB_BkCol = $iDef_EMB_BkCol
        Case -1
            ; Do nothing
        Case 0 To 0xFFFFFF
            $iEMB_BkCol = $iBkCol
        Case Else
            Return SetError(1, 3, 0)
    EndSwitch

    Switch $iCol
        Case Default
            $iEMB_Col = $iDef_EMB_Col
        Case -1
            ; Do nothing
        Case 0 To 0xFFFFFF
            $iEMB_Col = $iCol
        Case Else
            Return SetError(1, 4, 0)
    EndSwitch

    Switch $iFont_Size
        Case Default
            $iEMB_Font_Size = $iDef_EMB_Font_Size
        Case 8 To 72
            $iEMB_Font_Size = Int($iFont_Size)
        Case -1
            ; Do nothing
        Case Else
            Return SetError(1, 5, 0)
    EndSwitch

    Switch $sFont_Name
        Case Default
            $sEMB_Font_Name = $sDef_EMB_Font_Name
        Case ""
            ; Do nothing
        Case Else
            If IsString($sFont_Name) Then
                $sEMB_Font_Name = $sFont_Name
            Else
                Return SetError(1, 6, 0)
            EndIf
    EndSwitch

    Return 1

EndFunc

; #FUNCTION# =========================================================================================================
; Name...........: _ExtMsgBox
; Description ...: Generates user defined message boxes centred on an owner, on screen or at defined coordinates
; Syntax.........: _ExtMsgBox ($vIcon, $vButton, $sTitle, $sText, [$iTimeout, [$hWin, [$iVPos]]])
; Parameters ....: $vIcon       -> The icon to use: 0 - No icon, 8 - UAC, or a $MB_ICON constant as follows
;                                  16 - Stop, 32 - Query, 48 - Exclamation, 64 - Information
;                                  128 - Countdown if $iTimeout set
;                                  Any other numeric value returns -1, error 1
;                                  If set to the name of an exe, the main icon of that exe will be displayed
;                                  If set to the name of an icon, the icon will be displayed
;                   $vButton    -> Button text separated with "|" character.
;                                  An ampersand (&) before the text indicates the default button.
;                                  Two focus ampersands returns -1, error 2. A single button is always default
;                                  Pressing Enter or Space fires default button
;                                  Can also use $MB_ button numeric constants: 0 = "OK", 1 = "&OK|Cancel",
;                                  2 = "&Abort|Retry|Ignore", 3 = "&Yes|No|Cancel", 4 = "&Yes|No", 5 = "&Retry|Cancel",
;                                  6 = "&Cancel|Try Again|Continue".  Other values return -1, error 3
;                                  Default max width of 370 gives 1-4 buttons @ width 80, 5 @ width 60, 6 @ width 50
;                                  Min button width set at 50, so unless default changed 7 buttons returns -1, error 4
;                   $sTitle     -> The title of the message box
;                   $sText      -> The text to be displayed. Long lines will wrap. The box depth is adjusted to fit
;                                  The preset max width can increase to a preset absolute value if required
;                   $iTimeout   -> Timeout delay before EMB closes. 0 = no timeout (Default)
;                   $hWin       -> Handle of the window in which EMB is centred
;                                  If window is hidden or no handle passed EMB centred in display (Default)
;                                  If parameter does not hold valid window handle, it is interpreted as horizontal
;                                  coordinate for EMB location
;                   $iVPos      -> Vertical coordinate for EMB location, only if $hWin parameter is
;                                  interpreted as horizontal coordinate.  (Default = 0)
; Requirement(s).: v3.2.12.1 or higher
; Return values .: Success: Returns 1-based index of the button pressed, counting from the LEFT.
;                           Returns 0 if closed by a "CloseGUI" event (i.e. click [X] or press Escape)
;                           Returns 9 if timed out
;                           If "Not again" checkbox is present and checked, return value is negated
;                  Failure: Returns -1 and sets @error as follows:
;                               1 - Icon error
;                               2 - Multiple default button error
;                               3 - Button constant error
;                               4 - Too many buttons to fit max GUI size
;                               5 - StringSize error
;                               6 - GUI creation error
; Remarks .......; EMB position automatically adjusted to appear on screen
; Author ........: Melba23, based on some original code by photonbuddy & YellowLab
; Example........; Yes
;=====================================================================================================================
Func _ExtMsgBox($vIcon, $vButton, $sTitle, $sText, $iTimeout = 0, $hWin = "", $iVPos = 0)

    Local $iParent_Win = 0, $fCountdown = False, $cCheckbox, $aLabel_Size

    Local $nOldOpt = Opt('GUIOnEventMode', 0)

    ; Set default sizes for message box
    Local $iMsg_Width_max = 370, $iMsg_Width_min = 150, $iMsg_Width_abs = 500
    Local $iMsg_Height_min = 100
    Local $iButton_Width_max = 80, $iButton_Width_min = 50

    ; Declare local variables
    Local $iButton_Width_Req, $iButton_Width, $iButton_Xpos, $iRet_Value, $iHpos

    ;; Check for icon
    Local $iIcon_Style = 0
    Local $iIcon_Reduction = 50
    Local $sDLL = "user32.dll"
    If StringIsDigit($vIcon) Then
        Switch $vIcon
            Case 0
                $iIcon_Reduction = 0
            Case 8
                $sDLL = "imageres.dll"
                $iIcon_Style = 78
            Case 16 ; Stop
                $iIcon_Style = -4
            Case 32 ; Query
                $iIcon_Style = -3
            Case 48 ; Exclam
                $iIcon_Style = -2
            Case 64 ; Info
                $iIcon_Style = -5
            Case 128 ; Countdown
                If $iTimeout > 0 Then
                    $fCountdown = True
                Else
                    ContinueCase
                EndIf
            Case Else
                $nOldOpt = Opt('GUIOnEventMode', $nOldOpt)
                Return SetError(1, 0, -1)
        EndSwitch
    Else
        $sDLL = $vIcon
        $iIcon_Style = 0
    EndIf

    ; Check if two buttons are seeking focus
    StringRegExpReplace($vButton, "((?<!&)&)(?!&)", "*")
    If @extended > 1 Then
        $nOldOpt = Opt('GUIOnEventMode', $nOldOpt)
        Return SetError(2, 0, -1)
    EndIf

    ; Check if using constants or text
    If IsNumber($vButton) Then
        Switch $vButton
            Case 0
                $vButton = "OK"
            Case 1
                $vButton = "&OK|Cancel"
            Case 2
                $vButton = "&Abort|Retry|Ignore"
            Case 3
                $vButton = "&Yes|No|Cancel"
            Case 4
                $vButton = "&Yes|No"
            Case 5
                $vButton = "&Retry|Cancel"
            Case 6
                $vButton = "&Cancel|Try Again|Continue"
            Case Else
                $nOldOpt = Opt('GUIOnEventMode', $nOldOpt)
                Return SetError(3, 0, -1)
        EndSwitch
    EndIf

    ; Set tab expansion flag if required
    Local $iExpTab = Default
    If BitAnd($iEMB_Style, 8) Then
        $iExpTab = 1
    EndIf

    ; Get message label size
    While 1
        Local $aLabel_Pos = _StringSize($sText, $iEMB_Font_Size, Default, $iExpTab, $sEMB_Font_Name, $iMsg_Width_max - 20 - $iIcon_Reduction)
        If @error Then
            If $iMsg_Width_max = $iMsg_Width_abs Then
                $nOldOpt = Opt('GUIOnEventMode', $nOldOpt)
                Return SetError(5, 0, -1)
            Else
                $iMsg_Width_max += 10
            EndIf
        Else
            ExitLoop
        EndIf
    WEnd

    ; Reset text to wrapped version
    $sText = $aLabel_Pos[0]

    ; Get individual button text
    Local $aButtons = StringSplit($vButton, "|")
    ; Get minimum GUI width needed for buttons
    Local $iMsg_Width_Button = ($iButton_Width_max + 10) * $aButtons[0] + 10
    ; If shorter than min width
    If $iMsg_Width_Button < $iMsg_Width_min Then
        ; Set buttons to max size and leave box min width unchanged
        $iButton_Width = $iButton_Width_max
    Else
        ; Check button width needed to fit within max box width
        $iButton_Width_Req = ($iMsg_Width_max - (($aButtons[0] + 1) * 10)) / $aButtons[0]
        ; Button width less than min button width permitted
        If $iButton_Width_Req < $iButton_Width_min Then
            $nOldOpt = Opt('GUIOnEventMode', $nOldOpt)
            Return SetError(4, 0, -1)
            ; Buttons only need resizing to fit
        ElseIf $iButton_Width_Req < $iButton_Width_max Then
            ; Set box to max width and set button size as required
            $iMsg_Width_Button = $iMsg_Width_max
            $iButton_Width = $iButton_Width_Req
            ; Buttons can be max size
        Else
            ; Set box min width to fit buttons
            $iButton_Width = $iButton_Width_max
            $iMsg_Width_min = $iMsg_Width_Button
        EndIf
    EndIf
    ; Determine final button width required
    $iButton_Width_Req = Int((($iButton_Width + 10) * $aButtons[0]) + 10)

    ; Set label size
    Local $iLabel_Width = $aLabel_Pos[2]
    Local $iLabel_Height = $aLabel_Pos[3]
    ; Set GUI size
    Local $iMsg_Width = $iLabel_Width + 20 + $iIcon_Reduction
    ; Increase width to fit buttons if needed
    If $iButton_Width_Req > $iMsg_Width Then $iMsg_Width = $iButton_Width_Req
    If $iMsg_Width < $iMsg_Width_min Then
        $iMsg_Width = $iMsg_Width_min
        $iLabel_Width = $iMsg_Width_min - 20
    EndIf
    Local $iMsg_Height = $iLabel_Height + 65
    ; Increase height if checkbox required
    If BitAnd($iEMB_Style, 16) Then
        $iMsg_Height += 40
    EndIf
    If $iMsg_Height < $iMsg_Height_min Then $iMsg_Height = $iMsg_Height_min

    ; If only single line, lower label to to centre text on icon
    Local $iLabel_Vert = 20
    If StringInStr($sText, @CRLF) = 0 Then $iLabel_Vert = 27

    ; Check for taskbar button style required
    If Mod($iEMB_Style, 2) = 1 Then ; Hide taskbar button so create as child
        If IsHWnd($hWin) Then
            $iParent_Win = $hWin ; Make child of that window
        Else
            $iParent_Win = WinGetHandle(AutoItWinGetTitle()) ; Make child of AutoIt window
        EndIf
    EndIf

    ; Determine EMB location
    If $hWin = "" Then
        ; No handle or position passed so centre on screen
        $iHpos = (@DesktopWidth - $iMsg_Width) / 2
        $iVPos = (@DesktopHeight - $iMsg_Height) / 2
    Else
        If IsHWnd($hWin) Then
            ; Get parent GUI pos if visible
            If BitAND(WinGetState($hWin), 2) Then
                ; Set EMB to centre on parent
                Local $aPos = WinGetPos($hWin)
                $iHpos = ($aPos[2] - $iMsg_Width) / 2 + $aPos[0] - 3
                $iVPos = ($aPos[3] - $iMsg_Height) / 2 + $aPos[1] - 20
            Else
                ; Set EMB to centre om screen
                $iHpos = (@DesktopWidth - $iMsg_Width) / 2
                $iVPos = (@DesktopHeight - $iMsg_Height) / 2
            EndIf
        Else
            ; Assume parameter is horizontal coord
            $iHpos = Abs($hWin) ; $iVpos already set
        EndIf
    EndIf

    ; Now check to make sure GUI is visible on screen
    ; First horizontally
    If $iHpos < 10 Then $iHpos = 10
    If $iHpos + $iMsg_Width > @DesktopWidth - 20 Then $iHpos = @DesktopWidth - 20 - $iMsg_Width
    ; Then vertically
    If $iVPos < 10 Then $iVPos = 10
    If $iVPos + $iMsg_Height > @DesktopHeight - 60 Then $iVPos = @DesktopHeight - 60 - $iMsg_Height

    ; Remove TOPMOST extended style if required
    Local $iExtStyle = 0x00000008 ; $WS_TOPMOST
    If BitAnd($iEMB_Style, 2) Then $iExtStyle = -1

    ; Create GUI with $WS_POPUPWINDOW, $WS_CAPTION style and required extended style
    Local $hMsgGUI = GUICreate($sTitle, $iMsg_Width, $iMsg_Height, $iHpos, $iVPos, BitOR(0x80880000, 0x00C00000), $iExtStyle, $iParent_Win)
    If @error Then
        $nOldOpt = Opt('GUIOnEventMode', $nOldOpt)
        Return SetError(6, 0, -1)
    EndIf
    ; Check if icon is to be hidden
    If $hWin < 0 Then
        GUISetIcon(@AutoItExe, -2, $hMsgGUI)
    EndIf
    If $iEMB_BkCol <> Default Then GUISetBkColor($iEMB_BkCol)

    ; Set centring parameter
    Local $iLabel_Style = 0 ; $SS_LEFT
    If BitAND($iEMB_Just, 1) = 1 Then
        $iLabel_Style = 1 ; $SS_CENTER
    ElseIf BitAND($iEMB_Just, 2) = 2 Then
        $iLabel_Style = 2 ; $SS_RIGHT
    EndIf

    ; Create label
    GUICtrlCreateLabel($sText, 10 + $iIcon_Reduction, $iLabel_Vert, $iLabel_Width, $iLabel_Height, $iLabel_Style)
    GUICtrlSetFont(-1, $iEMB_Font_Size, Default, Default, $sEMB_Font_Name)
    If $iEMB_Col <> Default Then GUICtrlSetColor(-1, $iEMB_Col)

    ; Create checkbox if required
    If BitAnd($iEMB_Style, 16) Then
        Local $sAgain = " Do not show again"
        Local $iY = $iLabel_Vert + $iLabel_Height + 10
        ; Create checkbox
        $cCheckbox = GUICtrlCreateCheckbox("", 10 + $iIcon_Reduction, $iY, 20, 20)
        ; Write text in separate checkbox label
        Local $cCheckLabel = GUICtrlCreateLabel($sAgain, 20, 20, 20, 20)
        GUICtrlSetColor($cCheckLabel, $iEMB_Col)
        GUICtrlSetBkColor($cCheckLabel, $iEMB_BkCol)
        ; Set font if required and size checkbox label text
        If BitAnd($iEMB_Style, 4) Then
            $aLabel_Size = _StringSize($sAgain)
        Else
            $aLabel_Size = _StringSize($sAgain, $iEMB_Font_Size, 400, 0, $sEMB_Font_Name)
            GUICtrlSetFont($cCheckLabel, $iEMB_Font_Size, 400, 0, $sEMB_Font_Name)
        EndIf
        ; Move and resize checkbox label to fit
        $iY = ($iY + 10) - ($aLabel_Size[3] - 4) / 2
        ControlMove($hMsgGUI, "", $cCheckLabel, 30 + $iIcon_Reduction, $iY, $iMsg_Width - (30 + $iIcon_Reduction), $aLabel_Size[3])
    EndIf

    ; Create icon or countdown timer
    If $fCountdown = True Then
        Local $cCountdown_Label = GUICtrlCreateLabel(StringFormat("%2s", $iTimeout), 10, 20, 32, 32)
        GUICtrlSetFont(-1, 18, Default, Default, $sEMB_Font_Name)
        GUICtrlSetColor(-1, $iEMB_Col)
    Else
        If $iIcon_Reduction Then GUICtrlCreateIcon($sDLL, $iIcon_Style, 10, 20)
    EndIf

    ; Create dummy control for Accel key
    Local $cAccel_Key = GUICtrlCreateDummy()
    ; Set Space key as Accel key
    Local $aAccel_Key[1][2]=[["{SPACE}", $cAccel_Key]]
    GUISetAccelerators($aAccel_Key)

    ; Create buttons
    ; Calculate button horizontal start
    If $aButtons[0] = 1 Then
        If BitAND($iEMB_Just, 4) = 4 Then
            ; Single centred button
            $iButton_Xpos = ($iMsg_Width - $iButton_Width) / 2
        Else
            ; Single offset button
            $iButton_Xpos = $iMsg_Width - $iButton_Width - 10
        EndIf
    Else
        ; Multiple centred buttons
        $iButton_Xpos = 10 + ($iMsg_Width - $iMsg_Width_Button) / 2
    EndIf
    ; Set default button code
    Local $iDefButton_Code = 0
    ; Set default button style
    Local $iDef_Button_Style = 0
    ; Work through button list
    For $i = 0 To $aButtons[0] - 1
        Local $iButton_Text = $aButtons[$i + 1]
        ; Set default button
        If $aButtons[0] = 1 Then ; Only 1 button
            $iDef_Button_Style = 0x0001
        ElseIf StringLeft($iButton_Text, 1) = "&" Then ; Look for &
            $iDef_Button_Style = 0x0001
            $aButtons[$i + 1] = StringTrimLeft($iButton_Text, 1)
            ; Set default button code for Accel key return
            $iDefButton_Code = $i + 1
        EndIf
        ; Draw button
        GUICtrlCreateButton($aButtons[$i + 1], $iButton_Xpos + ($i * ($iButton_Width + 10)), $iMsg_Height - 35, $iButton_Width, 25, $iDef_Button_Style)
        ; Set font if required
        If Not BitAnd($iEMB_Style, 4) Then GUICtrlSetFont(-1, $iEMB_Font_Size, 400, 0, $sEMB_Font_Name)
        ; Reset default style parameter
        $iDef_Button_Style = 0
    Next

    ; Show GUI
    GUISetState(@SW_SHOW, $hMsgGUI)

    ; Begin timeout counter
    Local $iTimeout_Begin = TimerInit()
    Local $iCounter = 0

    ; Much faster to declare GUIGetMsg return array here and not in loop
    Local $aMsg

    While 1
        $aMsg = GUIGetMsg(1)

        If $aMsg[1] = $hMsgGUI Then
            Select
                Case $aMsg[0] = -3 ; $GUI_EVENT_CLOSE
                    $iRet_Value = 0
                    ExitLoop
                Case $aMsg[0] = $cAccel_Key
                    ; Accel key pressed so return default button code
                    If $iDefButton_Code Then
                        $iRet_Value = $iDefButton_Code
                        ExitLoop
                    EndIf
                Case $aMsg[0] > $cAccel_Key
                    ; Button handle minus Accel key handle will give button index
                    $iRet_Value = $aMsg[0] - $cAccel_Key
                    ExitLoop
            EndSelect
        EndIf

        ; Timeout if required
        If TimerDiff($iTimeout_Begin) / 1000 >= $iTimeout And $iTimeout > 0 Then
            $iRet_Value = 9
            ExitLoop
        EndIf

        ; Show countdown if required
        If $fCountdown = True Then
            Local $iTimeRun = Int(TimerDiff($iTimeout_Begin) /1000)
            If $iTimeRun <> $iCounter Then
                $iCounter = $iTimeRun
                GUICtrlSetData($cCountdown_Label, StringFormat("%2s", $iTimeout - $iCounter))
            EndIf
        EndIf

    WEnd

    $nOldOpt = Opt('GUIOnEventMode', $nOldOpt)

    If GUICtrlRead($cCheckbox) = 1 Then
        ; Negate the return value
        $iRet_Value *= -1
    EndIf

    GUIDelete($hMsgGUI)

    Return $iRet_Value

EndFunc   ;==>_ExtMsgBox

; #INTERNAL_USE_ONLY#============================================================================================================
; Name...........: _GetDefaultEMBFont
; Description ...: Determines Windows default MsgBox font size and name
; Syntax.........: _GetDefaultEMBFont()
; Return values .: Success - Array holding determined font data
;                : Failure - Array holding default values
;                  Array elements - [0] = Size, [1] = Weight, [2] = Style, [3] = Name, [4] = Quality
; Author ........: KaFu
; Remarks .......: Used internally by ExtMsgBox UDF
; ===============================================================================================================================
Func _GetDefaultEMBFont()

    ; Fill array with standard default data
    Local $aDefFontData[2] = [9, "Tahoma"]

    ; Get AutoIt GUI handle
    Local $hWnd = WinGetHandle(AutoItWinGetTitle())
    ; Open Theme DLL
    Local $hThemeDLL = DllOpen("uxtheme.dll")
    ; Get default theme handle
    Local $hTheme = DllCall($hThemeDLL, 'ptr', 'OpenThemeData', 'hwnd', $hWnd, 'wstr', "Static")
    If @error Then Return $aDefFontData
    $hTheme = $hTheme[0]
    ; Create LOGFONT structure
    Local $tFont = DllStructCreate("long;long;long;long;long;byte;byte;byte;byte;byte;byte;byte;byte;wchar[32]")
    Local $pFont = DllStructGetPtr($tFont)
    ; Get MsgBox font from theme
    DllCall($hThemeDLL, 'long', 'GetThemeSysFont', 'HANDLE', $hTheme, 'int', 805, 'ptr', $pFont) ; TMT_MSGBOXFONT
    If @error Then Return $aDefFontData
    ; Get default DC
    Local $hDC = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hWnd)
    If @error Then Return $aDefFontData
    $hDC = $hDC[0]
    ; Get font vertical size
    Local $iPixel_Y = DllCall("gdi32.dll", "int", "GetDeviceCaps", "handle", $hDC, "int", 90) ; LOGPIXELSY
    If Not @error Then
        $iPixel_Y = $iPixel_Y[0]
        $aDefFontData[0] = Int(2 * (.25 - DllStructGetData($tFont, 1) * 72 / $iPixel_Y)) / 2
    EndIf
    ; Close DC
    DllCall("user32.dll", "int", "ReleaseDC", "hwnd", $hWnd, "handle", $hDC)
    ; Extract font data from LOGFONT structure
    $aDefFontData[1] = DllStructGetData($tFont, 14)

    Return $aDefFontData

EndFunc ;=>_GetDefaultEMBFont

If you run this example and try "Test 5" you will see the result:

; ExtMsgBox Example

#include <GUIConstantsEx.au3>
#include <Constants.au3>
#include <StaticConstants.au3>

#include "ExtMsgBox_Mod.au3"

; Set a flag to repeat Test 5
$fAgain = True

$hTest_GUI = GUICreate("EMB Test",200, 460, 100, 100)
$hButton1 = GUICtrlCreateButton("Test 1", 20, 20, 60, 30)
$hButton2 = GUICtrlCreateButton("Test 2", 120, 20, 60, 30)
$hButton3 = GUICtrlCreateButton("Test 3", 20, 70, 60, 30)
$hButton4 = GUICtrlCreateButton("Test 4", 120, 70, 60, 30)
$hButton5 = GUICtrlCreateButton("Test 5", 20, 120, 60, 30)
$hButton6 = GUICtrlCreateButton("Test 6", 120, 120, 60, 30)
$hButton7 = GUICtrlCreateButton("Exit", 70, 420, 60, 30)

$sMsg  = "Move this window around the screen to see some of the child windows centre themselves upon it "
$sMsg &= "when they display." & @CRLF & @CRLF
$sMsg &= "If you place the window too close to the edge of the screen, the child windows will "
$sMsg &= "adjust their position automatically to prevent being partially hidden."
If @Compiled = 0 Then $sMsg &= @CRLF & @CRLF & "Look in the SciTE console to see the return values as buttons are pressed"

GUICtrlCreateLabel($sMsg, 10, 160, 180, 240, $SS_CENTER)
    GUICtrlSetFont(-1, 10)
GUISetState(@SW_SHOW, $hTest_GUI)

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $hButton7

            _ExtMsgBoxSet(1)
            $nTest = _ExtMsgBox(32, "Yes|&No", "Query", "Are you sure?", 0, $hTest_GUI)
            _ExtMsgBoxSet(Default)
            ConsoleWrite("The 'Exit' EMB returned: " & $nTest & @CRLF)
            If $nTest = 1 Then Exit

        Case $hButton1

            ; Set the centred value and font size, leaving colours unchanged
            _ExtMsgBoxSet(2, $SS_CENTER, -1, -1, 9)

            $sMsg =  "This is centred on 'EMB Test' with the AutoIt icon, 4 buttons, centred text,a Taskbar button and TOPMOST not set" & @CRLF & @CRLF
            $sMsg &= "The width is set to maximum by the requirement for 4 buttons and the text will wrap if required to fit in" & @CRLF & @CRLF
            $sMsg &= "Button 4 is set as default and will action on 'Enter' or 'Space'" & @CRLF & @CRLF
            $sMsg &= "It will not time out"
            $iRetValue = _ExtMsgBox (@AutoItExe, "1|2|3|&4", "Test 1", $sMsg, 20, $hTest_GUI)
            ConsoleWrite("Test 1 returned: " & $iRetValue & @CRLF)

            ; Reset to default
            _ExtMsgBoxSet(Default)

        Case $hButton2

            ; Hide the main GUI to centre the message box on screen
            GUISetState(@SW_HIDE, $hTest_GUI)

            ; Change font and justification, leaving colours unchanged
            _ExtMsgBoxSet(5, $SS_LEFT, -1, -1, 12, "Arial")

            $sMsg = "As 'EMB Test' is hidden, this is centred on screen" & @CRLF & @CRLF
            $sMsg &= "It has:" & @CRLF
            $sMsg &= @TAB & "An Info icon," & @CRLF
            $sMsg &= @TAB & "1 offset button"  & @CRLF
            $sMsg &= @TAB & "Left justified text," & @CRLF
            $sMsg &= @TAB & "Default button text," & @CRLF
            $sMsg &= @TAB & "No Taskbar button and " & @CRLF
            $sMsg &= @TAB & "TOPMOST set" & @CRLF& @CRLF
            $sMsg &= "The width is set by the maximum line length" & @CRLF & @CRLF
            $sMsg &= "(which is less than max message box width)" & @CRLF & @CRLF
            $sMsg &= "It will time out in 20 seconds"

            ; Use $MB_ constants and set timeout value
            $iRetValue = _ExtMsgBox ($MB_ICONASTERISK, "Default Font", "Test 2", $sMsg, 20, $hTest_GUI)
            ConsoleWrite("Test 2 returned: " & $iRetValue & @CRLF)

            ; Reset to default
            _ExtMsgBoxSet(Default)

            ; Show the main GUI again
            GUISetState(@SW_SHOW, $hTest_GUI)
            WinSetOnTop($hTest_GUI, "", 1)
            WinSetOnTop($hTest_GUI, "", 0)

        Case $hButton3

            ; Set the message box right justification, colours (yellow text on blue background) and change font
            _ExtMsgBoxSet(1, 2, 0x004080, 0xFFFF00, 10, "Comic Sans MS")

            $sMsg  = "This is centred on 'EMB Test' with an Exclamation icon, 2 buttons, wrapped right justified coloured text, "
            $sMsg &= "coloured background, no Taskbar button and TOPMOST set" & @CRLF & @CRLF
            $sMsg &= "Note you can get && in button text" & @CRLF
            $sMsg &= "and neither button is set as default" & @CRLF & @CRLF
            $sMsg &= "It will not time out"

            ; Use $MB_ constant
            $iRetValue = _ExtMsgBox ($MB_ICONEXCLAMATION, "One Way|To && Fro", "Test 3", $sMsg, 0, $hTest_GUI)
            ConsoleWrite("Test 3 returned: " & $iRetValue & @CRLF)

            ; Reset to default
            _ExtMsgBoxSet(Default)

        Case $hButton4

            ; Centre the single button
            _ExtMsgBoxSet(1, 4, -1, -1, 11)

            $sMsg  = "No window handle was passed, so the message box is centred on screen" & @CRLF & @CRLF
            $sMsg &= "It has a Stop icon and 1 centred button, is left justified in a largish font, has no Taskbar button and has TOPMOST set" & @CRLF & @CRLF
            $sMsg &= "This are some very long lines, so the message box width is set to the default maximum and the text will be forced to wrap as it is much too long to fit" & @CRLF & @CRLF
            $sMsg &= "It will time out in 15 seconds" & @CRLF & @CRLF & @CRLF & @CRLF & @CRLF & @CRLF & @CRLF & @CRLF
            $sMsg &= "Note that the message box varies in depth automatically to display the lines needed, even if they are forced to wrap a number of times!"

            $iRetValue = _ExtMsgBox (16, "OK", "Test 4", $sMsg, 15)
            ConsoleWrite("Test 4 returned: " & $iRetValue & @CRLF)

            ; Reset to default
            _ExtMsgBoxSet(Default)

        Case $hButton5

            ; Only run this if the flag is set
            If $fAgain Then

                ; Add a "Not again" checkbox with the default font
                _ExtMsgBoxSet(20, 0, Default, Default, 14, "Consolas")

                $sMsg  = "This message box was passed screen coordinates rather than a window handle "
                $sMsg &= "so it is located at 200, 200." & @CRLF & @CRLF
                $sMsg &= "It has an invisible titlebar icon, an internal Query icon, a Taskbar button, a ""Not again"" checkbox, has TOPMOST set and uses the default font for the controls with a user-set font for the text" & @CRLF & @CRLF
                $sMsg &= "It will not time out"

                $iRetValue = _ExtMsgBox ($MB_ICONQuery, $MB_OK, "Test 5", $sMsg, 0, -200, 200)
                ConsoleWrite("Test 5 returned: " & $iRetValue & @CRLF)

                ; Clear the flag as the checkbox was checked
                If $iRetValue < 0 Then $fAgain = False

                ; Reset to default
                _ExtMsgBoxSet(Default)

            Else

                ConsoleWrite("Test 5 will not run again" & @CRLF)

            EndIf

        Case $hButton6

            ; Set the message box right justification, colours (orange text on green background) and change font
            _ExtMsgBoxSet(3, 0, 0x008000, 0xFF8000, 12, "MS Sans Serif")

            $sMsg  = "This message box was passed screen coordinates rather than a window handle "
            $sMsg &= "so it is located at 100, 500." & @CRLF & @CRLF
            $sMsg &= "It has a countdown, no Taskbar button and TOPMOST is not set, with coloured text and background "
            $sMsg &= "and will time out in 20 seconds"

            $iRetValue = _ExtMsgBox (128, "Yes|No", "Test 6", $sMsg, 20, 100, 500)
            ConsoleWrite("Test 6 returned: " & $iRetValue & @CRLF)

            ; Reset to default
            _ExtMsgBoxSet(Default)

    EndSwitch

WEnd

Let me know if that would be of use and I shall release it after some more testing. :oops:

M23


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Edit: I was able figure out all my questions. I'm curious if there is a way to use more than one font in the same message box. It seems like the same font color, font size, and font name is can be used in the entire message box. Hopefully I'm wrong.

BTW: Thanks for the very nice mesage box. Its easy enough to use even for a complete beginner to autoit.

Edited by MKANET

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

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...