//----------------------------------------------------------------------------- // Name: DialogProc() // Desc: DialogProc for the dialog. This is a static class method. // // lParam: Pointer to the CBaseDialog object. // // The CBaseDialog class specifies lParam when it calls DialogBoxParam. We store the // pointer as user data in the window. // // (Note: The DirectShow CBasePropertyPage class uses the same technique.) //----------------------------------------------------------------------------- INT_PTR CALLBACK CBaseDialog::DialogProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) { CBaseDialog *pDlg = 0; // Pointer to the dialog class that manages the dialog if (msg == WM_INITDIALOG) { // Get the pointer to the dialog object and store it in // the window's user data SetWindowLongPtr(hDlg, DWLP_USER, (LONG)lParam); pDlg = (CBaseDialog*)lParam; if (pDlg) { pDlg->m_hDlg = hDlg; pDlg->OnInitDialog(); } return FALSE; } // Get the dialog object from the window's user data pDlg = (CBaseDialog*)(DWORD_PTR) GetWindowLongPtr(hDlg, DWLP_USER); if (msg == WM_COMMAND) { switch (LOWORD(wParam)) { case IDOK: if (!pDlg || pDlg->OnOK()) { EndDialog(hDlg, LOWORD(wParam)); } return TRUE; case IDCANCEL: if (!pDlg || pDlg->OnCancel()) { EndDialog(hDlg, LOWORD(wParam)); } return TRUE; } } if (pDlg) { // Let the object handle the message return pDlg->OnReceiveMsg(hDlg, msg, wParam, lParam); } else { return FALSE; } }
//----------------------------------------------------------------------------- // Name: DialogProc() // Desc: DialogProc for the dialog. This is a static class method. // // lParam: Pointer to the CBaseDialog object. // // The CBaseDialog class specifies lParam when it calls DialogBoxParam. We store the // pointer as user data in the window. // // (Note: The DirectShow CBasePropertyPage class uses the same technique.) //----------------------------------------------------------------------------- INT_PTR CALLBACK CBaseDialog::DialogProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) { CBaseDialog *pDlg = 0; // Pointer to the dialog class that manages the dialog if (msg == WM_INITDIALOG) { // Get the pointer to the dialog object and store it in // the window's user data _SetWindowLongPtr(hDlg, DWLP_USER, lParam); pDlg = (CBaseDialog*)lParam; if (pDlg) { pDlg->m_hDlg = hDlg; pDlg->CalcNcSize(); HRESULT hr = pDlg->OnInitDialog(); if (FAILED(hr)) { pDlg->EndDialog(0); } } return FALSE; } // Get the dialog object from the window's user data pDlg = _GetWindowLongPtr<CBaseDialog*>(hDlg, DWLP_USER); if (pDlg != NULL) { switch (msg) { case WM_COMMAND: switch (LOWORD(wParam)) { case IDOK: if (pDlg->OnOK()) { pDlg->EndDialog(IDOK); } return TRUE; case IDCANCEL: if (pDlg->OnCancel()) { pDlg->EndDialog(IDCANCEL); } return TRUE; default: return pDlg->OnCommand((HWND)lParam, LOWORD(wParam), HIWORD(wParam)); } break; case WM_NOTIFY: return pDlg->OnNotify((NMHDR*)lParam); default: return pDlg->OnReceiveMsg(msg, wParam, lParam); } } else { return FALSE; } }