I’m writing a custom control derived from CWnd. I want to initialize a member variable (e.g: a memory dc) of my custom control class using its device context. Which is the correct way to do it? I guess device context won’t be ready in the constructor. So what is the next option. Is it safe using the dc the OnCreate event? I’m probably in search of something like OnInitDialog, but its a custom control, not a dialog.
Update: I added the custom control to the parent dialog via resource editor. So there is no chance for getting WM_CREATE event as it has already been created before subclassing.
Device context can be created in
OnCreate(WM_CREATE), after you call the base class’ OnCreate method.http://msdn.microsoft.com/en-us/library/dd318297(v=vs.85).aspx
From Programming Windows