1 /* 2 * PROJECT: input.dll 3 * FILE: dll/cpl/input/input.c 4 * PURPOSE: input.dll 5 * PROGRAMMER: Dmitry Chapyshev (lentind@yandex.ru) 6 * Colin Finck 7 * UPDATE HISTORY: 8 * 06-09-2007 Created 9 */ 10 11 #include "input.h" 12 13 #define NUM_APPLETS (1) 14 15 static LONG CALLBACK SystemApplet(HWND hwnd, UINT uMsg, LPARAM lParam1, LPARAM lParam2); 16 17 HINSTANCE hApplet = NULL; 18 19 /* Applets */ 20 static APPLET Applets[NUM_APPLETS] = 21 { 22 {IDI_CPLSYSTEM, IDS_CPLSYSTEMNAME, IDS_CPLSYSTEMDESCRIPTION, SystemApplet} 23 }; 24 25 26 static VOID 27 InitPropSheetPage(PROPSHEETPAGEW *page, WORD idDlg, DLGPROC DlgProc) 28 { 29 ZeroMemory(page, sizeof(*page)); 30 31 page->dwSize = sizeof(*page); 32 page->dwFlags = PSP_DEFAULT; 33 page->hInstance = hApplet; 34 page->pszTemplate = MAKEINTRESOURCEW(idDlg); 35 page->pfnDlgProc = DlgProc; 36 } 37 38 static int CALLBACK 39 PropSheetProc(HWND hwndDlg, UINT uMsg, LPARAM lParam) 40 { 41 // NOTE: This callback is needed to set large icon correctly. 42 HICON hIcon; 43 switch (uMsg) 44 { 45 case PSCB_INITIALIZED: 46 { 47 hIcon = LoadIconW(hApplet, MAKEINTRESOURCEW(IDI_CPLSYSTEM)); 48 SendMessageW(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)hIcon); 49 break; 50 } 51 } 52 return 0; 53 } 54 55 /* First Applet */ 56 static LONG CALLBACK 57 SystemApplet(HWND hwnd, UINT uMsg, LPARAM lParam1, LPARAM lParam2) 58 { 59 PROPSHEETPAGEW page[2]; 60 PROPSHEETHEADERW header; 61 62 ZeroMemory(&header, sizeof(header)); 63 64 header.dwSize = sizeof(header); 65 header.dwFlags = PSH_PROPSHEETPAGE | PSH_USEICONID | PSH_USECALLBACK; 66 header.hwndParent = hwnd; 67 header.hInstance = hApplet; 68 header.pszIcon = MAKEINTRESOURCEW(IDI_CPLSYSTEM); 69 header.pszCaption = MAKEINTRESOURCEW(IDS_CPLSYSTEMNAME); 70 header.nPages = ARRAYSIZE(page); 71 header.nStartPage = 0; 72 header.ppsp = page; 73 header.pfnCallback = PropSheetProc; 74 75 /* Settings */ 76 InitPropSheetPage(&page[0], IDD_PROPPAGESETTINGS, SettingsPageProc); 77 78 /* Advanced Settings */ 79 InitPropSheetPage(&page[1], IDD_PROPPAGEADVANCEDSETTINGS, AdvancedSettingsPageProc); 80 81 return (LONG)(PropertySheetW(&header) != -1); 82 } 83 84 85 /* Control Panel Callback */ 86 LONG CALLBACK 87 CPlApplet(HWND hwndCPl, UINT uMsg, LPARAM lParam1, LPARAM lParam2) 88 { 89 CPLINFO *CPlInfo; 90 UINT i = (UINT)lParam1; 91 92 switch (uMsg) 93 { 94 case CPL_INIT: 95 return TRUE; 96 97 case CPL_GETCOUNT: 98 return NUM_APPLETS; 99 100 case CPL_INQUIRE: 101 if (i < NUM_APPLETS) 102 { 103 CPlInfo = (CPLINFO*)lParam2; 104 CPlInfo->lData = 0; 105 CPlInfo->idIcon = Applets[i].idIcon; 106 CPlInfo->idName = Applets[i].idName; 107 CPlInfo->idInfo = Applets[i].idDescription; 108 } 109 else 110 { 111 return TRUE; 112 } 113 break; 114 115 case CPL_DBLCLK: 116 if (i < NUM_APPLETS) 117 Applets[i].AppletProc(hwndCPl, uMsg, lParam1, lParam2); 118 else 119 return TRUE; 120 break; 121 } 122 123 return FALSE; 124 } 125 126 127 BOOL WINAPI 128 DllMain(HINSTANCE hinstDLL, DWORD dwReason, LPVOID lpvReserved) 129 { 130 UNREFERENCED_PARAMETER(lpvReserved); 131 132 switch (dwReason) 133 { 134 case DLL_PROCESS_ATTACH: 135 case DLL_THREAD_ATTACH: 136 hApplet = hinstDLL; 137 break; 138 } 139 140 return TRUE; 141 } 142 143 /* EOF */ 144