form_load is not suitable
-
I have windowsform that display Word document using DSOFramer activex from microsoft support website and i put the code that load this doc at load event of the form, but it doesn't work and when i added button to the form and made this button_click loads the word file it works so i think that the form.load event is not suitable and i do not know how to make this file opens auomaticly without using the form load event thnx in advance
-
I have windowsform that display Word document using DSOFramer activex from microsoft support website and i put the code that load this doc at load event of the form, but it doesn't work and when i added button to the form and made this button_click loads the word file it works so i think that the form.load event is not suitable and i do not know how to make this file opens auomaticly without using the form load event thnx in advance
It's worked for me in the past to simply override the
Form.OnHandleCreated
method (it's better to override in derived classes than handle events) for ActiveX controls using something like:public class MyForm : Form
{
// ...
protected override void OnHandleCreated(EventArgs e)
{
base.OnHandleCreated(e); //
// Put your initialization code here and add it to the Controls property
}
}The ActiveX control will most likely require a window handle (
HWND
) in which to be sited (parented). Callingbase.OnHandleCreate
first makes sure that everything is set up correctly. This handler is called byCreateHandle
after creating the handle. It's possible that the DSOFramer requires something different, though. You should check the Microsoft KB[^] or any existing product site for that control for specifics.Microsoft MVP, Visual C# My Articles