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_KEY_SHORT_ICO)); 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 WCHAR szCaption[MAX_STR_LEN]; 62 63 LoadStringW(hApplet, IDS_CPLSYSTEMNAME, szCaption, ARRAYSIZE(szCaption)); 64 65 ZeroMemory(&header, sizeof(header)); 66 67 header.dwSize = sizeof(header); 68 header.dwFlags = PSH_PROPSHEETPAGE | PSH_USEICONID | PSH_USECALLBACK; 69 header.hwndParent = hwnd; 70 header.hInstance = hApplet; 71 header.pszIcon = MAKEINTRESOURCEW(IDI_KEY_SHORT_ICO); 72 header.pszCaption = szCaption; 73 header.nPages = ARRAYSIZE(page); 74 header.nStartPage = 0; 75 header.ppsp = page; 76 header.pfnCallback = PropSheetProc; 77 78 /* Settings */ 79 InitPropSheetPage(&page[0], IDD_PROPPAGESETTINGS, SettingsPageProc); 80 81 /* Advanced Settings */ 82 InitPropSheetPage(&page[1], IDD_PROPPAGEADVANCEDSETTINGS, AdvancedSettingsPageProc); 83 84 return (LONG)(PropertySheetW(&header) != -1); 85 } 86 87 88 /* Control Panel Callback */ 89 LONG CALLBACK 90 CPlApplet(HWND hwndCPl, UINT uMsg, LPARAM lParam1, LPARAM lParam2) 91 { 92 CPLINFO *CPlInfo; 93 DWORD i; 94 95 i = (DWORD)lParam1; 96 97 switch (uMsg) 98 { 99 case CPL_INIT: 100 return TRUE; 101 102 case CPL_GETCOUNT: 103 return NUM_APPLETS; 104 105 case CPL_INQUIRE: 106 CPlInfo = (CPLINFO*)lParam2; 107 CPlInfo->lData = 0; 108 CPlInfo->idIcon = Applets[i].idIcon; 109 CPlInfo->idName = Applets[i].idName; 110 CPlInfo->idInfo = Applets[i].idDescription; 111 break; 112 113 case CPL_DBLCLK: 114 Applets[i].AppletProc(hwndCPl, uMsg, lParam1, lParam2); 115 break; 116 } 117 118 return FALSE; 119 } 120 121 122 BOOL WINAPI 123 DllMain(HINSTANCE hinstDLL, DWORD dwReason, LPVOID lpvReserved) 124 { 125 UNREFERENCED_PARAMETER(lpvReserved); 126 127 switch (dwReason) 128 { 129 case DLL_PROCESS_ATTACH: 130 case DLL_THREAD_ATTACH: 131 hApplet = hinstDLL; 132 break; 133 } 134 135 return TRUE; 136 } 137 138 /* EOF */ 139