Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Sun Sep 15, 2019 9:01 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Global MessageDialog
PostPosted: Sun Jun 12, 2011 11:10 am 
Offline
User avatar

Joined: Sat May 27, 2006 3:27 pm
Posts: 480
I figured i would add this for someone who would like to use a global message dialog with an icon


1. Add a global boolean named OK
2. Add this method to a module



Sub UserMessage(Title As String, ButtonCaption As String , CancelButton As Boolean , OKButton As Boolean , Message As String, Explanation As String)
Dim d as New MessageDialog
Dim b as MessageDialogButton
d.icon=MessageDialog.GraphicStop
d.title = Title
d.ActionButton.Caption=ButtonCaption
d.CancelButton.Visible=CancelButton
d.Message= Message
d.Explanation= Explanation

b=d.ShowModal
Select Case b
Case d.ActionButton
//user pressed Save
OK = True
Case d.CancelButton
//user pressed Cancel
Ok = False
End select
End Sub



3. Add this to a pushbutton action event


Call UserMessage( "    Error Deleteing File" , "OK" , False , True , "Cannot delete file: it is being used by another person or program", "Close any programs that may be using the file and try again!" )



If OK Then
'the user clicked the save button
Else
'do whatever else
End


Top
 Profile  
Reply with quote  
 Post subject: Re: Global MessageDialog
PostPosted: Sun Jun 12, 2011 1:01 pm 
Offline

Joined: Mon May 31, 2010 5:35 am
Posts: 2412
Location: Netherlands
even simpler:

Sub UserMessage(Title As String, ButtonCaption As String , CancelButton As Boolean , OKButton As Boolean , Message As String, Explanation As String) As Boolean
Dim d as New MessageDialog
Dim b as MessageDialogButton
d.icon=MessageDialog.GraphicStop
d.title = Title
d.ActionButton.Caption=ButtonCaption
d.CancelButton.Visible=CancelButton
d.Message= Message
d.Explanation= Explanation

b=d.ShowModal
Select Case b
Case d.ActionButton
//user pressed Save
Return True
Case d.CancelButton
//user pressed Cancel
Return False
End select
End Sub


here you functions returns a boolean so you can just check if it's true or false.
if UserMessage("Error Deleteing File" , "OK" , False , True , "Cannot delete file: it is being used by another person or program", "Close any programs that may be using the file and try again!" ) then
' user clicked ok button, or save button everything whent good.
MsgBox "thanks for saving the file"
else
' User cancelled
MsgBox "You cancelled"
end if


See the DutchTools Free module, it has this function for you and everyone free inside..;)

_________________
SWORT™
- Windows Vista, Windows XP, Windows 7, Linux Mint 11 and Mac OSX Lion
- REAL Studio Enterprise(latest) and WEB Edition(latest)
- Plugins (MBS Complete, ToringoLib, Einhugur, VanHoek + Some open source plugins)
For Dutch User Groups ask me to enter!


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group