[HELP]Some problems in .Net MDI child form about an ActiveX control which is made with MFC

  • Thread starter ³¶¸¸ ´ÞÆØÀÌ
  • Start date
³

³¶¸¸ ´ÞÆØÀÌ

Hi~.

I make an ActiveX Control with MFC library.

Source code of this control is from default Visual C++ wizard.

It run well in MFC container and other(VB, DELPHI, ...) and .Net winform.

But!... It has some different behavior in .Net MDI child form.


The function OnCreate of ActiveX Control window is called twice in .Net MDI
child form.

I think that this appearance has some side effects.

So, sometimes some ActiveX controls with MFC are crashed and then throw
exception in .Net MDI child form.

Of course, the ActiveX control is safe in .Net winform(not child form).

Just .Net MDI child form has this situation.


My customer wants my activeX control to run in .Net MDI child form.

Please tell me the technical column, answer or solution about this
situation.

Please tell me How to block about OnCreate is twice called.
 
N

Nicholas Paldino [.NET/C# MVP]

The workaround seems simple. In the OnCreate method of your MFC
control, set a flag indicating whether or not it was called already. If the
flag has been set, then exit the function immediately. If it has not been
set, run the code, and then set the flag to true.

This insures that the code in OnCreate is only run once (which is all I
assume you would want it to run).

Hope this helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top