tags:

views:

46

answers:

1

I have an OnMove handler in my dialog class, which does some stuff with control objects (i.e a CButton). I'm finding this handler gets called before the dialog OnInitDialog method is called, and hence when I try to call methods on the child controls, I get ASSERTS in debug as the controls don't yet exist... they are created in OnInitDialog.

There's two things I'd like to be able to check:

  1. How do I tell the dialog has been initialized?
  2. How do I check an individual CWnd control object's window has been created?

In both cases I'm looking for class members or method call results that can be used.

+1  A: 
  1. Set a flag in OnInitDialog, or use (2) for your dialog's m_hWnd

  2. if ( ::IsWindow(m_Ctrl.m_hWnd) ) { ... }

Roel
I don't want to write custom code, so 2 sounds preferable. Are there any other members I could test?
John
GetSafeHwnd() but it's just a wrapper around ::IsWindow(). In term of object-orientedness I guess it's nicer than querying the handle manually - I like the 'low-level' control of inspecting the handle, personally.
Roel