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.

259 lines
6.4 KiB

  1. //----------------------------------------------------------------------------
  2. //
  3. // Copyright (c) 1997-1999 Microsoft Corporation
  4. // All rights reserved.
  5. //
  6. // File Name:
  7. // protocol.c
  8. //
  9. // Description:
  10. //
  11. //
  12. //----------------------------------------------------------------------------
  13. #include "pch.h"
  14. #include "resource.h"
  15. int CALLBACK ListViewCompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort);
  16. //----------------------------------------------------------------------------
  17. //
  18. // Function: InitSelectProtocolListView
  19. //
  20. // Purpose:
  21. //
  22. //----------------------------------------------------------------------------
  23. VOID InitSelectProtocolListView( HWND hDlg, HINSTANCE hInst )
  24. {
  25. LV_ITEM lvI; // list view item structure
  26. HWND hProtocolListView; // handle to list view window
  27. NETWORK_COMPONENT *pNetComponent;
  28. hProtocolListView = GetDlgItem( hDlg, IDC_SELECT_PROTOCOL_LIST );
  29. for( pNetComponent = NetSettings.NetComponentsList;
  30. pNetComponent;
  31. pNetComponent = pNetComponent->next )
  32. {
  33. if( pNetComponent->bInstalled == FALSE &&
  34. pNetComponent->ComponentType == PROTOCOL )
  35. {
  36. //
  37. // If it is not a sysprep then just go ahead and add it to the
  38. // list view. If we are doing a sysprep, check to see if this
  39. // component is supported by sysprep to see if we should add it
  40. // or not
  41. //
  42. if( WizGlobals.iProductInstall == PRODUCT_SYSPREP )
  43. {
  44. if( pNetComponent->bSysprepSupport )
  45. {
  46. InsertEntryIntoListView( hProtocolListView,
  47. (LPARAM) pNetComponent );
  48. }
  49. }
  50. else
  51. {
  52. InsertEntryIntoListView( hProtocolListView,
  53. (LPARAM) pNetComponent );
  54. }
  55. }
  56. }
  57. SetListViewSelection( hDlg, IDC_SELECT_PROTOCOL_LIST, 0 );
  58. }
  59. //----------------------------------------------------------------------------
  60. //
  61. // Function: OnProtocolOk
  62. //
  63. // Purpose:
  64. //
  65. // Arguments: IN HWND hwnd - handle to the dialog
  66. //
  67. // Returns: VOID
  68. //
  69. //----------------------------------------------------------------------------
  70. static VOID
  71. OnProtocolOk( IN HWND hwnd )
  72. {
  73. LV_ITEM lvI;
  74. // ISSUE-2002/02/28-stelo- if there is no item selected and the user clicks OK the dialog should NOT close
  75. // see if there is an item selected
  76. if( GetSelectedItemFromListView( hwnd, IDC_SELECT_PROTOCOL_LIST, &lvI ) )
  77. {
  78. NETWORK_COMPONENT *pEntry = (NETWORK_COMPONENT *)lvI.lParam;
  79. pEntry->bInstalled = TRUE;
  80. // return a 1 to show an item was actually added
  81. EndDialog(hwnd, 1);
  82. }
  83. else
  84. {
  85. // return a 0 to show no items were added because the list is empty
  86. EndDialog(hwnd, 0);
  87. }
  88. }
  89. //----------------------------------------------------------------------------
  90. //
  91. // Function: NotifyHandler
  92. //
  93. // Purpose:
  94. //
  95. // Arguments: IN HWND hwnd - handle to the dialog
  96. // IN WPARAM wParam -
  97. // IN LPARAM lParam -
  98. //
  99. // Returns: BOOL - whether the message was handled or not
  100. //
  101. //----------------------------------------------------------------------------
  102. static BOOL
  103. NotifyHandler( IN HWND hwnd, IN WPARAM wParam, IN LPARAM lParam )
  104. {
  105. LV_DISPINFO *pLvdi = (LV_DISPINFO *)lParam;
  106. NM_LISTVIEW *pNm = (NM_LISTVIEW *)lParam;
  107. NETWORK_COMPONENT *pListViewString = (NETWORK_COMPONENT *)(pLvdi->item.lParam);
  108. BOOL bStatus = TRUE;
  109. if( wParam == IDC_SELECT_PROTOCOL_LIST )
  110. {
  111. switch( pLvdi->hdr.code )
  112. {
  113. case LVN_GETDISPINFO:
  114. pLvdi->item.pszText = pListViewString->StrComponentName;
  115. break;
  116. }
  117. switch( pNm->hdr.code )
  118. {
  119. case NM_DBLCLK:
  120. {
  121. NMITEMACTIVATE *pNmItemActivate = (NMITEMACTIVATE *) lParam;
  122. //
  123. // see if the user has double clicked inside the list view
  124. //
  125. if( pNm->hdr.idFrom == IDC_SELECT_PROTOCOL_LIST )
  126. {
  127. //
  128. // Make sure they actually clicked on an item and not just
  129. // empty space
  130. //
  131. if( pNmItemActivate->iItem != -1 )
  132. {
  133. OnProtocolOk( hwnd );
  134. }
  135. }
  136. break;
  137. }
  138. default:
  139. bStatus = FALSE;
  140. break;
  141. }
  142. }
  143. return( bStatus );
  144. }
  145. //----------------------------------------------------------------------------
  146. //
  147. // Function: SelectNetworkProtocolDlgProc
  148. //
  149. // Purpose:
  150. //
  151. //----------------------------------------------------------------------------
  152. INT_PTR CALLBACK SelectNetworkProtocolDlgProc(
  153. IN HWND hwnd,
  154. IN UINT uMsg,
  155. IN WPARAM wParam,
  156. IN LPARAM lParam)
  157. {
  158. BOOL bStatus = TRUE;
  159. switch (uMsg) {
  160. case WM_DESTROY:
  161. // do nothing
  162. break;
  163. case WM_INITDIALOG:
  164. InitSelectProtocolListView(hwnd, FixedGlobals.hInstance);
  165. break;
  166. case WM_COMMAND:
  167. {
  168. int nButtonId;
  169. switch ( nButtonId = LOWORD(wParam) ) {
  170. case IDOK:
  171. OnProtocolOk( hwnd );
  172. break;
  173. case IDCANCEL:
  174. // return a 0 to show no items were added
  175. EndDialog(hwnd, 0);
  176. break;
  177. case IDC_HAVEDISK:
  178. // ISSUE-2002/02/28-stelo- this needs to be implemented
  179. AssertMsg(FALSE,
  180. "This button has not been implemented yet.");
  181. break;
  182. default:
  183. bStatus = FALSE;
  184. break;
  185. }
  186. break;
  187. }
  188. case WM_NOTIFY:
  189. NotifyHandler( hwnd, wParam, lParam );
  190. break;
  191. default:
  192. bStatus = FALSE;
  193. break;
  194. }
  195. return( bStatus );
  196. }