!! Working with Control Arrays !!
I am working with a Form and a Control Array, found inside the Form. But I don't know what kind of control the end-user is going to load in the FileListBox control. But it has the OCX file extension, with it...
Can someone, please help me???
!! Thanks in advance !!
:afrog::afrog::afrog::afrog::afrog::afrog:
Re: !! Working with Control Arrays !!
A control array is an array of all the same kind of control.
What is it that you want the user to be able to do? Add completely new controls? Add new members to an existing control array?
Re: !! Working with Control Arrays !!
ThEiMp
If your desire is Marty's second scenario (add new members to an
existing control array), then you can use the Load statement
EDIT:
Here is a possible code snippet:
Code:
For ii = nn to zz
Load MyControl(ii)
With MyControl(ii)
.Top = v1
.Left = v2
.Visible = True
End With
Next ii
... natch, change as required.
Things to keep in mind:
- a variable to track how many controls you've added so far
- use the Unload statement to remove unwanted ones
Spoo
Re: !! Working with Control Arrays !!
If it isn't obvious to the other members:
Actually I am trying to get a Control Array of unknown controls, to the program to be added in a Control Array. Every example, I have seen and done works with the program's knowledge of the control, at design-time. Which is basically what I don't want to happen...
-- Not Sure why there is any error checking in that. It must work fine, without it...
Code:
Sub LoadCntlArray(ByRef cntlArray As Object)
On Error Resume Next
Dim cntl As Control
For Each cntl In cntlArray
Me.Controls.Add Blah Blah
Next
End Sub
!! Thanks in advance !!
Re: !! Working with Control Arrays !!
maybe you need to use a known user control for an array, that each can contain an instance of the unkown control, loaded at runtime
Re: !! Working with Control Arrays !!
Quote:
Originally Posted by
MartinLiss
...What is it that you want the user to be able to do? Add completely new controls? Add new members to an existing control array?
You never did answer my question.
Re: !! Working with Control Arrays !!
-- So sorry, about not answering questions. I had to hurry out of the office...
1. I am trying to get the end-user to add anykind of ActiveX control, that has the extension of ocx, into my IDE's Design-Time mode. But not sure how to do that. I am working with the source code, that I had posted, before this post. Also: The Controls must be contained however, inside the FileListBox control, and have their real process names, and not Filename.ocx. But instead they must be something like: SSTab ActiveX Control, or something like that, for all of them in the FileListBox...
2. Yes, I do wish to add new controls to the IDE, that I have written...
3. I cannot remember what members, are in VB6... (Might be getting myself confused, with Director.)
Re: !! Working with Control Arrays !!
Quote:
Originally Posted by
ThEiMp
...I am trying to get the end-user to add anykind of ActiveX control, that has the extension of ocx, into my IDE's Design-Time modeā¦.
Form your original post I had NO idea that that was what you were trying to do. A full description of what you are trying to do would have saved me some time since I would have realized that I have no idea how to help you and I wouldn't have replied.
Re: !! Working with Control Arrays !!
--So sorry, to have wasted your time...
Re: !! Working with Control Arrays !!
No problem. I was just trying to point out that while you of course know what you are working on, we don't, so when you create a new thread you always need to tell us.
Re: !! Working with Control Arrays !!
!! Wait a minute !!
Problem: How about we get my IDE, to read the ocx Control, and then extract the name of the Control, eg: CommandButton. And work from there???
Component Insert, MenuItem, using my CustomDialog Control:
Code:
Public Sub Comp_Insert_Click()
On Error Resume Next
Dim cntl As Control
With CustomDialog1
.FilterEnabled = True
.Filter = "ocx"
End With
frmMain1.CustomDialog1.ShowOpen
frmMain1.List1.AddItem "Unbound ActiveX Control: " & cntl
frmDesign1.Controls.Add cntl
End Sub
Re: !! Working with Control Arrays !!
Quote:
Originally Posted by
ThEiMp
-- So sorry, about not answering questions. I had to hurry out of the office...
1. ... The Controls must be contained however, inside the FileListBox control, and have their real process names, and not Filename.ocx. But instead they must be something like: SSTab ActiveX Control, or something like that, for all of them in the FileListBox...
The HelpString property of a typelib object is what you are looking for I believe. It is rather simple to return that string...
1. Add reference of "TypeLib Information" to your project.
2. Simply add path/filename in sample code below
Code:
Dim oLibInfo As TypeLibInfo, ctlLongName As String
Set oLibInfo = TLI.TLIApplication.TypeLibInfoFromFile(path/filename)
ctlLongName = oLibInfo.HelpString
Note that a file list box cannot be used here. You cannot modify its contents; you may want to use a listview so you can keep the filename and helpstring plus any other information together. Just an idea.
Edited: And regarding arrays; don't think that will happen. You'll need a base object, indexed, to append to any array. However, nothing saying you can't create a collection of objects, or classes, to act like a control array
Re: !! Working with Control Arrays !!
Okay So Far: I have been able to add the ListView control into the Project, and have added the source code, that last poster, LaVolpe has given to me. I have pointed the source destination of the source code to point to the c:\windows\system32 folder. If that is correct or not, please tell me if so???
No I need, more help in the way of that what LaVolpe has given me, or could you please help me, some more???
!! Thanks in advance !!