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.

339 lines
8.7 KiB

  1. //----------------------------------------------------------------------------
  2. //
  3. // Copyright (c) 1997-1999 Microsoft Corporation
  4. // All rights reserved.
  5. //
  6. // File Name:
  7. // msclient.c
  8. //
  9. // Description:
  10. //
  11. //
  12. //----------------------------------------------------------------------------
  13. #include "pch.h"
  14. #include "resource.h"
  15. static TCHAR *StrWindowsNtLocator;
  16. static TCHAR *StrDceDirectoryService;
  17. PROPSHEETHEADER MSClient_pshead ;
  18. PROPSHEETPAGE MSClient_pspage ;
  19. UINT CALLBACK
  20. MSClient_PropertiesPageProc (HWND hwnd, UINT uMsg, LPPROPSHEETPAGE ppsp);
  21. INT_PTR CALLBACK MSClient_PropertiesDlgProc(
  22. IN HWND hwnd,
  23. IN UINT uMsg,
  24. IN WPARAM wParam,
  25. IN LPARAM lParam);
  26. //----------------------------------------------------------------------------
  27. //
  28. // Function: MSClient_PropertySheetProc
  29. //
  30. // Purpose:
  31. //
  32. //----------------------------------------------------------------------------
  33. int CALLBACK MSClient_PropertySheetProc(HWND hwndDlg, UINT uMsg, LPARAM lParam)
  34. {
  35. switch (uMsg)
  36. {
  37. case PSCB_INITIALIZED :
  38. // Process PSCB_INITIALIZED
  39. break ;
  40. case PSCB_PRECREATE :
  41. // Process PSCB_PRECREATE
  42. break ;
  43. default :
  44. // Unknown message
  45. break ;
  46. }
  47. return 0 ;
  48. }
  49. //----------------------------------------------------------------------------
  50. //
  51. // Function: Create_MSClient_PropertySheet
  52. //
  53. // Purpose:
  54. //
  55. //----------------------------------------------------------------------------
  56. BOOL Create_MSClient_PropertySheet(HWND hwndParent) {
  57. // Initialize property sheet HEADER data
  58. ZeroMemory(&MSClient_pshead, sizeof (PROPSHEETHEADER));
  59. MSClient_pshead.dwSize = sizeof (PROPSHEETHEADER);
  60. MSClient_pshead.dwFlags = PSH_PROPSHEETPAGE |
  61. PSH_USECALLBACK |
  62. PSH_USEHICON |
  63. PSH_NOAPPLYNOW;
  64. MSClient_pshead.hwndParent = hwndParent;
  65. MSClient_pshead.hInstance = FixedGlobals.hInstance;
  66. MSClient_pshead.pszCaption = g_StrMsClientTitle;
  67. MSClient_pshead.nPages = 1;
  68. MSClient_pshead.nStartPage = 0;
  69. MSClient_pshead.ppsp = &MSClient_pspage;
  70. MSClient_pshead.pfnCallback = MSClient_PropertySheetProc;
  71. // Zero out property PAGE data
  72. ZeroMemory(&MSClient_pspage, 1 * sizeof (PROPSHEETPAGE));
  73. MSClient_pspage.dwSize = sizeof (PROPSHEETPAGE);
  74. MSClient_pspage.dwFlags = PSP_USECALLBACK;
  75. MSClient_pspage.hInstance = FixedGlobals.hInstance;
  76. MSClient_pspage.pszTemplate = MAKEINTRESOURCE(IDD_DLG_RPCCONFIG);
  77. MSClient_pspage.pfnDlgProc = MSClient_PropertiesDlgProc;
  78. MSClient_pspage.pfnCallback = MSClient_PropertiesPageProc;
  79. // --------- Create & display property sheet ---------
  80. return( PropertySheet(&MSClient_pshead) ? TRUE : FALSE );
  81. }
  82. //----------------------------------------------------------------------------
  83. //
  84. // Function: MSClient_PropertiesPageProc
  85. //
  86. // Purpose:
  87. //
  88. //----------------------------------------------------------------------------
  89. UINT CALLBACK
  90. MSClient_PropertiesPageProc (HWND hwnd, UINT uMsg, LPPROPSHEETPAGE ppsp)
  91. {
  92. switch (uMsg)
  93. {
  94. case PSPCB_CREATE :
  95. return 1 ;
  96. case PSPCB_RELEASE :
  97. return 0;
  98. }
  99. return 0 ;
  100. }
  101. //----------------------------------------------------------------------------
  102. //
  103. // Function: OnMsClientInitDialog
  104. //
  105. // Purpose:
  106. //
  107. // Arguments: IN HWND hwnd - handle to the dialog
  108. //
  109. // Returns: VOID
  110. //
  111. //----------------------------------------------------------------------------
  112. static VOID
  113. OnMsClientInitDialog( IN HWND hwnd )
  114. {
  115. INT iIndex;
  116. BOOL bGreyNetworkAddress;
  117. //
  118. // Load strings from resources
  119. //
  120. StrWindowsNtLocator = MyLoadString( IDS_WINDOWS_NT_LOCATOR );
  121. StrDceDirectoryService = MyLoadString( IDS_DCE_DIR_SERVICE );
  122. //
  123. // Fill Combo box with initial values
  124. //
  125. SendDlgItemMessage( hwnd,
  126. IDC_CMB_NAMESERVICE,
  127. CB_ADDSTRING,
  128. (WPARAM) 0,
  129. (LPARAM) StrWindowsNtLocator );
  130. SendDlgItemMessage( hwnd,
  131. IDC_CMB_NAMESERVICE,
  132. CB_ADDSTRING,
  133. (WPARAM) 0,
  134. (LPARAM) StrDceDirectoryService );
  135. if( NetSettings.NameServiceProvider == MS_CLIENT_WINDOWS_LOCATOR )
  136. {
  137. iIndex = 0;
  138. bGreyNetworkAddress = FALSE;
  139. }
  140. else if( NetSettings.NameServiceProvider == MS_CLIENT_DCE_CELL_DIR_SERVICE )
  141. {
  142. iIndex = 1;
  143. SetWindowText( GetDlgItem( hwnd, IDC_EDT_NETADDRESS ),
  144. NetSettings.szNetworkAddress );
  145. bGreyNetworkAddress = TRUE;
  146. }
  147. else
  148. {
  149. AssertMsg( FALSE,
  150. "Invalid case for NameServiceProvider" );
  151. iIndex = 0;
  152. bGreyNetworkAddress = FALSE;
  153. }
  154. SendDlgItemMessage( hwnd,
  155. IDC_CMB_NAMESERVICE,
  156. CB_SETCURSEL,
  157. (WPARAM) iIndex,
  158. (LPARAM) 0 );
  159. EnableWindow( GetDlgItem( hwnd, IDC_EDT_NETADDRESS ), bGreyNetworkAddress );
  160. }
  161. //----------------------------------------------------------------------------
  162. //
  163. // Function: OnSelChangeNameServiceProvider
  164. //
  165. // Purpose:
  166. //
  167. // Arguments: IN HWND hwnd - handle to the dialog
  168. //
  169. // Returns: VOID
  170. //
  171. //----------------------------------------------------------------------------
  172. static VOID
  173. OnSelChangeNameServiceProvider( IN HWND hwnd )
  174. {
  175. INT_PTR iIndex;
  176. HWND hNetworkAddressEditBox = GetDlgItem( hwnd, IDC_EDT_NETADDRESS );
  177. //
  178. // get the current selection from the combo box
  179. //
  180. iIndex = SendDlgItemMessage( hwnd,
  181. IDC_CMB_NAMESERVICE,
  182. CB_GETCURSEL,
  183. (WPARAM) 0,
  184. (LPARAM) 0 );
  185. // infer the settings from the index since there are only 2 to work from
  186. if(iIndex == 0) { // if "Windows NT Locator" is selected then do not let user edit the Network address
  187. EnableWindow(hNetworkAddressEditBox, FALSE);
  188. }
  189. else { // else DCE Cell Directory Service is selected so let user edit Network address
  190. EnableWindow(hNetworkAddressEditBox, TRUE);
  191. }
  192. }
  193. //----------------------------------------------------------------------------
  194. //
  195. // Function: OnMsClientApply
  196. //
  197. // Purpose:
  198. //
  199. // Arguments: IN HWND hwnd - handle to the dialog
  200. //
  201. // Returns: VOID
  202. //
  203. //----------------------------------------------------------------------------
  204. static VOID
  205. OnMsClientApply( IN HWND hwnd )
  206. {
  207. INT_PTR iIndex;
  208. iIndex = SendDlgItemMessage( hwnd,
  209. IDC_CMB_NAMESERVICE,
  210. CB_GETCURSEL,
  211. (WPARAM) 0,
  212. (LPARAM) 0 );
  213. if( iIndex == 0 )
  214. {
  215. NetSettings.NameServiceProvider = MS_CLIENT_WINDOWS_LOCATOR;
  216. }
  217. else if( iIndex == 1 )
  218. {
  219. NetSettings.NameServiceProvider = MS_CLIENT_DCE_CELL_DIR_SERVICE;
  220. }
  221. else
  222. {
  223. AssertMsg( FALSE,
  224. "Invalid result from Network Service Provider combo box." );
  225. NetSettings.NameServiceProvider = MS_CLIENT_WINDOWS_LOCATOR;
  226. }
  227. GetWindowText( GetDlgItem( hwnd, IDC_EDT_NETADDRESS ),
  228. NetSettings.szNetworkAddress,
  229. MAX_NETWORK_ADDRESS_LENGTH + 1 );
  230. }
  231. //----------------------------------------------------------------------------
  232. //
  233. // Function: MSClient_PropertiesDlgProc
  234. //
  235. // Purpose:
  236. //
  237. //----------------------------------------------------------------------------
  238. INT_PTR CALLBACK MSClient_PropertiesDlgProc(
  239. IN HWND hwnd,
  240. IN UINT uMsg,
  241. IN WPARAM wParam,
  242. IN LPARAM lParam)
  243. {
  244. BOOL bStatus = TRUE;
  245. switch (uMsg) {
  246. case WM_INITDIALOG:
  247. OnMsClientInitDialog( hwnd );
  248. break;
  249. case WM_NOTIFY: {
  250. LPNMHDR pnmh = (LPNMHDR) lParam;
  251. switch( pnmh->code )
  252. {
  253. case PSN_APPLY:
  254. OnMsClientApply( hwnd );
  255. break;
  256. }
  257. break;
  258. } // end case WM_NOTIFY
  259. case WM_COMMAND: {
  260. WORD wNotifyCode = HIWORD (wParam);
  261. WORD wButtonId = LOWORD (wParam);
  262. if(wNotifyCode == CBN_SELCHANGE)
  263. {
  264. if(wButtonId == IDC_CMB_NAMESERVICE)
  265. {
  266. OnSelChangeNameServiceProvider( hwnd );
  267. }
  268. }
  269. }
  270. break;
  271. default:
  272. bStatus = FALSE;
  273. break;
  274. }
  275. return( bStatus );
  276. }