Updated to work with Macro Scheduler 12 or higher.
Added default buttons option. Default buttons are in reverse when Right-justified title/text is selected under Miscellaneous.
Added an option to include the button results.
There no longer seems to be a problem with large texts. It's possible the large text issue in my previous example was caused by Windows XP. I can't confirm this since I no longer have Windows XP.
Code: Select all
let>APP_TITLE=LibFunc MessageBox Wizard
Dialog>Dialog1
object Dialog1: TForm
Left = 234
Top = 84
HelpContext = 5000
BorderIcons = [biSystemMenu, biMinimize]
BorderStyle = bsSingle
Caption = 'LibFunc MessageBox Wizard by Rain'
ClientHeight = 462
ClientWidth = 421
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = True
Position = poScreenCenter
ShowHint = True
OnTaskBar = True
PixelsPerInch = 96
TextHeight = 13
object msLabel1: TLabel
Left = 8
Top = 8
Width = 72
Height = 13
Caption = 'Window Title'
Font.Charset = ANSI_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = [fsBold]
ParentFont = False
Transparent = True
end
object msLabel2: TLabel
Left = 8
Top = 48
Width = 81
Height = 13
Caption = 'Message Body'
Font.Charset = ANSI_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = [fsBold]
ParentFont = False
Transparent = True
end
object msEdit1: TEdit
Left = 8
Top = 24
Width = 409
Height = 21
Font.Charset = ANSI_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = [fsBold]
ParentFont = False
TabOrder = 2
Text = 'Title of the message box'
end
object msMemo1: tMSMemo
Left = 8
Top = 64
Width = 409
Height = 153
Font.Charset = ANSI_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = [fsBold]
Lines.Strings = (
'Enter your message')
ParentFont = False
ScrollBars = ssVertical
TabOrder = 3
Text = 'Enter your message'
end
object msRadioGroup1: tMSRadioGroup
Tag = 4
Left = 176
Top = 224
Width = 97
Height = 137
Caption = 'Icons'
ItemIndex = 0
Items.Strings = (
'None'
'Warning'
'Informational'
'Critical'
'Question')
TabOrder = 5
Text = 'None'#13#10'Warning'#13#10'Informational'#13#10'Critical'#13#10'Question'#13#10
end
object msRadioGroup2: tMSRadioGroup
Tag = 2
Left = 280
Top = 224
Width = 137
Height = 65
Caption = 'Modality'
ItemIndex = 2
Items.Strings = (
'Application'
'System'
'Task Modal')
TabOrder = 6
Text = 'Application'#13#10'System'#13#10'Task Modal'#13#10
end
object msRadioGroup3: tMSRadioGroup
Tag = 1
Left = 280
Top = 296
Width = 137
Height = 65
Caption = 'Miscellaneous'
ItemIndex = 1
Items.Strings = (
'Nothing'
'Top-most attribute set'
'Right-justified title/text')
TabOrder = 7
Text = 'Nothing'#13#10'Top-most attribute set'#13#10'Right-justified title/text'#13#10
end
object msRadioGroup4: tMSRadioGroup
Left = 8
Top = 224
Width = 161
Height = 137
Caption = 'Buttons'
ItemIndex = 0
Items.Strings = (
'OK'
'OK-Cancel'
'Yes-No'
'Yes-No-Cancel'
'Abort-Retry-Ignore'
'Retry-Cancel'
'Cancel-Try Again-Continue')
TabOrder = 4
Text =
'OK'#13#10'OK-Cancel'#13#10'Yes-No'#13#10'Yes-No-Cancel'#13#10'Abort-Retry-Ignore'#13#10'Retry-' +
'Cancel'#13#10'Cancel-Try Again-Continue'#13#10
end
object msButton1: tMSButton
Left = 184
Top = 408
Width = 89
Height = 25
Caption = 'Preview'
Font.Charset = ANSI_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = [fsBold]
ModalResult = 1
ParentFont = False
ParentShowHint = False
ShowHint = False
TabOrder = 0
DoBrowse = False
BrowseStyle = fbOpen
end
object msButton2: tMSButton
Left = 288
Top = 408
Width = 97
Height = 25
Caption = 'Copy Code'
Font.Charset = ANSI_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = [fsBold]
ModalResult = 3
ParentFont = False
ParentShowHint = False
ShowHint = False
TabOrder = 1
DoBrowse = False
BrowseStyle = fbOpen
end
object msCheckBox1: TCheckBox
Left = 184
Top = 380
Width = 153
Height = 17
Caption = 'Include Button Results'
Checked = True
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = [fsBold]
ParentFont = False
State = cbChecked
TabOrder = 9
end
object msRadioGroup5: tMSRadioGroup
Tag = -1
Left = 8
Top = 360
Width = 161
Height = 73
Caption = 'Default Button'
ItemIndex = 0
Items.Strings = (
'First Button')
TabOrder = 8
Text = 'First Button'#13#10
end
object StatusBar1: TStatusBar
Left = 0
Top = 443
Width = 421
Height = 19
Panels = <>
SimplePanel = True
end
end
EndDialog>Dialog1
AddDialogHandler>Dialog1,msButton1,OnClick,Preview(PrevieOnly)
AddDialogHandler>Dialog1,msButton2,OnClick,Preview(CopyCode)
AddDialogHandler>Dialog1,,OnClose,Exit
AddDialogHandler>Dialog1,msEdit1,OnMouseDown,ClearTitleMessage
AddDialogHandler>Dialog1,msEdit1,OnKeyUp,ClearTitleMessage
AddDialogHandler>Dialog1,msMemo1,OnMouseDown,ClearBodyMessage
AddDialogHandler>Dialog1,msMemo1,OnKeyUp,ClearBodyMessage
AddDialogHandler>Dialog1,msRadioGroup3,OnClick,MiscellaneousClicked
SHOW>Dialog1
LET>ListBoxOptionA=FALSE
LET>ListBoxOptionB=FALSE
LET>ListBoxOptionC=FALSE
LET>ClearTitle=False
LET>ClearBody=False
LABEL>Loop
WAIT>0.05
GetDialogProperty>Dialog1,msRadioGroup4,ItemIndex,ButtonsRes
IF>ListBoxOptionA=FALSE
IF>ButtonsRes=0
LET>ListBoxOptionA=TRUE
LET>ListBoxOptionB=FALSE
LET>ListBoxOptionC=FALSE
SetDialogProperty>Dialog1,msRadioGroup5,ItemIndex,0
SetDialogProperty>Dialog1,msRadioGroup5,Text,First Button
endif
ENDIF
IF>ListBoxOptionB=FALSE
IF>{(%ButtonsRes%=1)OR(%ButtonsRes%=2)OR(%ButtonsRes%=5)}
LET>ListBoxOptionA=FALSE
LET>ListBoxOptionB=TRUE
LET>ListBoxOptionC=FALSE
SetDialogProperty>Dialog1,msRadioGroup5,ItemIndex,0
SetDialogProperty>Dialog1,msRadioGroup5,Text,First Button%CRLF%Second Button
endif
ENDIF
IF>ListBoxOptionC=FALSE
IF>{(%ButtonsRes%=3)OR(%ButtonsRes%=4)OR(%ButtonsRes%=6)}
LET>ListBoxOptionA=FALSE
LET>ListBoxOptionB=FALSE
LET>ListBoxOptionC=TRUE
SetDialogProperty>Dialog1,msRadioGroup5,ItemIndex,0
SetDialogProperty>Dialog1,msRadioGroup5,Text,First Button%CRLF%Second Button%CRLF%Third Button
endif
ENDIF
GOTO>Loop
SRT>Preview
LET>FLAG=0
//<--START GET FLAGS
//<--START Set Icons Flag
GetDialogProperty>Dialog1,msRadioGroup1,ItemIndex,IconsRes
IF>IconsRes=1
LET>FLAG=FLAG+48
ENDIF
IF>IconsRes=2
LET>FLAG=FLAG+64
ENDIF
IF>IconsRes=3
LET>FLAG=FLAG+16
ENDIF
IF>IconsRes=4
LET>FLAG=FLAG+32
ENDIF
//<--ENDI Set Icons Flag
//<--START Set Modality Flag
GetDialogProperty>Dialog1,msRadioGroup2,ItemIndex,ModalityRes
IF>ModalityRes=1
LET>FLAG=FLAG+4096
ENDIF
IF>ModalityRes=2
LET>FLAG=FLAG+8192
ENDIF
//<--END Set Modality Flag
//<--START Set Miscellaneous Flag
GetDialogProperty>Dialog1,msRadioGroup3,ItemIndex,MiscellaneousRes
IF>MiscellaneousRes=1
LET>FLAG=FLAG+262144
ENDIF
IF>MiscellaneousRes=2
LET>FLAG=FLAG+5244288
ENDIF
//<--END Set Miscellaneous Flag
//<--START Set Buttons Flag
GetDialogProperty>Dialog1,msRadioGroup4,ItemIndex,ButtonsRes
IF>ButtonsRes=1
LET>FLAG=FLAG+1
ENDIF
IF>ButtonsRes=2
LET>FLAG=FLAG+4
ENDIF
IF>ButtonsRes=3
LET>FLAG=FLAG+3
ENDIF
IF>ButtonsRes=4
LET>FLAG=FLAG+2
ENDIF
IF>ButtonsRes=5
LET>FLAG=FLAG+5
ENDIF
IF>ButtonsRes=6
LET>FLAG=FLAG+6
ENDIF
//<--END Set Buttons Flag
//<--START Set Default Button Flag
GetDialogProperty>Dialog1,msRadioGroup3,ItemIndex,MiscellaneousRes
IF>MiscellaneousRes=2
//Set Default button in reverse (Right-justified)
GetDialogProperty>Dialog1,msRadioGroup5,ItemIndex,DefaultButtonRes
IF>DefaultButtonRes=1
LET>FLAG=FLAG-1024
ENDIF
IF>DefaultButtonRes=2
LET>FLAG=FLAG-768
ENDIF
ELSE
GetDialogProperty>Dialog1,msRadioGroup5,ItemIndex,DefaultButtonRes
IF>DefaultButtonRes=1
LET>FLAG=FLAG+256
ENDIF
IF>DefaultButtonRes=2
LET>FLAG=FLAG+512
ENDIF
ENDIF
//<--END Set Default Button Flag
//<---- END GET FLAGS
GetDialogProperty>Dialog1,msEdit1,Text,TheTitle
GetDialogProperty>Dialog1,msMemo1,Text,Memo1Text
IF>%Preview_Var_1%=CopyCode
//<--START Create Code to Copy
Let>MsgFunc=
Concat>MsgFunc,/*%CRLF%
Concat>MsgFunc,MSG_BODY.DATA:%CRLF%
Concat>MsgFunc,%Memo1Text%%CRLF%
Concat>MsgFunc,*/%CRLF%
Concat>MsgFunc,LabelToVar>MSG_BODY.DATA,MsgBody%CRLF%
Concat>MsgFunc,LibFunc>user32,MessageBoxA,res,0,%MsgBody%,%TheTitle%,%FLAG%%CRLF%
GetDialogProperty>Dialog1,msCheckBox1,Checked,IncludeResultOptions
IF>IncludeResultOptions=True
GetDialogProperty>Dialog1,msRadioGroup4,ItemIndex,ButtonsRes
IF>ButtonsRes=0
/*
BUTTON_RESULT_OPTIONS_0.DATA:
IF>res=1
//Ok
endif
*/
LabelToVar>BUTTON_RESULT_OPTIONS_0.DATA,ButtonResultOptions
ENDIF
IF>ButtonsRes=1
/*
BUTTON_RESULT_OPTIONS_1.DATA:
IF>res=1
//Ok
endif
IF>res=2
//Cancel
endif
*/
LabelToVar>BUTTON_RESULT_OPTIONS_1.DATA,ButtonResultOptions
ENDIF
IF>ButtonsRes=2
/*
BUTTON_RESULT_OPTIONS_2.DATA:
IF>res=6
//Yes
endif
IF>res=7
//No
endif
*/
LabelToVar>BUTTON_RESULT_OPTIONS_2.DATA,ButtonResultOptions
ENDIF
IF>ButtonsRes=3
/*
BUTTON_RESULT_OPTIONS_3.DATA:
IF>res=2
//Cancel
endif
IF>res=6
//Yes
endif
IF>res=7
//No
endif
*/
LabelToVar>BUTTON_RESULT_OPTIONS_3.DATA,ButtonResultOptions
ENDIF
IF>ButtonsRes=4
/*
BUTTON_RESULT_OPTIONS_4.DATA:
IF>res=3
//Abort
endif
IF>res=4
//Retry
endif
IF>res=5
//Ignore
endif
*/
LabelToVar>BUTTON_RESULT_OPTIONS_4.DATA,ButtonResultOptions
ENDIF
IF>ButtonsRes=5
/*
BUTTON_RESULT_OPTIONS_5.DATA:
IF>res=2
//Cancel
endif
IF>res=4
//Retry
endif
*/
LabelToVar>BUTTON_RESULT_OPTIONS_5.DATA,ButtonResultOptions
ENDIF
IF>ButtonsRes=6
/*
BUTTON_RESULT_OPTIONS_6.DATA:
IF>res=2
//Cancel
endif
IF>res=10
//Try Again
endif
IF>res=11
//Continue
endif
*/
LabelToVar>BUTTON_RESULT_OPTIONS_6.DATA,ButtonResultOptions
ENDIF
Concat>MsgFunc,%ButtonResultOptions%%CRLF%
ENDIF
PutClipBoard>MsgFunc
GetTime>TheTime
SetDialogProperty>Dialog1,StatusBar1,SimpleText,Code copied %TheTime%
//<--END Create Code to Copy
ELSE
//<--START Preview Message Box
LibFunc>user32,MessageBoxA,r,0,%Memo1Text%,%TheTitle%,%FLAG%
//<--END Preview Message Box
ENDIF
END>Preview
SRT>MiscellaneousClicked
GetDialogProperty>Dialog1,msRadioGroup3,ItemIndex,MiscellaneousRes
IF>MiscellaneousRes=2
//Reverse if Right-justified title/text is selected
SetDialogProperty>Dialog1,msRadioGroup4,Text,OK%CRLF%Cancel-OK%CRLF%No-Yes%CRLF%Cancel-No-Yes%CRLF%Ignore-Retry-Abort%CRLF%Cancel-Retry%CRLF%Continue-Try Again-Cancel
ELSE
SetDialogProperty>Dialog1,msRadioGroup4,Text,OK%CRLF%OK-Cancel%CRLF%Yes-No%CRLF%Yes-No-Cancel%CRLF%Abort-Retry-Ignore%CRLF%Retry-Cancel%CRLF%Cancel-Try Again-Continue
ENDIF
END>MiscellaneousClicked
SRT>ClearTitleMessage
IF>ClearTitle=False
SetDialogProperty>Dialog1,msEdit1,Text,
Let>ClearTitle=True
ENDIF
END>ClearTitleMessage
SRT>ClearBodyMessage
IF>ClearBody=False
SetDialogProperty>Dialog1,msMemo1,Text,
Let>ClearBody=True
ENDIF
END>ClearBodyMessage
SRT>Exit
Exit>1
END>Exit