Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

379 lines
9.3 KiB

  1. //
  2. // Include Files.
  3. //
  4. #include "input.h"
  5. #include <cpl.h>
  6. #include <commctrl.h>
  7. #include "util.h"
  8. //
  9. // Constant Declarations.
  10. //
  11. #define MAX_PAGES 3 // limit on the number of pages
  12. //
  13. // Global Variables.
  14. //
  15. HANDLE g_hMutex = NULL;
  16. TCHAR szMutexName[] = TEXT("TextInput_InputLocaleMutex");
  17. HANDLE g_hEvent = NULL;
  18. TCHAR szEventName[] = TEXT("TextInput_InputLocaleEvent");
  19. HINSTANCE hInstance;
  20. HINSTANCE hInstOrig;
  21. HINSTANCE hInstRes;
  22. //
  23. // Function Prototypes.
  24. //
  25. void
  26. DoProperties(
  27. HWND hwnd,
  28. LPCTSTR pCmdLine);
  29. ////////////////////////////////////////////////////////////////////////////
  30. //
  31. // LibMain
  32. //
  33. // This routine is called from LibInit to perform any initialization that
  34. // is required.
  35. //
  36. ////////////////////////////////////////////////////////////////////////////
  37. BOOL APIENTRY LibMain(
  38. HANDLE hDll,
  39. DWORD dwReason,
  40. LPVOID lpReserved)
  41. {
  42. switch (dwReason)
  43. {
  44. case ( DLL_PROCESS_ATTACH ) :
  45. {
  46. hInstance = hDll;
  47. hInstOrig = hInstance;
  48. //
  49. // Create the mutex used for the Input Locale property page.
  50. //
  51. g_hMutex = CreateMutex(NULL, FALSE, szMutexName);
  52. g_hEvent = CreateEvent(NULL, TRUE, TRUE, szEventName);
  53. DisableThreadLibraryCalls(hDll);
  54. InitCommonControls();
  55. break;
  56. }
  57. case ( DLL_PROCESS_DETACH ) :
  58. {
  59. if (g_hMutex)
  60. {
  61. CloseHandle(g_hMutex);
  62. }
  63. if (g_hEvent)
  64. {
  65. CloseHandle(g_hEvent);
  66. }
  67. // Free XP SP1 resource instance if we loaded
  68. FreeCicResInstance();
  69. break;
  70. }
  71. case ( DLL_THREAD_DETACH ) :
  72. {
  73. break;
  74. }
  75. case ( DLL_THREAD_ATTACH ) :
  76. default :
  77. {
  78. break;
  79. }
  80. }
  81. return (TRUE);
  82. }
  83. ////////////////////////////////////////////////////////////////////////////
  84. //
  85. // CreateGlobals
  86. //
  87. ////////////////////////////////////////////////////////////////////////////
  88. BOOL CreateGlobals()
  89. {
  90. return TRUE;
  91. }
  92. ////////////////////////////////////////////////////////////////////////////
  93. //
  94. // DestroyGlobals
  95. //
  96. ////////////////////////////////////////////////////////////////////////////
  97. void DestroyGlobals()
  98. {
  99. }
  100. ////////////////////////////////////////////////////////////////////////////
  101. //
  102. // CPlApplet
  103. //
  104. ////////////////////////////////////////////////////////////////////////////
  105. LONG CALLBACK CPlApplet(
  106. HWND hwnd,
  107. UINT Msg,
  108. LPARAM lParam1,
  109. LPARAM lParam2)
  110. {
  111. switch (Msg)
  112. {
  113. case ( CPL_INIT ) :
  114. {
  115. //
  116. // First message to CPlApplet(), sent once only.
  117. // Perform all control panel applet initialization and return
  118. // true for further processing.
  119. //
  120. return (CreateGlobals());
  121. }
  122. case ( CPL_GETCOUNT ) :
  123. {
  124. //
  125. // Second message to CPlApplet(), sent once only.
  126. // Return the number of control applets to be displayed in the
  127. // control panel window. For this applet, return 1.
  128. //
  129. return (1);
  130. }
  131. case ( CPL_INQUIRE ) :
  132. {
  133. //
  134. // Third message to CPlApplet().
  135. // It is sent as many times as the number of applets returned by
  136. // CPL_GETCOUNT message. Each applet must register by filling
  137. // in the CPLINFO structure referenced by lParam2 with the
  138. // applet's icon, name, and information string. Since there is
  139. // only one applet, simply set the information for this
  140. // singular case.
  141. //
  142. LPCPLINFO lpCPlInfo = (LPCPLINFO)lParam2;
  143. lpCPlInfo->idIcon = CPL_DYNAMIC_RES;
  144. lpCPlInfo->idName = CPL_DYNAMIC_RES;
  145. lpCPlInfo->idInfo = CPL_DYNAMIC_RES;
  146. lpCPlInfo->lData = 0;
  147. break;
  148. }
  149. case ( CPL_NEWINQUIRE ) :
  150. {
  151. //
  152. // Third message to CPlApplet().
  153. // It is sent as many times as the number of applets returned by
  154. // CPL_GETCOUNT message. Each applet must register by filling
  155. // in the NEWCPLINFO structure referenced by lParam2 with the
  156. // applet's icon, name, and information string. Since there is
  157. // only one applet, simply set the information for this
  158. // singular case.
  159. //
  160. LPNEWCPLINFO lpNewCPlInfo = (LPNEWCPLINFO)lParam2;
  161. lpNewCPlInfo->dwSize = sizeof(NEWCPLINFO);
  162. lpNewCPlInfo->dwFlags = 0;
  163. lpNewCPlInfo->dwHelpContext = 0UL;
  164. lpNewCPlInfo->lData = 0;
  165. lpNewCPlInfo->hIcon = LoadIcon( hInstOrig,
  166. (LPCTSTR)MAKEINTRESOURCE(IDI_ICON) );
  167. LoadString(hInstance, IDS_NAME, lpNewCPlInfo->szName, 32);
  168. LoadString(hInstance, IDS_INFO, lpNewCPlInfo->szInfo, 64);
  169. lpNewCPlInfo->szHelpFile[0] = CHAR_NULL;
  170. break;
  171. }
  172. case ( CPL_SELECT ) :
  173. {
  174. //
  175. // Applet has been selected, do nothing.
  176. //
  177. break;
  178. }
  179. case ( CPL_DBLCLK ) :
  180. {
  181. //
  182. // Applet icon double clicked -- invoke property sheet with
  183. // the first property sheet page on top.
  184. //
  185. DoProperties(hwnd, (LPCTSTR)NULL);
  186. break;
  187. }
  188. case ( CPL_STARTWPARMS ) :
  189. {
  190. //
  191. // Same as CPL_DBLCLK, but lParam2 is a long pointer to
  192. // a string of extra directions that are to be supplied to
  193. // the property sheet that is to be initiated.
  194. //
  195. DoProperties(hwnd, (LPCTSTR)lParam2);
  196. break;
  197. }
  198. case ( CPL_STOP ) :
  199. {
  200. //
  201. // Sent once for each applet prior to the CPL_EXIT msg.
  202. // Perform applet specific cleanup.
  203. //
  204. break;
  205. }
  206. case ( CPL_EXIT ) :
  207. {
  208. //
  209. // Last message, sent once only, before MMCPL.EXE calls
  210. // FreeLibrary() on this DLL. Do non-applet specific cleanup.
  211. //
  212. DestroyGlobals();
  213. break;
  214. }
  215. default :
  216. {
  217. return (FALSE);
  218. }
  219. }
  220. return (TRUE);
  221. }
  222. ////////////////////////////////////////////////////////////////////////////
  223. //
  224. // AddPage
  225. //
  226. ////////////////////////////////////////////////////////////////////////////
  227. void AddPage(
  228. LPPROPSHEETHEADER ppsh,
  229. UINT id,
  230. DLGPROC pfn,
  231. LPARAM lParam)
  232. {
  233. if (ppsh->nPages < MAX_PAGES)
  234. {
  235. PROPSHEETPAGE psp;
  236. psp.dwSize = sizeof(psp);
  237. psp.dwFlags = PSP_DEFAULT;
  238. psp.hInstance = GetCicResInstance(hInstance, id);
  239. psp.pszTemplate = MAKEINTRESOURCE(id);
  240. psp.pfnDlgProc = pfn;
  241. psp.lParam = lParam;
  242. ppsh->phpage[ppsh->nPages] = CreatePropertySheetPage(&psp);
  243. if (ppsh->phpage[ppsh->nPages])
  244. {
  245. ppsh->nPages++;
  246. }
  247. }
  248. }
  249. ////////////////////////////////////////////////////////////////////////////
  250. //
  251. // DoProperties
  252. //
  253. ////////////////////////////////////////////////////////////////////////////
  254. void DoProperties(
  255. HWND hwnd,
  256. LPCTSTR pCmdLine)
  257. {
  258. HPROPSHEETPAGE rPages[MAX_PAGES];
  259. PROPSHEETHEADER psh;
  260. LPARAM lParam = 0;
  261. BOOL bQuit = FALSE;
  262. while (pCmdLine && *pCmdLine)
  263. {
  264. if (*pCmdLine == TEXT('/'))
  265. {
  266. switch (*++pCmdLine)
  267. {
  268. case ( TEXT('u') ) :
  269. case ( TEXT('U') ) :
  270. {
  271. CheckInternatModule();
  272. bQuit = TRUE;
  273. break;
  274. }
  275. case ( TEXT('m') ) :
  276. case ( TEXT('M') ) :
  277. {
  278. MigrateCtfmonFromWin9x(pCmdLine+2);
  279. bQuit = TRUE;
  280. break;
  281. }
  282. default :
  283. {
  284. break;
  285. }
  286. }
  287. }
  288. else if (*pCmdLine == TEXT(' '))
  289. {
  290. pCmdLine++;
  291. }
  292. else
  293. {
  294. break;
  295. }
  296. }
  297. if (bQuit)
  298. return;
  299. //
  300. // See if there is a command line switch from Setup.
  301. //
  302. psh.nStartPage = 0;
  303. //
  304. // Set up the property sheet information.
  305. //
  306. psh.dwSize = sizeof(psh);
  307. psh.dwFlags = 0;
  308. psh.hwndParent = hwnd;
  309. psh.hInstance = hInstance;
  310. psh.pszCaption = MAKEINTRESOURCE(IDS_NAME);
  311. psh.nPages = 0;
  312. psh.phpage = rPages;
  313. //
  314. // Add the appropriate property pages.
  315. //
  316. AddPage(&psh, DLG_INPUT_LOCALES, InputLocaleDlgProc, lParam);
  317. AddPage(&psh, DLG_INPUT_ADVANCED, InputAdvancedDlgProc, lParam);
  318. //
  319. // Make the property sheet.
  320. //
  321. PropertySheet(&psh);
  322. }