(HELPLESS CASE) How dynamically add Controls from other-not referenced project!?
From: [SolarAngel] (not-for-mail)
Date: 06/15/04
- Next message: Michael Culley: "Re: (HELPLESS CASE) How dynamically add Controls from other-not referenced project!?"
- Previous message: Dave: "Re: Location of .ocx and .dll files?"
- Next in thread: Michael Culley: "Re: (HELPLESS CASE) How dynamically add Controls from other-not referenced project!?"
- Reply: Michael Culley: "Re: (HELPLESS CASE) How dynamically add Controls from other-not referenced project!?"
- Reply: Grinder: "Re: (HELPLESS CASE) How dynamically add Controls from other-not referenced project!?"
- Reply: Beeeeeves: "Re: (HELPLESS CASE) How dynamically add Controls from other-not referenced project!?"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 16 Jun 2004 01:22:45 +0200
It seems a little problem for beginning, but I was unable to find solution in 1 week.
I have one project (in further test named as EXE) that load controls from other (not referenced) Project (in further text named as
OCX) created
in VB. Where in EXE I don't use reference to OCX, cause I need to read different controls, depending on some other value.
Ok, here it is how I managed to do it:
I declare some variable WithEvents type of VBControlExtender then call method Add in Controls class of some Form,
legally trough VB!?
Code looks something like this:
(View Licenses.Add VB Reference for more information)
-----------------
Dim WithEvents Ctrl As VBControlExtender
Public sub Form_Load()
' some test to add license if needed and error handler !?
Set Ctrl = Me.Controls.Add("SomeProject.ControlName", "MyControl")
' assuming that "MyControl" is not taken name for some other control on that form
Ctrl.Visible = True
Ctrl.Move 0,0,ScaleWidth, ScaleHeight
End Sub
Public Sub Form_Unload()
Me.Controls.Remove "MyControl" 'The control's name.
' also don't forget to remove license if you have added one previously (GPF may occur)
End Sub
-----------------
I have some api example using CreateObject, SetParent, ShowWindow, but above example is more VB q=)
Both have same problem!!!
PROBLEM:
ok this code works when project OCX is compiled or in Group project with EXE Project,
but for me most significant thing doesn't work. I need to provide compiled EXE project that can load Control from VB Project
Runtime.
means that EXE that loads control is compiled, and Control is in VB IDE (started) exposing interface of control trough vb6debug.dll!
vb6debug.dll seam that doesn't work very well!?
I had similar problem with implementation of some other Interfaces but I have found solution for that, but that solution can not be
applied for the controls!
To reproduce environment of my need you can do next thing:
=========================================
1. Open two instances of VB in first one make Standalone EXE Project, and Second one ActiveX Control (OCX).
2. In OCX Create control with Orange background, for example OCXProject.OrangeControl
3. In EXE add on form one text box and one button, and needed code explained above how to, and use textbox as source name of
ProjectOCX.ControlName.
4. Add on Button Click event code to create control and set its visibility and size
5. Now run OCX project and than run EXE project, type in textbox "OCXProject.OrangeControl" or what ever you have named your
control.
You will end With Error!? Control isn't registered, right!?
OK, Now save both projects and Add to EXE project OCXProject to be a group project,
Don't add reference in EXE to OCX (so we can load from external not depending project)!!!
And repeat step 5. now everything works, Why!?
Well I don't know, but I can't give 10mb of mine code to all programmers that need to write a plugin so they can test/debug... their
plugins.
There must be some solution but I must be blind.
I appreciate all help or points where I am wrong or anything... please
I believe that everything is possible until it is proven not to be!
I hope it will not be proven q=)
[SolarAngel]
Helpless case
- Next message: Michael Culley: "Re: (HELPLESS CASE) How dynamically add Controls from other-not referenced project!?"
- Previous message: Dave: "Re: Location of .ocx and .dll files?"
- Next in thread: Michael Culley: "Re: (HELPLESS CASE) How dynamically add Controls from other-not referenced project!?"
- Reply: Michael Culley: "Re: (HELPLESS CASE) How dynamically add Controls from other-not referenced project!?"
- Reply: Grinder: "Re: (HELPLESS CASE) How dynamically add Controls from other-not referenced project!?"
- Reply: Beeeeeves: "Re: (HELPLESS CASE) How dynamically add Controls from other-not referenced project!?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|