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.

245 lines
6.3 KiB

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