Source code of Windows XP (NT5)
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.

205 lines
5.2 KiB

  1. /****************************************************************************
  2. *
  3. *
  4. * PROGRAM: Themes.c
  5. *
  6. * PURPOSE: Themes Control Panel applet
  7. *
  8. * FUNCTIONS:
  9. *
  10. * DllMain()
  11. * InitThemesApplet()
  12. * TermThemesApplet()
  13. * CPIApplet()
  14. *
  15. * Copyright (C) 1994 - 1998 Microsoft Corporation. All rights reserved.
  16. *
  17. ****************************************************************************/
  18. #include <windows.h>
  19. #include <cpl.h>
  20. #include <shellapi.h>
  21. #include "thm_cpl.h"
  22. #define NUM_APPLETS 1
  23. #define EXE_NAME_SIZE 14
  24. HANDLE hModule = NULL;
  25. TCHAR szCtlPanel[30];
  26. /****************************************************************************
  27. *
  28. * FUNCTION: DllMain(PVOID, ULONG, PCONTEXT)
  29. *
  30. * PURPOSE: Win 32 Initialization DLL
  31. *
  32. * COMMENTS:
  33. *
  34. *
  35. ****************************************************************************/
  36. BOOL WINAPI DllMain(
  37. IN PVOID hmod,
  38. IN ULONG ulReason,
  39. IN PCONTEXT pctx OPTIONAL)
  40. {
  41. if (ulReason != DLL_PROCESS_ATTACH)
  42. {
  43. return TRUE;
  44. }
  45. else
  46. {
  47. hModule = hmod;
  48. }
  49. return TRUE;
  50. UNREFERENCED_PARAMETER(pctx);
  51. }
  52. /****************************************************************************
  53. *
  54. * FUNCTION: InitThemesApplet (HWND)
  55. *
  56. * PURPOSE: loads the caption string for the Control Panel
  57. *
  58. * COMMENTS:
  59. *
  60. *
  61. ****************************************************************************/
  62. BOOL InitThemesApplet (HWND hwndParent)
  63. {
  64. LoadString (hModule, CPCAPTION, szCtlPanel, ARRAYSIZE(szCtlPanel));
  65. return TRUE;
  66. UNREFERENCED_PARAMETER(hwndParent);
  67. }
  68. /****************************************************************************
  69. *
  70. * FUNCTION: TermThemesApplet()
  71. *
  72. * PURPOSE: termination procedure for the stereo applets
  73. *
  74. * COMMENTS:
  75. *
  76. *
  77. ****************************************************************************/
  78. void TermThemesApplet()
  79. {
  80. return;
  81. }
  82. /****************************************************************************
  83. *
  84. * FUNCTION: CPIApplet(HWND, UINT, lPARAM, lPARAM)
  85. *
  86. * PURPOSE: Processes messages for control panel applet
  87. *
  88. * COMMENTS:
  89. *
  90. *
  91. ****************************************************************************/
  92. LONG CALLBACK CPlApplet (hwndCPL, uMsg, lParam1, lParam2)
  93. HWND hwndCPL; // handle of Control Panel window
  94. UINT uMsg; // message
  95. LPARAM lParam1; // first message parameter
  96. LPARAM lParam2; // second message parameter
  97. {
  98. LPNEWCPLINFO lpNewCPlInfo;
  99. LPCPLINFO lpCPlInfo;
  100. static iInitCount = 0;
  101. TCHAR szEXE_Name[ EXE_NAME_SIZE ];
  102. switch (uMsg) {
  103. case CPL_INIT: // first message, sent once
  104. if (!iInitCount)
  105. {
  106. if (!InitThemesApplet(hwndCPL))
  107. return FALSE;
  108. }
  109. iInitCount++;
  110. return TRUE;
  111. case CPL_GETCOUNT: // second message, sent once
  112. return (LONG)NUM_APPLETS;
  113. break;
  114. case CPL_NEWINQUIRE: // third message, sent once per app
  115. lpNewCPlInfo = (LPNEWCPLINFO) lParam2;
  116. lpNewCPlInfo->dwSize = (DWORD) sizeof(NEWCPLINFO);
  117. lpNewCPlInfo->dwFlags = 0;
  118. lpNewCPlInfo->dwHelpContext = 0;
  119. lpNewCPlInfo->lData = 0;
  120. lpNewCPlInfo->hIcon = LoadIcon (hModule,
  121. (LPCTSTR) MAKEINTRESOURCE(THEMES_ICON));
  122. lpNewCPlInfo->szHelpFile[0] = TEXT('\0');
  123. LoadString (hModule, THEMES_CPL_NAME,
  124. lpNewCPlInfo->szName, 32);
  125. LoadString (hModule, THEMES_CPL_CAPTION,
  126. lpNewCPlInfo->szInfo, 64);
  127. #ifdef DEBUG
  128. OutputDebugString(TEXT("\nCPL_NEWINQUIRE Name: "));
  129. OutputDebugString(lpNewCPlInfo->szName);
  130. OutputDebugString(TEXT("\n"));
  131. OutputDebugString(TEXT("\nCPL_NEWINQUIRE Caption: "));
  132. OutputDebugString(lpNewCPlInfo->szInfo);
  133. OutputDebugString(TEXT("\n"));
  134. #endif // DEBUG
  135. break;
  136. case CPL_INQUIRE: // for backward compat & speed
  137. lpCPlInfo = (LPCPLINFO) lParam2;
  138. lpCPlInfo->lData = 0;
  139. lpCPlInfo->idIcon = THEMES_ICON; // MAKEINTRESOURCE(THEMES_ICON);
  140. lpCPlInfo->idName = THEMES_CPL_NAME; // MAKEINTRESOURCE(THEMES_CPL_NAME);
  141. lpCPlInfo->idInfo = THEMES_CPL_CAPTION; // MAKEINTRESOURCE(THEMES_CPL_CAPTION);
  142. break;
  143. case CPL_SELECT: // application icon selected
  144. break;
  145. case CPL_DBLCLK: // application icon double-clicked
  146. LoadString( hModule,
  147. EXE_NAME,
  148. szEXE_Name,
  149. EXE_NAME_SIZE );
  150. ShellExecute( hwndCPL,
  151. TEXT("open"),
  152. szEXE_Name,
  153. NULL,
  154. NULL,
  155. 1 );
  156. break;
  157. case CPL_STOP: // sent once per app. before CPL_EXIT
  158. break;
  159. case CPL_EXIT: // sent once before FreeLibrary called
  160. iInitCount--;
  161. if (!iInitCount)
  162. TermThemesApplet();
  163. break;
  164. default:
  165. break;
  166. }
  167. return 0;
  168. }