LRESULT CDeviceView::OnAction( _In_ UINT Action ) { switch (Action) { case IDC_PROPERTIES: { DisplayPropertySheet(); break; } case IDC_SCAN_HARDWARE: { Refresh(GetCurrentView(), true, true); break; } case IDC_ENABLE_DRV: { bool NeedsReboot; if (EnableSelectedDevice(true, NeedsReboot) && NeedsReboot) { MessageBox(m_hMainWnd, L"Rebooting", L"Enable", MB_OK); } break; } case IDC_DISABLE_DRV: { bool NeedsReboot; EnableSelectedDevice(false, NeedsReboot); break; } case IDC_UPDATE_DRV: { bool NeedsReboot; UpdateSelectedDevice(NeedsReboot); break; } case IDC_UNINSTALL_DRV: { UninstallSelectedDevice(); break; } case IDC_ADD_HARDWARE: { RunAddHardwareWizard(); break; } } return 0; }
///////////////////////////////////////////////////////////////////////////////// // CPlApplet ///////////////////////////////////////////////////////////////////////////////// // This function is called by the control panel manager. It is very similar to // a Windows message handler (search for CplApplet in MSDN for description). // // Arguments: // HWND hWnd Parent window handle // UINT uMsg The message // LPARAM lParam1 depends on message // LPARAM lParam2 depends on message // // Return Value: // LONG (depends on message; in general 0 means failure). // LONG APIENTRY CPlApplet (HWND hWnd, UINT uMsg, LPARAM lParam1, LPARAM lParam2) { switch (uMsg) { // Initialize. You can allocate memory here. case CPL_INIT: return TRUE; // How many applets are in this DLL? case CPL_GETCOUNT: return 1; // Requesting information about the dialog box. // lParam1 is the dialog box number (we have only one) and // lParam2 is the pointer to a CPLINFO structure. // There is no return value. case CPL_INQUIRE: { UINT uAppNum = (UINT)lParam1; LPCPLINFO pCplInfo = (LPCPLINFO)lParam2; if (!pCplInfo) return TRUE; // unsuccessful if (uAppNum == 0) // first Applet? { pCplInfo->idIcon = IDI_AC97CPL; pCplInfo->idName = IDS_AC97CPL; pCplInfo->idInfo = IDS_AC97CPLINFO; } break; } // This is basically the same as CPL_INQUIRE, but passes a pointer // to a different structure. // This function is called before CPL_INQUIRE and if we return zero // here, then CPL_INQUIRE is called. case CPL_NEWINQUIRE: break; // One of these messages are sent when we should display the dialog box. // There is no return value. // lParam1 is the dialog box number (we have only one) case CPL_DBLCLK: case CPL_STARTWPARMS: { UINT uAppNum = (UINT)lParam1; if (uAppNum == 0) // first Applet? DisplayPropertySheet (hWnd); break; } // We get unloaded in a second. // There is no return value. case CPL_EXIT: break; default: // Who knows? break; } return 0; }