Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script Control, Dynamic Control Creation, and Dynamic Control Events

Status
Not open for further replies.

NipsMG

Programmer
Dec 27, 2000
215
US
Hey everyone.

I have been messing around with the Scripting Control and Dynamic Control Creation.. I think it's amazingly powerful to have a program that can be extended by an end user by using VB Scripting commands. I'm actually developing a system that will allow scripts to be written, saved, and run on start-up of my program to create any additional forms or controls that end users have created so it is as if they have been there the whole time.

My problem is this:

I am creating controls as follows:

I Created a class ScriptingFunctions and added some functions to it, instantiate the class, and add the object to the ScriptControl so that i can have full control of the functions.

I run a function called AddObjectToForm(ByVal sFormName as string, byVal sObjectType as string, ByVal sObjectName as String).

It loops through vb.forms, finds the form with the name you sent, selects it, and does the following:


frmForm.Controls.Add sObjectType, sObjectName

I then call, from script, a function already in the form called "GiveAccessTo" which adds the object with the form name as a prefix to the ScriptControl.. so if I just created a "Vb.CommandButton" with name "cmdNew", I can access it through the scripting control now using "frmFormcmdNew.Caption = "NewCaption""


My problem is, however....

How can I add code .. through the scripting control, for the events on the new control I just created?

I could see creating a new windowproc in the scripting control and doing a SetWindowLong w/ GWL_WNDPROC to subclass the window procedure, but I'm not sure what I would have to do with the function? Should I have a MsScriptControlCTL.Module and add the function to that, and reference that function via AddressOf to get the pointer to that function?

Don't forget, I know when the program ends, all of this will go away, but Like I said, I plan to have the script saved so it will execute on startup.

I'd really appreciate any help anyone could give me on this.

Thanks a lot in advance! :)
--NipsMG s-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top