Real Software Forums
http://forums.realsoftware.com/

Custom classes interacting with each other
http://forums.realsoftware.com/viewtopic.php?f=21&t=47562
Page 1 of 1

Author:  wedgesan [ Thu Apr 11, 2013 2:33 am ]
Post subject:  Custom classes interacting with each other

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.

Author:  simulanics [ Thu Apr 11, 2013 8:15 am ]
Post subject:  Re: Custom classes interacting with each other

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

Author:  wedgesan [ Thu Apr 11, 2013 9:32 am ]
Post subject:  Re: Custom classes interacting with each other

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?

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/