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.

424 lines
14 KiB

  1. //----------------------------------------------------------------------------
  2. //
  3. // Copyright (c) 1997-1999 Microsoft Corporation
  4. // All rights reserved.
  5. //
  6. // File Name:
  7. // msnwipx.c
  8. //
  9. // Description:
  10. // This file contains the property sheet and page procedures for the
  11. // IPX protocol property sheet.
  12. //
  13. //----------------------------------------------------------------------------
  14. #include "pch.h"
  15. #include "resource.h"
  16. #define MAX_NETWORKNUMBER_LENGTH 8
  17. static TCHAR *StrIpxDescription;
  18. static TCHAR *StrAutoDetect;
  19. static TCHAR *StrEthernet_802_2;
  20. static TCHAR *StrEthernet_802_3;
  21. static TCHAR *StrEthernet_II;
  22. static TCHAR *StrEthernetSnap;
  23. PROPSHEETHEADER MS_NWIPX_pshead ;
  24. PROPSHEETPAGE MS_NWIPX_pspage ;
  25. UINT CALLBACK
  26. MS_NWIPX_PropertiesPageProc( HWND hwnd, UINT uMsg, LPPROPSHEETPAGE ppsp );
  27. int CALLBACK MS_NWIPX_PropertySheetProc( IN HWND hwndDlg,
  28. IN UINT uMsg,
  29. IN LPARAM lParam );
  30. INT_PTR CALLBACK MS_NWIPX_PropertiesDlgProc(
  31. IN HWND hwnd,
  32. IN UINT uMsg,
  33. IN WPARAM wParam,
  34. IN LPARAM lParam);
  35. //----------------------------------------------------------------------------
  36. //
  37. // Function: MS_NWIPX_PropertySheetProc
  38. //
  39. // Purpose:
  40. //
  41. // Arguments:
  42. //
  43. // Returns:
  44. //
  45. //----------------------------------------------------------------------------
  46. int CALLBACK MS_NWIPX_PropertySheetProc( IN HWND hwndDlg,
  47. IN UINT uMsg,
  48. IN LPARAM lParam ) {
  49. switch( uMsg ) {
  50. case PSCB_INITIALIZED:
  51. // Process PSCB_INITIALIZED
  52. break;
  53. case PSCB_PRECREATE:
  54. // Process PSCB_PRECREATE
  55. break;
  56. default:
  57. // Unknown message
  58. break;
  59. }
  60. return 0 ;
  61. }
  62. //----------------------------------------------------------------------------
  63. //
  64. // Function: Create_MS_NWIPX_PropertySheet
  65. //
  66. // Purpose:
  67. //
  68. // Arguments:
  69. //
  70. // Returns:
  71. //
  72. //----------------------------------------------------------------------------
  73. BOOL Create_MS_NWIPX_PropertySheet( HWND hwndParent ) {
  74. // Initialize property sheet HEADER data
  75. ZeroMemory( &MS_NWIPX_pshead, sizeof( PROPSHEETHEADER ) ) ;
  76. MS_NWIPX_pshead.dwSize = sizeof( PROPSHEETHEADER ) ;
  77. MS_NWIPX_pshead.dwFlags = PSH_PROPSHEETPAGE |
  78. PSH_USECALLBACK |
  79. PSH_USEHICON |
  80. PSH_NOAPPLYNOW;
  81. MS_NWIPX_pshead.hwndParent = hwndParent ;
  82. MS_NWIPX_pshead.hInstance = FixedGlobals.hInstance;
  83. MS_NWIPX_pshead.pszCaption = g_StrIpxProtocolTitle;
  84. MS_NWIPX_pshead.nPages = 1 ;
  85. MS_NWIPX_pshead.nStartPage = 0 ;
  86. MS_NWIPX_pshead.ppsp = &MS_NWIPX_pspage ;
  87. MS_NWIPX_pshead.pfnCallback = MS_NWIPX_PropertySheetProc ;
  88. // Zero out property PAGE data
  89. ZeroMemory (&MS_NWIPX_pspage, 1 * sizeof( PROPSHEETPAGE) ) ;
  90. MS_NWIPX_pspage.dwSize = sizeof( PROPSHEETPAGE ) ;
  91. MS_NWIPX_pspage.dwFlags = PSP_USECALLBACK ;
  92. MS_NWIPX_pspage.hInstance = FixedGlobals.hInstance;
  93. MS_NWIPX_pspage.pszTemplate = MAKEINTRESOURCE(IDD_IPX_CONFIG) ;
  94. MS_NWIPX_pspage.pfnDlgProc = MS_NWIPX_PropertiesDlgProc ;
  95. MS_NWIPX_pspage.pfnCallback = MS_NWIPX_PropertiesPageProc ;
  96. // --------- Create & display property sheet ---------
  97. return PropertySheet( &MS_NWIPX_pshead ) ? TRUE : FALSE ;
  98. }
  99. //----------------------------------------------------------------------------
  100. //
  101. // Function: MS_NWIPX_PropertiesPageProc
  102. //
  103. // Purpose:
  104. //
  105. // Arguments:
  106. //
  107. // Returns:
  108. //
  109. //----------------------------------------------------------------------------
  110. UINT CALLBACK
  111. MS_NWIPX_PropertiesPageProc( HWND hwnd, UINT uMsg, LPPROPSHEETPAGE ppsp ) {
  112. switch( uMsg ) {
  113. case PSPCB_CREATE :
  114. return 1 ;
  115. case PSPCB_RELEASE :
  116. return 0;
  117. }
  118. return 0 ;
  119. }
  120. //----------------------------------------------------------------------------
  121. //
  122. // Function: MS_NWIPX_PropertiesDlgProc
  123. //
  124. // Purpose:
  125. //
  126. // Arguments:
  127. //
  128. // Returns:
  129. //
  130. //----------------------------------------------------------------------------
  131. INT_PTR CALLBACK MS_NWIPX_PropertiesDlgProc(
  132. IN HWND hwnd,
  133. IN UINT uMsg,
  134. IN WPARAM wParam,
  135. IN LPARAM lParam)
  136. {
  137. BOOL bStatus = TRUE;
  138. switch( uMsg ) {
  139. case WM_INITDIALOG: {
  140. HWND hInternalNetworkNumberEditBox = GetDlgItem( hwnd,
  141. IDC_EDT_IPXAS_INTERNAL );
  142. HWND hNetworkNumberEditBox = GetDlgItem( hwnd,
  143. IDC_EDT_IPXPP_NETWORKNUMBER );
  144. StrIpxDescription = MyLoadString( IDS_IPX_DESCRIPTION );
  145. StrAutoDetect = MyLoadString( IDS_AUTO_DETECT );
  146. StrEthernet_802_2 = MyLoadString( IDS_ETHERNET_802_2 );
  147. StrEthernet_802_3 = MyLoadString( IDS_ETHERNET_802_3 );
  148. StrEthernet_II = MyLoadString( IDS_ETHERNET_II );
  149. StrEthernetSnap = MyLoadString( IDS_ETHERNET_SNAP );
  150. SetWindowText(
  151. GetDlgItem( hwnd, IDC_IPXPP_TEXT ), StrIpxDescription );
  152. //
  153. // Set the text limit on the edit boxes to MAX_NETWORKNUMBER_LENGTH
  154. //
  155. SendDlgItemMessage( hwnd,
  156. IDC_EDT_IPXAS_INTERNAL,
  157. EM_LIMITTEXT,
  158. (WPARAM) MAX_NETWORKNUMBER_LENGTH,
  159. (LPARAM) 0 );
  160. SendDlgItemMessage( hwnd,
  161. IDC_EDT_IPXPP_NETWORKNUMBER,
  162. EM_LIMITTEXT,
  163. (WPARAM) MAX_NETWORKNUMBER_LENGTH,
  164. (LPARAM) 0 );
  165. //
  166. // Fill Combo box with initial values
  167. //
  168. SendDlgItemMessage( hwnd,
  169. IDC_CMB_IPXPP_FRAMETYPE,
  170. CB_ADDSTRING,
  171. (WPARAM) 0,
  172. (LPARAM) StrAutoDetect );
  173. SendDlgItemMessage( hwnd,
  174. IDC_CMB_IPXPP_FRAMETYPE,
  175. CB_ADDSTRING,
  176. (WPARAM) 0,
  177. (LPARAM) StrEthernet_802_2 );
  178. SendDlgItemMessage( hwnd,
  179. IDC_CMB_IPXPP_FRAMETYPE,
  180. CB_ADDSTRING,
  181. (WPARAM) 0,
  182. (LPARAM) StrEthernet_802_3);
  183. SendDlgItemMessage( hwnd,
  184. IDC_CMB_IPXPP_FRAMETYPE,
  185. CB_ADDSTRING,
  186. (WPARAM) 0,
  187. (LPARAM) StrEthernet_II );
  188. SendDlgItemMessage( hwnd,
  189. IDC_CMB_IPXPP_FRAMETYPE,
  190. CB_ADDSTRING,
  191. (WPARAM) 0,
  192. (LPARAM) StrEthernetSnap );
  193. SetWindowText( hInternalNetworkNumberEditBox,
  194. NetSettings.szInternalNetworkNumber );
  195. //
  196. // Make the default selection in the combo box whatever
  197. // NetSettings.szFrameType is
  198. //
  199. if( lstrcmp( NetSettings.pCurrentAdapter->szFrameType,
  200. _T("0xFF") ) == 0 ) {
  201. SendDlgItemMessage( hwnd,
  202. IDC_CMB_IPXPP_FRAMETYPE,
  203. CB_SETCURSEL,
  204. (WPARAM) 0,
  205. (LPARAM) 0 );
  206. }
  207. else if( lstrcmp( NetSettings.pCurrentAdapter->szFrameType,
  208. _T("0x2") ) == 0 ) {
  209. SendDlgItemMessage( hwnd,
  210. IDC_CMB_IPXPP_FRAMETYPE,
  211. CB_SETCURSEL,
  212. (WPARAM) 1,
  213. (LPARAM) 0 );
  214. }
  215. else if( lstrcmp( NetSettings.pCurrentAdapter->szFrameType,
  216. _T("0x1") ) == 0 ) {
  217. SendDlgItemMessage( hwnd,
  218. IDC_CMB_IPXPP_FRAMETYPE,
  219. CB_SETCURSEL,
  220. (WPARAM) 2,
  221. (LPARAM) 0 );
  222. }
  223. else if( lstrcmp( NetSettings.pCurrentAdapter->szFrameType,
  224. _T("0x0") ) == 0 ) {
  225. SendDlgItemMessage( hwnd,
  226. IDC_CMB_IPXPP_FRAMETYPE,
  227. CB_SETCURSEL,
  228. (WPARAM) 3,
  229. (LPARAM) 0 );
  230. }
  231. else if( lstrcmp( NetSettings.pCurrentAdapter->szFrameType,
  232. _T("0x3") ) == 0 ) {
  233. SendDlgItemMessage( hwnd,
  234. IDC_CMB_IPXPP_FRAMETYPE,
  235. CB_SETCURSEL,
  236. (WPARAM) 4,
  237. (LPARAM) 0 );
  238. }
  239. if( lstrcmp( NetSettings.pCurrentAdapter->szFrameType,
  240. _T("0xFF") ) == 0 ) {
  241. EnableWindow( GetDlgItem( hwnd, IDC_STATIC_NETNUM ), FALSE );
  242. EnableWindow( GetDlgItem( hwnd, IDC_EDT_IPXPP_NETWORKNUMBER ), FALSE );
  243. }
  244. else {
  245. SetWindowText( hInternalNetworkNumberEditBox,
  246. NetSettings.szInternalNetworkNumber );
  247. SetWindowText( hNetworkNumberEditBox,
  248. NetSettings.pCurrentAdapter->szNetworkNumber );
  249. }
  250. break;
  251. }
  252. case WM_NOTIFY: {
  253. LPNMHDR pnmh = (LPNMHDR) lParam;
  254. switch( pnmh->code ) {
  255. case PSN_APPLY: {
  256. TCHAR szFrameTypeBuffer[MAX_STRING_LEN];
  257. // user clicked the OK button on the property sheet
  258. HWND hInternalNetworkNumberEditBox = GetDlgItem( hwnd, IDC_EDT_IPXAS_INTERNAL );
  259. HWND hNetworkNumberEditBox = GetDlgItem( hwnd, IDC_EDT_IPXPP_NETWORKNUMBER );
  260. HWND hFrameTypeComboBox = GetDlgItem( hwnd, IDC_CMB_IPXPP_FRAMETYPE );
  261. // 8+1 because only want to take the first 8 characters +1 for the null
  262. GetWindowText( hInternalNetworkNumberEditBox, NetSettings.szInternalNetworkNumber, 8+1 );
  263. GetWindowText( hNetworkNumberEditBox, NetSettings.pCurrentAdapter->szNetworkNumber, 8+1 );
  264. //
  265. // Map Combo Box names to the appropriate string for the answer file
  266. //
  267. GetWindowText( hFrameTypeComboBox, szFrameTypeBuffer, MAX_STRING_LEN );
  268. if( lstrcmp( szFrameTypeBuffer, StrAutoDetect ) == 0 ) {
  269. lstrcpyn( NetSettings.pCurrentAdapter->szFrameType, _T("0xFF"), AS(NetSettings.pCurrentAdapter->szFrameType) );
  270. }
  271. else if( lstrcmp( szFrameTypeBuffer, StrEthernet_802_2 ) == 0 ) {
  272. lstrcpyn( NetSettings.pCurrentAdapter->szFrameType, _T("0x2"), AS(NetSettings.pCurrentAdapter->szFrameType) );
  273. }
  274. else if( lstrcmp( szFrameTypeBuffer, StrEthernet_802_3 ) == 0 ) {
  275. lstrcpyn( NetSettings.pCurrentAdapter->szFrameType, _T("0x1"), AS(NetSettings.pCurrentAdapter->szFrameType) );
  276. }
  277. else if( lstrcmp( szFrameTypeBuffer, StrEthernet_II ) == 0 ) {
  278. lstrcpyn( NetSettings.pCurrentAdapter->szFrameType, _T("0x0"), AS(NetSettings.pCurrentAdapter->szFrameType) );
  279. }
  280. else if( lstrcmp( szFrameTypeBuffer, StrEthernetSnap ) == 0 ) {
  281. lstrcpyn( NetSettings.pCurrentAdapter->szFrameType, _T("0x3"), AS(NetSettings.pCurrentAdapter->szFrameType) );
  282. }
  283. }
  284. }
  285. break;
  286. } // end case WM_NOTIFY
  287. case WM_COMMAND: {
  288. WORD wNotifyCode = HIWORD( wParam ) ;
  289. WORD wButtonId = LOWORD( wParam ) ;
  290. if( wNotifyCode == CBN_SELCHANGE ) {
  291. if( wButtonId == IDC_CMB_IPXPP_FRAMETYPE ) {
  292. INT_PTR iIndex;
  293. HWND hNetworkNumberEditBox = GetDlgItem( hwnd, IDC_EDT_IPXPP_NETWORKNUMBER );
  294. // get the current selection from the combo box
  295. iIndex = SendDlgItemMessage( hwnd,
  296. IDC_CMB_IPXPP_FRAMETYPE,
  297. CB_GETCURSEL,
  298. (WPARAM) 0,
  299. (LPARAM) 0 ) ;
  300. // infer the settings from the index since they they added in a fixed order
  301. if( iIndex == 0 ) { // if "Auto Detect" is selected then do not let user edit the Network Number
  302. EnableWindow( GetDlgItem( hwnd, IDC_STATIC_NETNUM ), FALSE );
  303. EnableWindow( hNetworkNumberEditBox, FALSE );
  304. SetWindowText( hNetworkNumberEditBox, _T("") );
  305. }
  306. else { // else let user edit Network Number
  307. EnableWindow( GetDlgItem( hwnd, IDC_STATIC_NETNUM ), TRUE );
  308. EnableWindow( hNetworkNumberEditBox, TRUE );
  309. }
  310. }
  311. }
  312. break;
  313. }
  314. default:
  315. bStatus = FALSE;
  316. break;
  317. }
  318. return bStatus;
  319. }