|
-
Mar 26th, 2008, 05:26 PM
#1
Thread Starter
Fanatic Member
Any way to have a form implement and interface?
I have a handful of MDI forms with the same set of public functions. Is there any way to have a form implement an interface and then test for that interface, ie. "Implements iCustom". I've played around with it briefly and can get private interfaces to attach themselves, but the idea of an interface with all private members seems silly. I suspect this is out of VB6's league, but thought I'd make sure.
-
Mar 26th, 2008, 06:23 PM
#2
Re: Any way to have a form implement and interface?
Leaving aside how to do it, what is it you are trying to accomplish?
-
Mar 26th, 2008, 06:27 PM
#3
Re: Any way to have a form implement and interface?
BTW LaVolpe has an Implements example in this thread.
-
Mar 26th, 2008, 06:30 PM
#4
Re: Any way to have a form implement and interface?
Hmmm. You can create an interface class containing the function stubs. Each MDI child will implement that interface. Then to call a specific MDI child's interface, the logic would look something like...
Code:
' iCustom interface
Option Explicit
Public Function ObjectPointer() As Long
' stub
End Function
' each child form
Implements iCustom
Private Function iCustom_ObjectPointer() As Long
iCustom_ObjectPointer = ObjPtr(Me)
End Function
' the MDI parent
Dim theInterface As iCustom
Set theInterface = Me.ActiveForm
Debug.Print theInterface.ObjectPointer, ObjPtr(Me.ActiveForm)
Don't kow if you already had this? If not, then is this what you are looking for?
-
Mar 26th, 2008, 07:10 PM
#5
Thread Starter
Fanatic Member
Re: Any way to have a form implement and interface?
 Originally Posted by MartinLiss
Leaving aside how to do it, what is it you are trying to accomplish?
I have several different types of displays in ListViews, and need to update all of them in a loop. Right now, I check the TypeName of the forms in a loop through the Forms collection. Problem is, as I add new forms that need to update, checking all of the TypeNames is becoming unwieldly. I also use some public functions to handle things like right-click popup menus, custom sort types, etc. where I expose the ListView through a custom property (that way I don't have to name them all the same thing). This would be a lot easier to maintain if I had a custom interface to use.
@LaVolpe: That's an interesting idea, and one that I hadn't thought of. I'll have to play around with it a little bit.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|