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.

370 lines
6.6 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. faxcfg.c
  5. Abstract:
  6. Implementation of the control panel applet entry point
  7. Environment:
  8. Windows NT fax configuration applet
  9. Revision History:
  10. 02/27/96 -davidx-
  11. Created it.
  12. 05/22/96 -davidx-
  13. Share the same DLL with remote admin program.
  14. mm/dd/yy -author-
  15. description
  16. --*/
  17. #include <stdlib.h>
  18. #include <windows.h>
  19. #include <commctrl.h>
  20. #include <cpl.h>
  21. #include <tchar.h>
  22. #include "faxcfg.h"
  23. #include "resource.h"
  24. //
  25. // Fax configuration applet index
  26. //
  27. #define FAX_CLIENT_APPLET 0
  28. #define FAX_SERVER_APPLET 1
  29. //
  30. // Definition of global variables
  31. //
  32. HANDLE ghInstance; // DLL instance handle
  33. INT faxConfigType; // fax configuration type
  34. //
  35. // Forward declaration of local functions
  36. //
  37. VOID FillOutCPlInfo(CPLINFO *, INT);
  38. INT DoFaxConfiguration(HWND, INT, LPTSTR);
  39. BOOL
  40. DllEntryPoint(
  41. HANDLE hModule,
  42. ULONG ulReason,
  43. PCONTEXT pContext
  44. )
  45. /*++
  46. Routine Description:
  47. DLL initialization procedure.
  48. Arguments:
  49. hModule - DLL instance handle
  50. ulReason - Reason for the call
  51. pContext - Pointer to context (not used by us)
  52. Return Value:
  53. TRUE if DLL is initialized successfully, FALSE otherwise.
  54. --*/
  55. {
  56. switch (ulReason) {
  57. case DLL_PROCESS_ATTACH:
  58. ghInstance = hModule;
  59. break;
  60. case DLL_PROCESS_DETACH:
  61. break;
  62. }
  63. return TRUE;
  64. }
  65. LONG
  66. CPlApplet(
  67. HWND hwndCPl,
  68. UINT uMsg,
  69. LONG lParam1,
  70. LONG lParam2
  71. )
  72. /*++
  73. Routine Description:
  74. Control panel applet entry point
  75. Arguments:
  76. hwndCPl - Identifies the Control Panel window
  77. uMsg - Specifies the message being sent to the Control Panel applet
  78. lParam1 - Specifies additional message-specific information
  79. lParam2 - Specifies additional message-specific information
  80. Return Value:
  81. Depends on the message
  82. --*/
  83. {
  84. static BOOL Failed = FALSE;
  85. switch (uMsg) {
  86. case CPL_INIT:
  87. {
  88. DWORD Size;
  89. WCHAR ComputerName[MAX_COMPUTERNAME_LENGTH+4];
  90. ComputerName[0] = L'\\';
  91. ComputerName[1] = L'\\';
  92. Size = sizeof(ComputerName)/sizeof(WCHAR);
  93. GetComputerName( &ComputerName[2], &Size );
  94. return (faxConfigType = FaxConfigInit(ComputerName, TRUE)) >= 0;
  95. }
  96. case CPL_GETCOUNT:
  97. //
  98. // We export one or two applets depending on whether
  99. // we're doing client, server, or workstation configuration
  100. //
  101. return (faxConfigType == FAXCONFIG_SERVER) ? 2 : 1;
  102. case CPL_INQUIRE:
  103. //
  104. // Fill out the CPLINFO structure depending on the fax configuration type
  105. //
  106. FillOutCPlInfo((CPLINFO *) lParam2, lParam1);
  107. break;
  108. case CPL_DBLCLK:
  109. //
  110. // Treat this as CPL_STARTWPARMS with no parameter
  111. //
  112. if (Failed) {
  113. return 1;
  114. }
  115. return DoFaxConfiguration(hwndCPl, lParam1, NULL);
  116. case CPL_STARTWPARMS:
  117. //
  118. // Display fax configuration dialog: client, server, or workstation
  119. //
  120. if (!(DoFaxConfiguration(hwndCPl, lParam1, (LPTSTR) lParam2) == 0)) {
  121. Failed = TRUE;
  122. return 1;
  123. }
  124. return 0;
  125. case CPL_EXIT:
  126. FaxConfigCleanup();
  127. break;
  128. }
  129. return 0;
  130. }
  131. VOID
  132. FillOutCPlInfo(
  133. CPLINFO *pCPlInfo,
  134. INT cplIndex
  135. )
  136. /*++
  137. Routine Description:
  138. Fill out the CPLINFO structure corresponding to the
  139. specified fax configuration control panel applet
  140. Arguments:
  141. pCPlInfo - Points to a CPLINFO buffer
  142. cplIndex - Index of the interested fax conguration applet
  143. Return Value:
  144. NONE
  145. --*/
  146. {
  147. pCPlInfo->lData = 0;
  148. switch (faxConfigType) {
  149. case FAXCONFIG_SERVER:
  150. if (cplIndex == FAX_SERVER_APPLET) {
  151. //
  152. // Fax server configuration
  153. //
  154. pCPlInfo->idIcon = IDI_FAX_SERVER;
  155. pCPlInfo->idName = IDS_FAX_SERVER;
  156. pCPlInfo->idInfo = IDS_CONFIG_FAX_SERVER;
  157. } else {
  158. //
  159. // Fax client configuration
  160. //
  161. pCPlInfo->idIcon = IDI_FAX_CLIENT;
  162. pCPlInfo->idName = IDS_FAX_CLIENT;
  163. pCPlInfo->idInfo = IDS_CONFIG_FAX_CLIENT;
  164. }
  165. break;
  166. default:
  167. //
  168. // Fax client or workstation configuration
  169. //
  170. pCPlInfo->idIcon = IDI_FAX;
  171. pCPlInfo->idName = IDS_FAX;
  172. pCPlInfo->idInfo = IDS_CONFIG_FAX;
  173. break;
  174. }
  175. }
  176. INT
  177. DoFaxConfiguration(
  178. HWND hwndCPl,
  179. INT cplIndex,
  180. LPTSTR pCmdLine
  181. )
  182. /*++
  183. Routine Description:
  184. Display fax configuration dialogs: client, server, or workstation
  185. Arguments:
  186. hwndCPl - Handle to the Control Panel window
  187. cplIndex - Index of the interested fax configuration applet
  188. pCmdLine - Command line parameters
  189. Return Value:
  190. 0 if successful, -1 if there is an error
  191. --*/
  192. #define MAX_PAGES 16
  193. #define MAX_TITLE_LEN 64
  194. {
  195. HPROPSHEETPAGE hPropSheetPages[MAX_PAGES];
  196. PROPSHEETHEADER psh;
  197. CPLINFO cplInfo;
  198. TCHAR dlgTitle[MAX_TITLE_LEN];
  199. INT nPages, nStartPage;
  200. //
  201. // Get an array of property sheet page handles
  202. //
  203. switch (faxConfigType) {
  204. case FAXCONFIG_WORKSTATION:
  205. nPages = FaxConfigGetWorkstationPages(hPropSheetPages, MAX_PAGES);
  206. break;
  207. case FAXCONFIG_SERVER:
  208. if (cplIndex == FAX_SERVER_APPLET) {
  209. nPages = FaxConfigGetServerPages(hPropSheetPages, MAX_PAGES);
  210. break;
  211. }
  212. default:
  213. nPages = FaxConfigGetClientPages(hPropSheetPages, MAX_PAGES);
  214. break;
  215. };
  216. if (nPages < 0 || nPages > MAX_PAGES)
  217. return -1;
  218. //
  219. // Determine which page to activate initially
  220. //
  221. nStartPage = pCmdLine ? _ttol(pCmdLine) : 0;
  222. if (nStartPage < 0 || nStartPage >= nPages)
  223. nStartPage = 0;
  224. //
  225. // Fill out PROPSHEETHEADER structure
  226. //
  227. FillOutCPlInfo(&cplInfo, cplIndex);
  228. LoadString(ghInstance, cplInfo.idInfo, dlgTitle, MAX_TITLE_LEN);
  229. ZeroMemory(&psh, sizeof(psh));
  230. psh.dwSize = sizeof(PROPSHEETHEADER);
  231. psh.dwFlags = PSH_USEICONID;
  232. psh.hwndParent = hwndCPl;
  233. psh.hInstance = ghInstance;
  234. psh.pszIcon = MAKEINTRESOURCE(cplInfo.idIcon);
  235. psh.pszCaption = dlgTitle;
  236. psh.nPages = nPages;
  237. psh.nStartPage = nStartPage;
  238. psh.phpage = hPropSheetPages;
  239. //
  240. // Display the property sheet
  241. //
  242. return (PropertySheet(&psh) == -1) ? -1 : 0;
  243. }