Passing "Controls" collection to a class method not defined in .ctl file
- From: Eric Chevalier <etech@xxxxxxxxxxxxxxxx>
- Date: Fri, 08 Aug 2008 17:42:22 -0500
I'm trying to pass the "Controls" collection from the
UserControl_Initialize() routine in my .ctl file to a class method
defined in a separate module. Here's the .ctl code:
Private Sub UserControl_Initialize()
m_Viewer = VIEWER_GLOBAL360
Select Case m_Viewer
Case VIEWER_GLOBAL360
Set Viewer = New ViewerG360
Case VIEWER_UNISOFT
Set Viewer = New ViewerUnisoft
End Select
Viewer.Setup Controls
"ViewerG360" and "ViewerUnisoft" are classes (each defined in their
own .cls file) which encapsulate the functionality of a graphics
toolkit. (In the future, I may define more of these classes as I
support more graphics libraries.) The G360 toolkit needs to add
controls to my form; the Unisoft viewer does not. I want to pass the
"Setup" method the forms's "Controls" array so that the toolkit can
add controls if it needs to. (I'm trying to avoid a bunch of in-line
code which tests for different graphics toolkits and performs whatever
logic is required.)
Here's the start of the ViewerG360.Setup method:
Public Function Setup(Controls As ComctlLib.Controls) As Boolean
Dim szWang As String
szWang = GetWangControlString(WANG_EDIT_OCX)
Set wimgView = Controls.Add(szWang, "ctl1")
If wimgView Is Nothing Then
MsgBox "Error during dynamic load of " & szWang
Else
szWang = GetWangControlString(WANG_THUMB_OCX)
Set wimgThumb = Controls.Add(szWang, "ctl2")
If wimgThumb Is Nothing Then
MsgBox "Error during dynamic load of " & szWang
Else
This code sequence gives me a "Run-time error '13': Type mismatch".
I've tried some alternatives, such as:
Public Function Setup(Controls As Controls) As Boolean
but that gives me the same error. I've also tried:
Public Function Setup(xxx) As Boolean
Dim szWang As String
Dim Controls As ComctlLib.Controls
Set Controls = xxx
Setup = False
szWang = GetWangControlString(WANG_EDIT_OCX)
Set wimgView = Controls.Add(szWang, "ctl1")
but that gives "Compile error: Method or data member not found".
I've been Googling for a couple of hours now, but haven't found any
good clues. Am I just barking up the wrong tree, or am I missing
something obvious?
Any help would be graciously appreciated!
Eric
--
Eric Chevalier E-mail: etech@xxxxxxxxxxxxxxxx
Web: www.tulsagrammer.com
Is that call really worth your child's life? HANG UP AND DRIVE!
.
- Follow-Ups:
- Re: Passing "Controls" collection to a class method not defined in .ctl file
- From: Larry Serflaten
- Re: Passing "Controls" collection to a class method not defined in .ctl file
- Prev by Date: Re: Database field in control
- Next by Date: Re: Passing "Controls" collection to a class method not defined in .ctl file
- Previous by thread: Database field in control
- Next by thread: Re: Passing "Controls" collection to a class method not defined in .ctl file
- Index(es):
Relevant Pages
|