Программирование на языке MFC

Мой второй блог в серии программирования

Метод CreateEx


Нетрудно заметить, что метод Create(), в свою очередь, вызы­вает метод CreateEx():

BOOL CWnd::CreateEx(DWORD dwExStyle,

LPCTSTR IpszClassName,

LPCTSTR IpszWindowName,

DWORD dwStyle,

int x,

int y,

int nWidth,

int nHeight,

HWND hWndParent,

HMENU nIDorHMenu,

LPVOID lpParam)

{

/I allow modification of several common create parameters CREATESTRUCT cs; cs.dwExStyle = dwExStyle; cs.IpszClass = IpszClassName; cs.lpszName = IpszWindowName; cs.style = dwStyle; cs.x = x; cs.y = y; cs.cx = nWidth; cs.cy = nHeight; cs.hwndParent = hWndParent; cs.hMenu = nIDorHMenu;

cs.hlnstance = AfxGetlnstanceHandle(); cs.lpCreateParams = lpParam;

if (!PreCreateWindow(cs)) {

PostNcDestroy(); return FALSE;

}

AfxHookWindowCreate(this);

HWND hWnd = ::CreateWindowEx(cs.dwExStyle,

cs.IpszClass, cs.IpszName, cs.style, cs .x, cs.y, cs.cx, cs.cy,

cs.hwndParent,
cs.hMenu,
‘*
cs.hlnstance,

cs.lpCreateParams);

#ifdef _DEBUG

if (hWnd == NULL) {

TRACE1("Warning: Window creation failed:

GetLastError returns 0x%8.8X\n",

GetLastError ());

#endif

if (!AfxUnhookWindowCreate()) PostNcDestroy();

// cleanup if CreateWindowEx fails too soon

if (hWnd == NULL)

return FALSE;
ASSERT (hWnd == m_hWnd) ;
fl

// should have been set in send msg hook return TRUE;

}

Похожие статьи: