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.

246 lines
9.3 KiB

  1. /*****************************************************************************
  2. *
  3. * $Workfile: NT5UIMgr.cpp $
  4. *
  5. * Copyright (C) 1997 Hewlett-Packard Company.
  6. * Copyright (c) 1997 Microsoft Corporation.
  7. * All rights reserved.
  8. *
  9. * 11311 Chinden Blvd.
  10. * Boise, Idaho 83714
  11. *
  12. *****************************************************************************/
  13. /*
  14. * Author: Becky Jacobsen
  15. */
  16. #include "precomp.h"
  17. #include "TCPMonUI.h"
  18. #include "UIMgr.h"
  19. #include "InptChkr.h"
  20. #include "NT5UIMgr.h"
  21. #include "Prsht.h"
  22. #include "resource.h"
  23. // includes for ConfigPort
  24. #include "DevPort.h"
  25. #include "CfgPort.h"
  26. #include "CfgAll.h"
  27. // includes for AddPort
  28. #include "AddWelcm.h"
  29. #include "AddGetAd.h"
  30. #include "AddMInfo.h"
  31. #include "AddMulti.h"
  32. #include "AddDone.h"
  33. // NOTICE-DavePr@2002/05/27
  34. // remove STRICT_DLGPROC once printscan remove NO_STRICT from sources files
  35. // Win64 works better relying on strict typing rather than serendipity.
  36. //
  37. typedef INT_PTR (CALLBACK* STRICT_DLGPROC)(HWND, UINT, WPARAM, LPARAM);
  38. static void FillInPropertyPage( PROPSHEETPAGE* psp, // a pointer to the structure to be filled in.
  39. int idDlg, // the id of the dialog template
  40. LPTSTR pszProc, // Title of the dialog.
  41. LPTSTR pszHeaderTitle, // Title displayed in the header.
  42. LPTSTR pszHeaderSubTitle, // SubTitle displayed in the header.
  43. DWORD dwFlags, // Flags used by the page.
  44. STRICT_DLGPROC pfnDlgProc, // dialog procedure that handles window messages.
  45. LPARAM lParam); // data that will appear in the lParam field of the struct passed to the dialog procedure.
  46. //
  47. // FUNCTION: CNT5UIManager
  48. //
  49. // PURPOSE: Constructor
  50. //
  51. CNT5UIManager::CNT5UIManager()
  52. {
  53. } // Constructor
  54. //
  55. // FUNCTION: AddPortUI
  56. //
  57. // PURPOSE: Main function called when the User Interface for adding a port is called.
  58. //
  59. DWORD CNT5UIManager::AddPortUI(HWND hWndParent,
  60. HANDLE hXcvPrinter,
  61. TCHAR pszServer[],
  62. TCHAR sztPortName[])
  63. {
  64. INT_PTR iReturnVal;
  65. PROPSHEETPAGE psp[MaxNumAddPages];
  66. PROPSHEETHEADER psh;
  67. PORT_DATA_1 PortData;
  68. ADD_PARAM_PACKAGE Params;
  69. TCHAR sztPropSheetTitle[MAX_TITLE_LENGTH];
  70. TCHAR sztWelcomePageTitle[MAX_TITLE_LENGTH];
  71. TCHAR sztAddPortPageTitle[MAX_TITLE_LENGTH];
  72. TCHAR sztAddPortHeaderTitle[MAX_TITLE_LENGTH];
  73. TCHAR sztAddPortHeaderSubTitle[MAX_TITLE_LENGTH];
  74. TCHAR sztMoreInfoPageTitle[MAX_TITLE_LENGTH];
  75. TCHAR sztMoreInfoHeaderTitle[MAX_TITLE_LENGTH];
  76. TCHAR sztMoreInfoHeaderSubTitle[MAX_TITLE_LENGTH];
  77. TCHAR sztMultiPortPageTitle[MAX_TITLE_LENGTH];
  78. TCHAR sztMultiPortHeaderTitle[MAX_TITLE_LENGTH];
  79. TCHAR sztMultiPortHeaderSubTitle[MAX_TITLE_LENGTH];
  80. TCHAR sztSummaryPageTitle[MAX_TITLE_LENGTH];
  81. memset(&PortData, 0, sizeof(PortData));
  82. PortData.dwVersion = 1;
  83. Params.pData = &PortData;
  84. Params.hXcvPrinter = hXcvPrinter;
  85. Params.UIManager = this;
  86. Params.dwLastError = NO_ERROR;
  87. if (pszServer != NULL) {
  88. lstrcpyn(Params.pszServer, pszServer, MAX_NETWORKNAME_LEN);
  89. } else {
  90. Params.pszServer[0] = '\0';
  91. }
  92. if (sztPortName != NULL) {
  93. lstrcpyn(Params.sztPortName, sztPortName, MAX_PORTNAME_LEN);
  94. } else {
  95. Params.sztPortName[0] = '\0';
  96. }
  97. // NOTICE-DavePr@2002/05/27
  98. // g_hInstance is linked to what?
  99. //
  100. LoadString(g_hInstance, IDS_STRING_ADDPORT_TITLE, sztWelcomePageTitle, MAX_TITLE_LENGTH);
  101. LoadString(g_hInstance, IDS_STRING_ADDPORT_TITLE, sztAddPortPageTitle, MAX_TITLE_LENGTH);
  102. LoadString(g_hInstance, IDS_STRING_ADDPORT_HEADER, sztAddPortHeaderTitle, MAX_TITLE_LENGTH);
  103. LoadString(g_hInstance, IDS_STRING_ADDPORT_SUBTITLE, sztAddPortHeaderSubTitle, MAX_SUBTITLE_LENGTH);
  104. LoadString(g_hInstance, IDS_STRING_ADDPORT_TITLE, sztMoreInfoPageTitle, MAX_TITLE_LENGTH);
  105. LoadString(g_hInstance, IDS_STRING_MOREINFO_HEADER, sztMoreInfoHeaderTitle, MAX_TITLE_LENGTH);
  106. LoadString(g_hInstance, IDS_STRING_MOREINFO_SUBTITLE, sztMoreInfoHeaderSubTitle, MAX_SUBTITLE_LENGTH);
  107. LoadString(g_hInstance, IDS_STRING_ADDPORT_TITLE, sztMultiPortPageTitle, MAX_TITLE_LENGTH);
  108. LoadString(g_hInstance, IDS_MULTIPORT_HEADER, sztMultiPortHeaderTitle, MAX_TITLE_LENGTH);
  109. LoadString(g_hInstance, IDS_MULTIPORT_SUBTITLE, sztMultiPortHeaderSubTitle, MAX_SUBTITLE_LENGTH);
  110. LoadString(g_hInstance, IDS_STRING_ADDPORT_TITLE, sztSummaryPageTitle, MAX_TITLE_LENGTH);
  111. FillInPropertyPage( &psp[0], IDD_WELCOME_PAGE, sztWelcomePageTitle, sztWelcomePageTitle, NULL, PSP_HIDEHEADER, WelcomeDialog, (LPARAM)&Params);
  112. FillInPropertyPage( &psp[1], IDD_DIALOG_ADDPORT, sztAddPortPageTitle, sztAddPortHeaderTitle, sztAddPortHeaderSubTitle, 0, GetAddressDialog, (LPARAM)&Params);
  113. FillInPropertyPage( &psp[2], IDD_DIALOG_MORE_INFO, sztMoreInfoPageTitle, sztMoreInfoHeaderTitle, sztMoreInfoHeaderSubTitle, 0, MoreInfoDialog, (LPARAM)&Params);
  114. FillInPropertyPage( &psp[3], IDD_DIALOG_MULTIPORT, sztMultiPortHeaderTitle, sztMultiPortHeaderTitle, sztMultiPortHeaderSubTitle, 0, MultiPortDialog, (LPARAM)&Params);
  115. FillInPropertyPage( &psp[4], IDD_DIALOG_SUMMARY, sztSummaryPageTitle, NULL, NULL, PSP_HIDEHEADER, SummaryDialog, (LPARAM)&Params);
  116. LoadString(g_hInstance, IDS_STRING_CONFIG_TITLE, sztPropSheetTitle, MAX_TITLE_LENGTH);
  117. psh.dwSize = sizeof(PROPSHEETHEADER);
  118. psh.hInstance = g_hInstance;
  119. psh.dwFlags = PSH_WIZARD | PSH_PROPSHEETPAGE | PSH_WIZARD97 | PSH_WATERMARK | PSH_HEADER | PSH_STRETCHWATERMARK;
  120. psh.hwndParent = hWndParent;
  121. psh.pszCaption = sztPropSheetTitle;
  122. psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE);
  123. psh.nStartPage = 0;
  124. psh.ppsp = psp;
  125. psh.pszbmWatermark = MAKEINTRESOURCE( IDB_WATERMARK );
  126. psh.pszbmHeader = MAKEINTRESOURCE( IDB_BANNER );
  127. iReturnVal = PropertySheet(&psh);
  128. if (iReturnVal < 0) {
  129. return(ERROR_INVALID_FUNCTION);
  130. }
  131. return(Params.dwLastError);
  132. } // AddPortUI
  133. //
  134. // FUNCTION: ConfigPortUI
  135. //
  136. // PURPOSE: Main function called when the User Interface for configuring a port is called.
  137. //
  138. DWORD CNT5UIManager::ConfigPortUI(HWND hWndParent,
  139. PPORT_DATA_1 pData,
  140. HANDLE hXcvPrinter,
  141. TCHAR *szServerName,
  142. BOOL bNewPort)
  143. {
  144. INT_PTR iReturnVal = NO_ERROR;
  145. PROPSHEETPAGE psp[MaxNumCfgPages];
  146. PROPSHEETHEADER psh;
  147. TCHAR sztPropSheetTitle[MAX_TITLE_LENGTH];
  148. TCHAR sztPortPageTitle[MAX_TITLE_LENGTH];
  149. CFG_PARAM_PACKAGE Params;
  150. Params.pData = pData;
  151. pData->dwVersion = 1;
  152. Params.hXcvPrinter = hXcvPrinter;
  153. Params.bNewPort = bNewPort;
  154. Params.dwLastError = NO_ERROR;
  155. if (szServerName != NULL) {
  156. lstrcpyn(Params.pszServer, szServerName, MAX_NETWORKNAME_LEN);
  157. } else {
  158. Params.pszServer[0] = '\0';
  159. }
  160. LoadString(g_hInstance, IDS_STRING_PORTPAGE_TITLE, sztPortPageTitle, MAX_TITLE_LENGTH);
  161. FillInPropertyPage( &psp[0], IDD_PORT_SETTINGS, sztPortPageTitle, NULL, NULL, 0, ConfigurePortPage, (LPARAM)&Params);
  162. #if 0
  163. if (!bNewPort) {
  164. // It's not a brand new port so show the AllPorts Page.
  165. FillInPropertyPage( &psp[1], IDD_DIALOG_CONFIG_ALL, sztAllPortsPageTitle, NULL, NULL, 0, AllPortsPage, (LPARAM)&Params);
  166. }
  167. #endif
  168. LoadString(g_hInstance, IDS_STRING_CONFIG_TITLE, sztPropSheetTitle, MAX_TITLE_LENGTH);
  169. psh.dwSize = sizeof(PROPSHEETHEADER);
  170. psh.dwFlags = PSH_NOAPPLYNOW | PSH_PROPSHEETPAGE;
  171. psh.hwndParent = hWndParent;
  172. psh.hInstance = g_hInstance;
  173. psh.pszCaption = sztPropSheetTitle;
  174. psh.nStartPage = 0;
  175. psh.ppsp = psp;
  176. psh.pfnCallback = NULL;
  177. psh.nPages = MaxNumCfgPages;
  178. iReturnVal = PropertySheet(&psh);
  179. if (iReturnVal < 0) {
  180. return(ERROR_INVALID_FUNCTION);
  181. }
  182. return(Params.dwLastError);
  183. } // ConfigPortUI
  184. //
  185. //
  186. // FUNCTION: FillInPropertyPage(PROPSHEETPAGE *, int, LPSTR, LPFN)
  187. //
  188. // PURPOSE: Fills in the given PROPSHEETPAGE structure
  189. //
  190. // COMMENTS:
  191. //
  192. // This function fills in a PROPSHEETPAGE structure with the
  193. // information the system needs to create the page.
  194. //
  195. static void FillInPropertyPage( PROPSHEETPAGE* psp, int idDlg, LPTSTR pszProc, LPTSTR pszHeaderTitle, LPTSTR pszHeaderSubTitle, DWORD dwFlags, STRICT_DLGPROC pfnDlgProc, LPARAM lParam)
  196. {
  197. psp->dwSize = sizeof(PROPSHEETPAGE);
  198. psp->dwFlags = PSP_USETITLE |
  199. ((pszHeaderTitle != NULL) ? PSP_USEHEADERTITLE : 0) |
  200. ((pszHeaderSubTitle != NULL) ? PSP_USEHEADERSUBTITLE : 0) |
  201. dwFlags;
  202. psp->hInstance = g_hInstance;
  203. psp->pszTemplate = MAKEINTRESOURCE(idDlg);
  204. psp->pszIcon = NULL;
  205. psp->pfnDlgProc = (DLGPROC)pfnDlgProc;
  206. psp->pszTitle = pszProc;
  207. psp->lParam = lParam;
  208. psp->pszHeaderTitle = pszHeaderTitle;
  209. psp->pszHeaderSubTitle = pszHeaderSubTitle;
  210. } // FillInPropertyPage