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.

309 lines
7.1 KiB

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