This is because
m_hWnd
is required to be a valid window handle registers in Windows at the moment of the call. As you never show other calls where
m_hWnd
is involved, it's hard to say what exactly missing, but the idea is simple: a window's should be created and assigned to this member prior to calling the function with this assertion. The assertion simply tries to protect you from this inconsistency and suggest you the fix.
At the level of raw Windows API, the handle is created by one of these calls:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms632679%28v=vs.85%29.aspx[
^],
http://msdn.microsoft.com/en-us/library/windows/desktop/ms632680%28v=vs.85%29.aspx[
^].
It does not mean that you have to call one of these functions directly. The very usual mistake is: the window handle is created somewhere, but you call the method with assertion
too early. You would need to call it
later. For example, you could call it when a window is already shown. This would be even too late, but 100% sure that the handle is already created.
—SA