The problem is that the control is not actaully initialized when you first call MoveWindow on the graph control. When Onsize is called while the Window is being created, m_graph's handle will not be ready, hence causing the assertion when you try to manipulate the control. This is not a problem specific to the CWGraph control, it is pretty much standard with all MFC controls. You'll see the same thing happen if you do the same thing with a command button.
Your workaround is the correct way to set this up. You could also have use a boolean to indicate when the window has finished initializing and then change the size of the graph control. Either way, MFC has to initialize the control before it can do anything to it.
I hope this helps
Bi
lal Durrani
NI
Bilal Durrani
NI