Re: AxHost and ActiveX initialization

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Peter, hi,

Thanks for the response, and sorry for the confusion. What I need a copy of
the ActiveX component for each account. Each copy will manage a connection
to the server. If I just create an instance of the component, however, the
component is not initialized properly. That gives me the
InvalidActiveXStateException with the first call to thecomponent.

If instead I only use the object generated by VS from pretending the
component is visible (placing it on a form), I have no problem.

Finally, if I pursue option One (simply create instances of the component as
I need them) and then duplicate the code VS uses to initialize, I again get
the InvalidActiveXStateException error.

So my question is, what am I missing in my initialization? I'll include my
code at the end of this message. What is the "secret sauce" VS is performing
to initialize a "visible" component that I need to do on an "invisible"
component? In particular, I don't understand what the correct syntax for the
resources.GetObject("MytwsObj.OcxState")

should be.

Thanks for your help!

Regards,
Raj

Here is my initialization code "copied" from similar code generated by VS:
private AxTWSLib.AxTws MytwsObj;

MytwsObj = new AxTWSLib.AxTws();

System.ComponentModel.ComponentResourceManager resources = new
System.ComponentModel.ComponentResourceManager(typeof(TWSInterface));

((System.ComponentModel.ISupportInitialize)(MytwsObj)).BeginInit();

MytwsObj.Enabled = true;

MytwsObj.Name = "axTws0" + account;

MytwsObj.OcxState =
((System.Windows.Forms.AxHost.State)(resources.GetObject("MytwsObj.OcxState")));



""Peter Huang" [MSFT]" <v-phuang@xxxxxxxxxxxxxxxxxxxx> wrote in message
news:K3TwC0NaGHA.880@xxxxxxxxxxxxxxxxxxxxxxxx
Hi

Do you mean you just want one instance of the ActiveX class in memory in
the lifetime of the form1?
If so, we can delare the object in the form level but not in certian
method.
e.g.
class Form1
{
IABCObj o = new ABCObjClass();
Form1()
{
}
....
}


Also we can create more than one form1 instance.
e.g.
In certian method, we can call.
Form1 fm = new Form1();
fm.Show();

So that another form1 will show in addition to the original one.

"Or is there a way to "drop" multiple copies of the component onto a
running form? "
I did not understand the question. Do you mean you want to drop more than
one ActiveX component onto form1 and run Form1?
If so, we just need to drag&drop more than one onto the form.


Best regards,

Peter Huang

Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no
rights.



.



Relevant Pages

  • Re: Keeping invisible forms from showing at start-up
    ... > Paul E. Schoen wrote: ... >> The following code is part of my Delphi project file: ... Application.Terminate in Form1, after doing some clean-up. ... I thought this was done at initialization if explicitly set in Project ...
    (comp.lang.pascal.delphi.misc)
  • Re: Getting data from another form
    ... The trick to designing the confirmation form ... form2, where form2 is the response to form1. ...
    (microsoft.public.outlook.program_forms)
  • Re: Difference between Form1() and Form1_Load() ?
    ... load of Form1. ... the constructor is executed before the all of the underlying Windows data has been initialized. ... you should wait until the Load event to do anything that involves actually interacting with Windows. ... But for any sort of internal data initialization, the constructor is a perfectly appropriate to do that. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: AxHost and ActiveX initialization
    ... Do you mean you just want one instance of the ActiveX class in memory in ... the lifetime of the form1? ... we can delare the object in the form level but not in certian method. ... one ActiveX component onto form1 and run Form1? ...
    (microsoft.public.dotnet.framework.interop)