Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Thu Aug 17, 2017 12:59 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Custom classes interacting with each other
PostPosted: Thu Apr 11, 2013 2:33 am 
Offline

Joined: Wed Mar 06, 2013 4:25 am
Posts: 4
I'm using a custom class to deal with database management, and in order to handle errors i'm calling a method that opens a dialog box.

Class DDBBManagement
sub MyMethodToCallDialogBox (<several parameters here>)
code to open a DialogBox


I've also coded a custom dialog box. It does nothing fancy, just a little prettier than the standard dialog box.
In order to use it with my custom database class, I've subclassed it, and overrided the dialog method:

Class DDBBManagementEnhanced subclass of DDBBManagement
sub MyMethodToCallDialogBox (<several parameters here>)
code to open my Custom dialog box


It works, but I wonder if there's a more elegant way to achieve this. Any ideas?

Thank you very much. Best regards.


Top
 Profile  
Reply with quote  
 Post subject: Re: Custom classes interacting with each other
PostPosted: Thu Apr 11, 2013 8:15 am 
Offline
User avatar

Joined: Sun Aug 12, 2007 10:10 am
Posts: 1086
Location: Boiling Springs, SC
wedgesan wrote:
I'm using a custom class to deal with database management, and in order to handle errors i'm calling a method that opens a dialog box.

Class DDBBManagement
sub MyMethodToCallDialogBox (<several parameters here>)
code to open a DialogBox


I've also coded a custom dialog box. It does nothing fancy, just a little prettier than the standard dialog box.
In order to use it with my custom database class, I've subclassed it, and overrided the dialog method:

Class DDBBManagementEnhanced subclass of DDBBManagement
sub MyMethodToCallDialogBox (<several parameters here>)
code to open my Custom dialog box


It works, but I wonder if there's a more elegant way to achieve this. Any ideas?

Thank you very much. Best regards.


In the RSDS Library (Download) I believe there are 6-7 custom dialogs...load the software, choose "snippet" for category, enter "dialog" in the search field, and press enter :-)

Here is a copy paste example from the library...

1. make a global method called MessageDialog in your APP class

2. Call it anywhere you like in your app
App.MessageDialog(App.ExecutableFile.Name,"Error: Testing Msg....","Msg Tested",1,"","", False)

Sub MessageDialog(Title As String, Message As String , Explanation As String , GraphicIcon As Integer , ActionCaption As String ="OK" , CancelCaption As String ="Cancel", CancelButton As Boolean)

'0 - GraphicNote (The application icon on Mac OS X)
'1 - GraphicCaution triangle (On Mac OS X, the application icon superimposed on the caution triangle)
'2 - GraphicStop (On Mac OS X 10.3 and above, the application icon)
'3 - GraphicQuestion icon (On Mac OS X 10.3 and above, it is the same as 0)

Dim d as New MessageDialog
Dim b as MessageDialogButton

d.icon= GraphicIcon
d.Title = Title
d.ActionButton.Caption = ActionCaption
d.CancelButton.Caption= CancelCaption
d.CancelButton.Visible = CancelButton

d.Message=Message
d.Explanation=Explanation
b=d.ShowModal

'You can use the return type as a boolean or a string to see what the user pressed
Select Case b
Case d.ActionButton
Speak "You Pressed OK"

Case d.CancelButton
Speak "You Pressed Cancel"
End Select
End Sub

_________________
Matthew A. Combatti
Real Studio 2012 r1.2

Visit Xojo Developer's Spot!
Systems I Use:
Windows XP/Windows Vista/Windows Server 2008 r2/Windows 7/Windows 8
Mac OSX 10.5/Mac OSX 10.6/Mac OSX Server/Ubuntu/Debian/Suse/Red Hat/
Windows Server 2011/CentOS 5.4 /ReactOS/SimOS

~All Xojo Compatible~


Top
 Profile  
Reply with quote  
 Post subject: Re: Custom classes interacting with each other
PostPosted: Thu Apr 11, 2013 9:32 am 
Offline

Joined: Wed Mar 06, 2013 4:25 am
Posts: 4
Thank you very much for your reply, simulaniacs, but I'd like to further explain what is what I'm trying to achieve

My point is: I call a standard dialog box from within my DDBB class and I want to make it so it can call a non standard dialog window (it doesn't matter if its my own dialog box or somebody's else).

There's two ways to acomplish this that I can think of:

-Replace all calls to the standard dialog box in my code, so it calls now the custom dialog box (This is the "no way" option)

-Having a centraliced method that calls the standard dialog box that you call whenever you need a dialog box and override/rewrite/youname it so it calls the new custom dialog box.

This option is far more elegant, and it makes both my DDBB class and the custom dialog box independent of each other, so i can export them both to use in other projects, or I can use them both in the same project and benefit from both.

My implementation has this method within the DDBB class. Your idea is to make it global inside the app class, and I can see that it is so it can be called from anywhere inside the project. I was aiming to have my DDBB class portable, so it doesn't depend on having a "Sub MessageDialog" in the app.

I was wondering if there is a better way to do this. My way needs the method overriden to call a custom Dialog box, yours (if I'm not wrong) implies i'd have to rewrite the "MessageDialog Sub" to do the same. Seems like it's the way to go, isn't it?


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 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