1

I'm creating an ActiveX using VS and MFC. Initialisation is done in constructor of my control. There the m_hWND window handle is not valid, it is still NULL.

So: is there some kind of "initialisation complete" function available in COleControl() that is called as soon as m_hWnd is valid and additional controls can be added to it?

Thanks!

Elmi
  • 5,899
  • 15
  • 72
  • 143
  • 1
    I normally do lazy initialisation from the `OnDraw` or `OnPaint` handler but have you tried `OnCreate`? – Roger Rowland Jan 27 '14 at 11:44
  • Hm, OnCreate is not called. Currently I'm suing OnDraw() too but I'm not sure if this is the correct place for this! – Elmi Jan 27 '14 at 12:11
  • 1
    Yes, depending on the client, sometimes `OnCreate` doesn't get called, that's why I do the same as you. It's by far the safest approach IMHO. – Roger Rowland Jan 27 '14 at 12:13

3 Answers3

0

It's been a while since I've written an ActiveX control, but, I seem to remember using OnResetState, or, one of the other events shown in the link to handle initialization.

rrirower
  • 4,338
  • 4
  • 27
  • 45
  • Unfortunately not, m_hWnd is still NULL when OnResetState() is called. I go with OnDraw() now since this seems to be a widely used method for initialisation. – Elmi Jan 28 '14 at 06:41
0

Remember that there are windowless ActiveX controls. For such controls you never get a window handle! So normally after the creation a ActiveX Control is "initialized", and you can use it.

ActiveX controls usually reside in the same Thread so there is nothing that can run beside your code and do further initialization.

If this doesn't help you Need to refine your question.

See discussion here too about ActiveX controls without a window handle.

Community
  • 1
  • 1
xMRi
  • 14,982
  • 3
  • 26
  • 59
0

I think OnActivate is what you are looking for.

thomiel
  • 2,467
  • 22
  • 37