Example #1
0
BOOL CALLBACK DialogProc(HWND hwnd,
						 UINT message,
						 WPARAM wParam,
						 LPARAM lParam)
{
	CDialog *pDlg = NULL;

	switch (message)
	{
	case WM_INITDIALOG:
		pDlg = (CDialog*)lParam;
		return pDlg->OnInit(hwnd);

	case WM_COMMAND:
		pDlg = (CDialog*)::GetWindowLong(hwnd, DWL_USER);
		return pDlg->OnCommand(LOWORD (wParam), HIWORD (wParam));

	case WM_DESTROY:
		::PostQuitMessage(0);
		return TRUE;

	case WM_CLOSE:
		pDlg = (CDialog*)::GetWindowLong(hwnd, DWL_USER);
		return pDlg->OnClose();
	}
	return FALSE;
}
Example #2
0
INT_PTR WINAPI CDialog::DialogProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	if(msg == WM_INITDIALOG)
	{
		return TRUE;
	}
	CDialog* pThis = static_cast<CDialog*>(GetClassPtr(hWnd));
	if(pThis == NULL)
	{
		return FALSE;
	}
	switch(msg)
	{
	case WM_CLOSE:
		if(!pThis->OnClose()) return FALSE;
		break;
	case WM_CTLCOLORSTATIC:
		return pThis->OnCtlColorStatic((HDC)wParam, (HWND)lParam);
		break;
	case WM_SIZE:
		if(!pThis->OnSize(static_cast<unsigned int>(wParam), LOWORD(lParam), HIWORD(lParam))) return FALSE;
		break;
	case WM_TIMER:
		if(!pThis->OnTimer(wParam)) return FALSE;
		break;
	case WM_COMMAND:
		if(!pThis->OnCommand(LOWORD(wParam), HIWORD(wParam), (HWND)lParam)) return FALSE;
		break;
	case WM_SYSCOMMAND:
		if(!pThis->OnSysCommand(static_cast<unsigned int>(wParam), lParam)) return FALSE;
		break;
	case WM_NOTIFY:
		return pThis->OnNotify(wParam, reinterpret_cast<NMHDR*>(lParam));
		break;
	case WM_NCDESTROY:
		pThis->m_hWnd = NULL;
		return FALSE;
		break;
	}
	if(!pThis->OnWndProc(msg, wParam, lParam)) return FALSE;
	return FALSE;
}