The difference between the WS_CHILD and WS_POPUP windows created by CWnd
Recently, I was writing a self-painted window derived from CWnd. Previously, the Create FUNCTION FOR Packaging my own classes was written like this:
Bool CGG: Create (DWORD dwstyle, const rect & rect, cwnd * pparentwnd, uint NID, ccreatecontext * pcontext) <br/>{< br/> If (! Cwnd: Create (guoguotipsupwindow_classname, null, dwstyle, rect, pparentwnd, NID, pcontext) <br/> return false; </P> <p> return true; <br/>}< br/>
This is also the case. The WS_CHILD windows previously created are called as follows:
DWORD style = WS_CHILD | WS_OVERLAPPED;
M_tooltips.Create (style, CRect (0, 0, 300,300), NULLthis, NULL, NULL );
No problem.
This time we will create a WS_POPUP window, which will be called as follows:
DWORD style = WS_POPUP | WS_OVERLAPPED;
M_tooltips.Create (style, CRect (0, 0, 300,300), NULL );
However, the result is crash and depressing.
After checking for half a day, we found that the implementation of the Create FUNCTION had a problem.
The CWnd: Create Function can only Create window styles that are not WS_POPUP. To create a WS_POPUP window and an extended window, you must call CWnd: CreateEx.
MSDN description of Create:
Creates and initializes the child window associated withCwndObject.
Description of CreateEx on MSDN:
Creates a Windows overlapped, pop-up, or child window and attaches it toCwndObject.