I know you can load as many a activex controls as you want to a form during runtime. But you have to have atleast one of those controls, with index '0'. Then you give...
VB Code:
Load ControlName(UBound(ControlName))
ControlName.Move 100, 100, 500, 300
ControlName.Visible = True
'etc...
But I want to know if it is possible to add during runtime if....
1. It is added as a component, but not added to the form during design time.
2. Nothing has been done in relation to the control during design time. ie... the path of the activex control is got during runtime and then the form loads it.
THE TIME/WEATHER IS
Don't know how to use APIs or have problem with them,
Download API-Guide & API-Viewer from http://www.allapi.net
I'm not sure about CommandBtn and other controls, that are directly part of the runtime. But for Usercontrols and properly also other controls you can use this
Me.Controls.Add <Name of UserControl>, <Key to identify control>
The name must be somthing like this: LibraryName.ControlName, if you know what I mean.
I will need to add controls to my forms during runtime. Controls maybe common vb controls, where I can easily use the load function. But what if the user wants to add a custom control
THE TIME/WEATHER IS
Don't know how to use APIs or have problem with them,
Download API-Guide & API-Viewer from http://www.allapi.net
What do you mean by without setting reference? you mean without assigning object to the object variable?? If you don't do so... how would you be able to set its visibility to True and other properties????
I think I couldn't get your question.
If you want to add an activex control, you select 'Components' from from the 'Project' menu in VB. Then you check the components you want from the list and click OK. The required controls get added to the toolbar. I want to do this in my vb app also. ie... through some code I want to add activex controls in my form, even though I haven't made it available through the components window shown in the picture attached.
THE TIME/WEATHER IS
Don't know how to use APIs or have problem with them,
Download API-Guide & API-Viewer from http://www.allapi.net
Thank You. That is just what I wanted. But now, I got to figure out how to get the Library Name and the Control Name from a selected file. I checked out API-GUIDE. This code shows how to use an API without declaring it.
VB Code:
'Create a new project and add this code to Form1
Private Declare Function FreeLibrary Lib "kernel32" (ByVal hLibModule As Long) As Long
Private Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long
Private Declare Function GetProcAddress Lib "kernel32" (ByVal hModule As Long, ByVal lpProcName As String) As Long
Private Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Any, ByVal wParam As Any, ByVal lParam As Any) As Long
Just another problem. Add a button 'Command1' to a form and paste the following.
When the command1 button is pressed it gives me an object required error.
VB Code:
Private Sub Command1_Click()
ADODC1.Visible = False
End Sub
Private Sub Form_Load()
Dim lKey As String
lKey = Licenses.Add("MSADODCLib.ADODC")
With Controls.Add("MSADODCLib.ADODC", "ADODC1")
.Move 100, 100, 5000, 500
.Visible = True
End With
End Sub
THE TIME/WEATHER IS
Don't know how to use APIs or have problem with them,
Download API-Guide & API-Viewer from http://www.allapi.net