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
5.9 KiB

  1. /*****************************************************************************
  2. *
  3. * $Workfile: UIMgr.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. * $Log: /StdTcpMon/TcpMonUI/UIMgr.cpp $
  15. *
  16. * 9 9/23/97 3:56p Becky
  17. * Corrected small bug for NT 5.0
  18. *
  19. * 8 9/23/97 3:35p Becky
  20. * Split functionality into NT4UIMgr and NT5UIMgr files. This main class
  21. * is only responsible, now, for making a decision on which of these
  22. * classes to create and call.
  23. *
  24. * 7 9/19/97 11:26a Becky
  25. * Added Wizard 97 flags and function parameters.
  26. *
  27. * 6 9/12/97 3:25p Becky
  28. * Added bNewPort to the params structure.
  29. *
  30. * 5 9/11/97 9:55a Becky
  31. * Added parameter to the ConfigPortUI call to let us know if the call is
  32. * for a new port or an existing one.
  33. *
  34. * 4 9/10/97 3:16p Becky
  35. * Split out Input Checking functionality into the class CInptChkr.
  36. *
  37. * 3 9/09/97 4:35p Becky
  38. * Updated to use the new Monitor UI data structure.
  39. *
  40. * 2 9/09/97 11:58a Becky
  41. * Added a UIManager field to the AddParamsPackage so the Add UI will know
  42. * how to call the Config UI (it's a member function of the UIManager).
  43. *
  44. * 1 8/19/97 3:46p Becky
  45. * Redesign of the Port Monitor UI.
  46. *
  47. *****************************************************************************/
  48. /*
  49. * Author: Becky Jacobsen
  50. */
  51. #include "precomp.h"
  52. #define _PRSHT_H_
  53. #include "TCPMonUI.h"
  54. #include "UIMgr.h"
  55. #include "InptChkr.h"
  56. #include "resource.h"
  57. #include "NT5UIMgr.h"
  58. // includes for ConfigPort
  59. #include "CfgPort.h"
  60. #include "CfgAll.h"
  61. // includes for AddPort
  62. #include "DevPort.h"
  63. #include "AddWelcm.h"
  64. #include "AddGetAd.h"
  65. #include "AddMInfo.h"
  66. #include "AddDone.h"
  67. #undef _PRSHT_H_
  68. //
  69. // FUNCTION: CUIManager
  70. //
  71. // PURPOSE: Constructor
  72. //
  73. CUIManager::CUIManager() : m_hBigBoldFont(NULL)
  74. {
  75. CreateWizardFont();
  76. } // Constructor
  77. //
  78. // FUNCTION: CUIManager
  79. //
  80. // PURPOSE: Destructor
  81. //
  82. CUIManager::~CUIManager()
  83. {
  84. DestroyWizardFont();
  85. } // Destructor
  86. //
  87. // FUNCTION: AddPortUI
  88. //
  89. // PURPOSE: Main function called when the User Interface for adding a port is called.
  90. //
  91. DWORD CUIManager::AddPortUI(HWND hWndParent,
  92. HANDLE hXcvPrinter,
  93. TCHAR pszServer[],
  94. TCHAR sztPortName[])
  95. {
  96. OSVERSIONINFO osVersionInfo;
  97. osVersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
  98. if ( GetVersionEx(&osVersionInfo) ) // get the OS version
  99. {
  100. if ( osVersionInfo.dwMajorVersion >= 5 ) // check if we are NT 5.0 & later
  101. {
  102. CNT5UIManager UI97;
  103. return UI97.AddPortUI(hWndParent, hXcvPrinter, pszServer, sztPortName);
  104. }
  105. else
  106. {
  107. return ERROR_NOT_SUPPORTED;
  108. }
  109. }
  110. return NO_ERROR;
  111. } // AddPortUI
  112. //
  113. // FUNCTION: ConfigPortUI
  114. //
  115. // PURPOSE: Main function called when the User Interface for configuring a port is called.
  116. //
  117. DWORD CUIManager::ConfigPortUI(HWND hWndParent,
  118. PPORT_DATA_1 pData,
  119. HANDLE hXcvPrinter,
  120. TCHAR *szServerName,
  121. BOOL bNewPort)
  122. {
  123. OSVERSIONINFO osVersionInfo;
  124. osVersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
  125. if ( GetVersionEx(&osVersionInfo) ) // get the OS version
  126. {
  127. if ( osVersionInfo.dwMajorVersion >= 5 ) // check if we are NT 5.0 & later
  128. {
  129. CNT5UIManager UI97;
  130. return UI97.ConfigPortUI(hWndParent, pData, hXcvPrinter, szServerName, bNewPort);
  131. }
  132. else
  133. {
  134. return ERROR_NOT_SUPPORTED;
  135. }
  136. }
  137. return NO_ERROR;
  138. } // ConfigPortUI
  139. //
  140. //
  141. // FUNCTION: CreateWizardFont()
  142. //
  143. // PURPOSE: Create the large bold font for the wizard 97 style.
  144. //
  145. // COMMENTS:
  146. //
  147. VOID CUIManager::CreateWizardFont()
  148. {
  149. //
  150. // Create the fonts we need based on the dialog font
  151. //
  152. NONCLIENTMETRICS ncm = {0};
  153. ncm.cbSize = sizeof(ncm);
  154. SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &ncm, 0);
  155. LOGFONT BigBoldLogFont = ncm.lfMessageFont;
  156. //
  157. // Create the Big Bold Font
  158. //
  159. BigBoldLogFont.lfWeight = FW_BOLD;
  160. INT FontSize;
  161. TCHAR szLargeFontName[MAX_PATH];
  162. TCHAR szLargeFontSize[MAX_PATH];
  163. //
  164. // Load size and name from resources, since these may change
  165. // from locale to locale based on the size of the system font, etc.
  166. //
  167. // NOTICE-DavePr@2002/05/27
  168. // g_hInstance is linked to what?
  169. //
  170. if( LoadString( g_hInstance, IDS_LARGEFONTNAME, szLargeFontName, sizeof(szLargeFontName)/sizeof(szLargeFontName[0]) ) &&
  171. LoadString( g_hInstance, IDS_LARGEFONTSIZE, szLargeFontSize, sizeof(szLargeFontName)/sizeof(szLargeFontName[0]) ) )
  172. {
  173. lstrcpyn( BigBoldLogFont.lfFaceName, szLargeFontName, sizeof(BigBoldLogFont.lfFaceName)/sizeof(BigBoldLogFont.lfFaceName[0]) );
  174. FontSize = _tcstoul( szLargeFontSize, NULL, 10 );
  175. HDC hdc = GetDC( NULL );
  176. if( hdc )
  177. {
  178. BigBoldLogFont.lfHeight = 0 - (GetDeviceCaps(hdc,LOGPIXELSY) * FontSize / 72);
  179. m_hBigBoldFont = CreateFontIndirect( &BigBoldLogFont );
  180. ReleaseDC( NULL, hdc);
  181. }
  182. }
  183. } // CreateWizardFont
  184. //
  185. //
  186. // FUNCTION: DestroyWizardFont()
  187. //
  188. // PURPOSE: Destroys the wizard font created with CreateWizardFont
  189. //
  190. // COMMENTS:
  191. //
  192. VOID CUIManager::DestroyWizardFont()
  193. {
  194. if(m_hBigBoldFont)
  195. {
  196. DeleteObject(m_hBigBoldFont);
  197. }
  198. } // DestroyWizardFont
  199. //
  200. //
  201. // FUNCTION: SetControlFont(HWND hwnd, INT nId)
  202. //
  203. // PURPOSE: Set font of the specified control
  204. //
  205. // COMMENTS:
  206. //
  207. VOID CUIManager::SetControlFont(HWND hwnd, INT nId) const
  208. {
  209. if(m_hBigBoldFont)
  210. {
  211. HWND hwndControl = GetDlgItem(hwnd, nId);
  212. if(hwndControl)
  213. {
  214. SetWindowFont(hwndControl, m_hBigBoldFont, TRUE);
  215. }
  216. }
  217. } // SetControlFont