MsgBox is more or less the equivalent of the old VB6 Msgbox. Over the years Apple, and more recently Microsoft have moved away from the simple responses (yes/no, abort/retry/cancel) because users found them confusing. The better way is to have a button with an action. Delete/Cancel, Open/Cancel, or whatever you want.
Here’s what we’ve used for years (we also have a training video on how to create this):
[code]Function Alert(Type as AlertTypes, Title as string, msg as string, btn1txt as string, btn2txt as string, btn3txt as string, w as window = nil) As integer
Dim d as New MessageDialog //declare the MessageDialog object
Dim b as MessageDialogButton //for handling the result
select case Type
case AlertTypes.kCaution
d.icon=MessageDialog.GraphicCaution //display warning icon
case AlertTypes.kNote
d.icon = MessageDialog.GraphicNote
case AlertTypes.kStop
d.icon = MessageDialog.GraphicStop
case AlertTypes.kPlain
d.icon = MessageDialog.GraphicNone
case AlertTypes.kQuestion
d.icon = MessageDialog.GraphicQuestion
end
d.ActionButton.Caption= btn1txt
if btn2txt <> “” then
d.CancelButton.Visible= True //show the Cancel button
d.CancelButton.Caption = btn2txt
else
d.CancelButton.Visible = false
end
if btn3txt <> “” then
d.AlternateActionButton.Visible= True //show the “Don’t Save” button
d.AlternateActionButton.Caption = btn3txt
else
d.AlternateActionButton.Visible = false
end
d.Message = Title
d.Explanation = msg
if w = nil then
b=d.ShowModal //display the dialog
else
b = d.ShowModalWithin( w )
end
Select Case b //determine which button was pressed.
Case d.ActionButton
return 1
Case d.AlternateActionButton
return 3
Case d.CancelButton
return 2
End select
End Function
[/code]
And if used in code it’s like this:
dim res as integer = BKS.Alert( kAlertCaution, "Title Message.", _
"Detailed message", _
"Button1Text", "Button2Text", "Button3Text", self.trueWindow)
if res = 1 then return