|
-
March 13th, 2001, 11:03 AM
#1
Communicating between forms
Is there a way to call user-defined functions in other forms via a pointer? I need to close windows that are docked to my main form using a function that creates a sliding effect. I want to point to that function on a mouse click event on the form for all possible open windows with the same function.
-
March 13th, 2001, 11:08 AM
#2
Re: Communicating between forms
If the form's subs are public, you can refer to them directly thus:
' In frmCustomer
public Sub RefreshCustomerDetails()
'..yadda yadda yadda
End Sub
'in frmMain
Call frmCustomer.RefreshCustomerDetails()
HTH,
Duncan
-------------------------------------------------
Ex. Datis: Duncan Jones
Merrion Computing Ltd
http://www.merrioncomputing.com
-
March 13th, 2001, 11:37 AM
#3
Re: Communicating between forms
I don't want to hard code the form names into the main form because I want to be able to add extra forms without having to update the main form. Any suggestions?
-
March 13th, 2001, 11:51 AM
#4
Re: Communicating between forms
Aha - in that case you need "Implements"
Create a class file called something like: IDockableForm with all the things a dockable form does, but no code filled in.
'\\ IDockableForm
'\\ Interface Inhertance class
public Enum enDockTargets
enDTLeft = 1
enDTRight = 2
enDTTop = 3
enDTBottom = 4
End Enum
public Sub DockToBorder(byval Target as enDockTargets)
'no code here....
End Sub
Now in each for, in the declarations part:
Implements IDockableForm
'This will create:
public Sub IDockableForm_Dock(byval Target as enDockTargets)
'put actual implementation of the docking behaviour here
End Sub
And then in your main code, iterate the Forms collection and if they implement IDockableForm, call the IDockableForm_Dock method.
Dim frmThis as IDockableForm
for Each frmThis in Forms
If Not frmThis is nothing then
Call frmThis.Dock(enDTLeft )
End If
next frmThis
Read the help on the implements keyword for more info....
HTH,
Duncan
-------------------------------------------------
Ex. Datis: Duncan Jones
Merrion Computing Ltd
http://www.merrioncomputing.com
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
|