VXDSP
Support Notes: Frank K's VBA Notes |
|
Home Visio VXDSP VXDSP Support Notes This page |
Reader Frank K very kindly submitted some comments that may be very useful to others:
1. You state that (p. 303) that VBA forms do not expose their Windows handles. The following code has worked dead-solid for over 2 years:
I assume that there is a control on this form (I'm using a textbox here but almost anything else will work). Also when I'm working in VBA I always go to the ObjectBrowser and set "Show hidden members" to On. That's how I discovered "_GethWnd" - note that if you have "Show hidden members" to On then Intellisense will display them also! "_GethWnd" is enclosed in square brackets so that VBA won't choke on leading underscore. I also assume that GetParent API is declared
Dim formMS As MSForms.Control 'this is
a generic control
Dim lngHandleToTextBox As long
Dim lngHandleToForm As long
Set formMS = Me.Textbox1
'assumes you have this control
lngHandleToTextBox = formMS.[_GethWnd]
'get the handle to Textbox
lngHandleToForm =GetParent(m_lngHandleToTextBox) 'get Form's handle
2. Your section on where to place VBA code is extremely good. I had decided to place my common code in a stencil that a drawing would have a reference to. However I have a lot of code that sits in classes and I found that the code in a drawing project couldn't see those classes. The following workaround uses a declared public type which contains the desired class(es).
This seems to operate so far - I'll update you if I hit problems. In the referenced library project have a code module with the following:
Public Type PublicDummyVariable
clsDesiredClass As DesiredClass
End Type
Public p_clsDesiredClass As DesiredClass
In the calling code it is now possible to have code like the following:
Dim udtPublicDummyVariable as PublicDummyVariable
Set udtPublicDummyVariable.clsDesiredClass = New DesiredClass 'this instantiates the class
'more code goes here - access methods & properties of class, etc.
Set udtPublicDummyVariable.clsDesiredClass = Nothing 'release object
Article Created: 2002-08-08 Last edit: Last edit:
02-08-21 Graham Wideman
Go to: DiagramAntics.com