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.

395 lines
11 KiB

  1. //----------------------------------------------------------------------------
  2. //
  3. // Copyright (c) 1997-1999 Microsoft Corporation
  4. // All rights reserved.
  5. //
  6. // File Name:
  7. // tcpipwin.c
  8. //
  9. // Description:
  10. //
  11. //----------------------------------------------------------------------------
  12. #include "pch.h"
  13. #include "resource.h"
  14. #include "tcpip.h"
  15. //----------------------------------------------------------------------------
  16. //
  17. // Function: OnTcpipWinsInitDialog
  18. //
  19. // Purpose: loads button bitmaps from resources and initializes the list view
  20. //
  21. // Arguments: IN HWND hwnd - handle to the dialog
  22. //
  23. // Returns: VOID
  24. //
  25. //----------------------------------------------------------------------------
  26. VOID
  27. OnTcpipWinsInitDialog( IN HWND hwnd ) {
  28. HWND hWINSEditButton = GetDlgItem( hwnd, IDC_WINS_EDIT );
  29. HWND hWINSRemoveButton = GetDlgItem( hwnd, IDC_WINS_REMOVE );
  30. HWND hEnableLMHostsButton = GetDlgItem( hwnd, IDC_WINS_LOOKUP );
  31. // fill the WINS list box with the appropriate initial value(s)
  32. AddValuesToListBox( GetDlgItem( hwnd, IDC_WINS_SERVER_LIST ),
  33. &NetSettings.pCurrentAdapter->Tcpip_WinsAddresses,
  34. 0 );
  35. SetButtons( GetDlgItem( hwnd, IDC_WINS_SERVER_LIST ),
  36. hWINSEditButton,
  37. hWINSRemoveButton );
  38. SetArrows( hwnd,
  39. IDC_WINS_SERVER_LIST,
  40. IDC_WINS_UP,
  41. IDC_WINS_DOWN );
  42. // set the starting state for the LMHosts check box
  43. if( NetSettings.bEnableLMHosts ) {
  44. SendMessage( hEnableLMHostsButton, BM_SETCHECK, 1, 0 );
  45. }
  46. else {
  47. SendMessage( hEnableLMHostsButton, BM_SETCHECK, 0, 0 );
  48. }
  49. // set the starting state for the NetBIOS radio button
  50. switch( NetSettings.pCurrentAdapter->iNetBiosOption ) {
  51. case 0:
  52. CheckRadioButton( hwnd,
  53. IDC_RAD_ENABLE_NETBT,
  54. IDC_RAD_UNSET_NETBT,
  55. IDC_RAD_UNSET_NETBT );
  56. break;
  57. case 1:
  58. CheckRadioButton( hwnd,
  59. IDC_RAD_ENABLE_NETBT,
  60. IDC_RAD_UNSET_NETBT,
  61. IDC_RAD_ENABLE_NETBT );
  62. break;
  63. case 2:
  64. CheckRadioButton( hwnd,
  65. IDC_RAD_ENABLE_NETBT,
  66. IDC_RAD_UNSET_NETBT,
  67. IDC_RAD_DISABLE_NETBT );
  68. break;
  69. }
  70. // Place up/down arrow icons on buttons
  71. SendDlgItemMessage( hwnd,
  72. IDC_WINS_UP,
  73. BM_SETIMAGE,
  74. (WPARAM)IMAGE_ICON,
  75. (LPARAM)g_hIconUpArrow );
  76. SendDlgItemMessage( hwnd,
  77. IDC_WINS_DOWN,
  78. BM_SETIMAGE,
  79. (WPARAM)IMAGE_ICON,
  80. (LPARAM)g_hIconDownArrow );
  81. }
  82. //----------------------------------------------------------------------------
  83. //
  84. // Function: OnTcpipWinsApply
  85. //
  86. // Purpose: stores the contents on the TCP/IP advanced WINS page into
  87. // the global variables
  88. //
  89. // Arguments: IN HWND hwnd - handle to the dialog
  90. //
  91. // Returns: VOID
  92. //
  93. //----------------------------------------------------------------------------
  94. VOID
  95. OnTcpipWinsApply( IN HWND hwnd ) {
  96. // user clicked the OK button on the property sheet
  97. INT_PTR iCount;
  98. INT_PTR i;
  99. HWND hEnableLMHostsCheckBox = GetDlgItem( hwnd,
  100. IDC_WINS_LOOKUP );
  101. // delete any old settings in the Namelist
  102. ResetNameList( &NetSettings.pCurrentAdapter->Tcpip_WinsAddresses );
  103. iCount = SendDlgItemMessage( hwnd,
  104. IDC_WINS_SERVER_LIST,
  105. LB_GETCOUNT,
  106. 0,
  107. 0 );
  108. for( i = 0; i < iCount; i++ ) {
  109. // get the IP string from the list box
  110. SendDlgItemMessage( hwnd,
  111. IDC_WINS_SERVER_LIST,
  112. LB_GETTEXT,
  113. i,
  114. (LPARAM)szIPString );
  115. // store the IP string in to the Namelist
  116. TcpipNameListInsertIdx( &NetSettings.pCurrentAdapter->Tcpip_WinsAddresses,
  117. szIPString,
  118. (int)i );
  119. }
  120. NetSettings.bEnableLMHosts =
  121. (int)SendMessage( hEnableLMHostsCheckBox,
  122. BM_GETCHECK,
  123. 0,
  124. 0 );
  125. if( IsDlgButtonChecked( hwnd,
  126. IDC_RAD_ENABLE_NETBT ) == BST_CHECKED ) {
  127. NetSettings.pCurrentAdapter->iNetBiosOption = 1;
  128. }
  129. else if( IsDlgButtonChecked( hwnd,
  130. IDC_RAD_DISABLE_NETBT ) == BST_CHECKED ) {
  131. NetSettings.pCurrentAdapter->iNetBiosOption = 2;
  132. }
  133. else {
  134. NetSettings.pCurrentAdapter->iNetBiosOption = 0;
  135. }
  136. }
  137. //----------------------------------------------------------------------------
  138. //
  139. // Function: TCPIP_WINSPageProc
  140. //
  141. // Purpose: Required function for the property sheet page to function properly.
  142. // The important thing is to give the return value of 1 to the message PSPCB_CREATE and
  143. // 0 for PSPCB_RELEASE
  144. //
  145. // Arguments:
  146. //
  147. // Returns:
  148. //
  149. //----------------------------------------------------------------------------
  150. UINT CALLBACK
  151. TCPIP_WINSPageProc( HWND hwnd, UINT uMsg, LPPROPSHEETPAGE ppsp ) {
  152. switch( uMsg ) {
  153. case PSPCB_CREATE :
  154. return 1 ; // needed for property sheet page to initialize correctly
  155. case PSPCB_RELEASE :
  156. return 0;
  157. default:
  158. return -1;
  159. }
  160. }
  161. //----------------------------------------------------------------------------
  162. //
  163. // Function: TCPIP_WINSDlgProc
  164. //
  165. // Purpose: Dialog procedure for the WINS page of the property sheet
  166. // handles all the messages sent to this window
  167. //
  168. // Arguments:
  169. //
  170. // Returns:
  171. //
  172. //----------------------------------------------------------------------------
  173. INT_PTR CALLBACK
  174. TCPIP_WINSDlgProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) {
  175. switch( uMsg ) {
  176. case WM_INITDIALOG: {
  177. OnTcpipWinsInitDialog( hwndDlg );
  178. return TRUE ;
  179. }
  180. case WM_COMMAND: {
  181. WORD wNotifyCode = HIWORD( wParam );
  182. WORD wButtonId = LOWORD( wParam );
  183. if( wNotifyCode == LBN_SELCHANGE ) {
  184. SetArrows( hwndDlg,
  185. IDC_WINS_SERVER_LIST,
  186. IDC_WINS_UP,
  187. IDC_WINS_DOWN );
  188. }
  189. switch ( wButtonId ) {
  190. case IDC_RAD_ENABLE_NETBT:
  191. if( wNotifyCode == BN_CLICKED ) {
  192. CheckRadioButton( hwndDlg,
  193. IDC_RAD_ENABLE_NETBT,
  194. IDC_RAD_UNSET_NETBT,
  195. IDC_RAD_ENABLE_NETBT );
  196. }
  197. return TRUE ;
  198. case IDC_RAD_DISABLE_NETBT:
  199. if( wNotifyCode == BN_CLICKED ) {
  200. CheckRadioButton( hwndDlg,
  201. IDC_RAD_ENABLE_NETBT,
  202. IDC_RAD_UNSET_NETBT,
  203. IDC_RAD_DISABLE_NETBT );
  204. }
  205. return TRUE ;
  206. case IDC_RAD_UNSET_NETBT:
  207. if( wNotifyCode == BN_CLICKED ) {
  208. CheckRadioButton( hwndDlg,
  209. IDC_RAD_ENABLE_NETBT,
  210. IDC_RAD_UNSET_NETBT,
  211. IDC_RAD_UNSET_NETBT );
  212. }
  213. return TRUE ;
  214. case IDC_WINS_ADD:
  215. g_CurrentEditBox = WINS_EDITBOX;
  216. OnAddButtonPressed( hwndDlg,
  217. IDC_WINS_SERVER_LIST,
  218. IDC_WINS_EDIT,
  219. IDC_WINS_REMOVE,
  220. (LPCTSTR) IDD_WINS_SERVER,
  221. GenericIPDlgProc );
  222. SetArrows( hwndDlg,
  223. IDC_WINS_SERVER_LIST,
  224. IDC_WINS_UP,
  225. IDC_WINS_DOWN );
  226. return TRUE ;
  227. case IDC_WINS_EDIT:
  228. g_CurrentEditBox = WINS_EDITBOX;
  229. OnEditButtonPressed( hwndDlg,
  230. IDC_WINS_SERVER_LIST,
  231. (LPCTSTR) IDD_WINS_SERVER,
  232. GenericIPDlgProc );
  233. SetArrows( hwndDlg,
  234. IDC_WINS_SERVER_LIST,
  235. IDC_WINS_UP,
  236. IDC_WINS_DOWN );
  237. return TRUE ;
  238. case IDC_WINS_REMOVE:
  239. OnRemoveButtonPressed( hwndDlg,
  240. IDC_WINS_SERVER_LIST,
  241. IDC_WINS_EDIT,
  242. IDC_WINS_REMOVE );
  243. SetArrows( hwndDlg,
  244. IDC_WINS_SERVER_LIST,
  245. IDC_WINS_UP,
  246. IDC_WINS_DOWN );
  247. return TRUE ;
  248. case IDC_WINS_UP:
  249. OnUpButtonPressed( hwndDlg, IDC_WINS_SERVER_LIST );
  250. SetArrows( hwndDlg,
  251. IDC_WINS_SERVER_LIST,
  252. IDC_WINS_UP,
  253. IDC_WINS_DOWN );
  254. return TRUE ;
  255. case IDC_WINS_DOWN:
  256. OnDownButtonPressed( hwndDlg, IDC_WINS_SERVER_LIST );
  257. SetArrows( hwndDlg,
  258. IDC_WINS_SERVER_LIST,
  259. IDC_WINS_UP,
  260. IDC_WINS_DOWN );
  261. return TRUE ;
  262. case IDC_WINS_LMHOST:
  263. // ISSUE-2002/02/28-stelo- this either needs to be removed or implemented
  264. AssertMsg(FALSE,
  265. "This button has not been implemented yet.");
  266. return TRUE ;
  267. } // end switch
  268. return FALSE;
  269. }
  270. case WM_NOTIFY: {
  271. LPNMHDR pnmh = (LPNMHDR) lParam ;
  272. switch( pnmh->code ) {
  273. case PSN_APPLY: {
  274. OnTcpipWinsApply( hwndDlg );
  275. return TRUE ;
  276. }
  277. }
  278. default:
  279. return FALSE ;
  280. }
  281. }
  282. }