BOOL CALLBACK DispatchResponseProc(void* pCaller, // Caller LPARAM lParam, // application-defined value WPARAM wParam // application-defined value ) { CBaseDialog *dlg = (CBaseDialog *)pCaller; dlg->DealwithResponseProc(lParam, wParam); return TRUE; }
//----------------------------------------------------------------------------- // 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; } }
INT_PTR CALLBACK CBaseDialog::InitialDlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { if (uMsg == WM_INITDIALOG) { CBaseDialog* dialog = (CBaseDialog*)lParam; dialog->m_Window = hWnd; SetWindowLongPtr(hWnd, DWLP_USER, (LONG_PTR)dialog); SetWindowLongPtr(hWnd, DWLP_DLGPROC, (LONG_PTR)MainDlgProc); return dialog->HandleMessage(uMsg, wParam, lParam); } return FALSE; }
void CCtrlDesktop::OnMouse(float wx, float wy, bool lBtn, bool rBtn) { for (size_t k = 0; k < dialogs.size(); k++) { CBaseDialog* dlg = dialogs.at(k); if (dlg->InControl(wx, wy))//определили диалог "под мышкой" { dlg->OnMouse(wx, wy, lBtn, rBtn); //передаем нажатие в диалог. return; } } }
void CBaseDialog::UpdateSkin() { RenderEngine->RemoveImage(m_pImageBack); m_pImageBack = RenderEngine->GetImage(theApp.m_szDefaultSkin); for (int i=0;i<theApp.m_WindowArray.size();i++) { CBaseDialog * pBaseDialog = theApp.m_WindowArray.at(i); if (pBaseDialog->GetSafeHwnd() == NULL ) continue; pBaseDialog->ModifyStyle(WS_CLIPCHILDREN,0); pBaseDialog->Invalidate(FALSE); pBaseDialog->ModifyStyle(0,WS_CLIPCHILDREN); } }
BOOL CALLBACK EnumChildProc( HWND hwnd, // handle to child window LPARAM lParam // application-defined value ) { TCHAR classname[200]; TCHAR ctrltext[20]={0}; CBaseDialog *dlg = (CBaseDialog *)lParam; DWORD style; GetClassName( hwnd, classname, 200 ); style = GetWindowStyle( hwnd ); /////// /* GetDlgItemText(hwnd,IDC_BUTTON_NUM_HASH,ctrltext,19); if (strcmp(ctrltext, "#") == 0) { dlg->SubClassButton( hwnd ); } */ /////// if (wcscmp(classname, _T("Button")) == 0) { style = (UINT)GetWindowLong(hwnd, GWL_STYLE) & 0xff; //BS_PUSHBUTTON:发送消息按钮 //Creates a pushbutton that posts a WM_COMMAND message to the owner window //when the user selects the button. //BS_DEFPUSHBUTTON:默认按钮 //Creates a button that has a heavy black border. //The user can select this button by pressing the ENTER key. //This style enables the user to quickly select the most likely option //(the default option). if ( style == BS_PUSHBUTTON || style == BS_DEFPUSHBUTTON ) { dlg->SubClassButton( hwnd ); } } return TRUE; }
//----------------------------------------------------------------------------- // 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; } }
INT_PTR CALLBACK CBaseDialog::MainDlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { CBaseDialog* dialog = (CBaseDialog*)GetWindowLongPtr(hWnd, DWLP_USER); return dialog->HandleMessage(uMsg, wParam, lParam); }