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.

202 lines
6.1 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. dlgdvsel.c
  5. Abstract:
  6. This file implements the dialog proc for the workstation
  7. device selection page.
  8. Environment:
  9. WIN32 User Mode
  10. Author:
  11. Wesley Witt (wesw) 17-Feb-1996
  12. --*/
  13. #include "wizard.h"
  14. #pragma hdrstop
  15. LRESULT
  16. DeviceSelectionDlgProc(
  17. HWND hwnd,
  18. UINT msg,
  19. WPARAM wParam,
  20. LPARAM lParam
  21. )
  22. {
  23. static HWND hwndList;
  24. static DWORD TotalDevicesSelected;
  25. switch( msg ) {
  26. case WM_INITDIALOG:
  27. {
  28. HIMAGELIST himlState;
  29. int iItem = 0;
  30. DWORD i;
  31. LV_ITEM lvi;
  32. LV_COLUMN lvc = {0};
  33. for (i=0,lvi.iItem=0,TotalDevicesSelected=0; i<FaxDevices; i++) {
  34. LineInfo[i].Selected = TRUE;
  35. TotalDevicesSelected += 1;
  36. if (RequestedSetupType & FAX_INSTALL_WORKSTATION && TotalDevicesSelected == MAX_DEVICES_NTW) {
  37. break;
  38. }
  39. }
  40. hwndList = GetDlgItem( hwnd, IDC_DEVICE_LIST );
  41. //
  42. // set/initialize the image list(s)
  43. //
  44. himlState = ImageList_Create( 16, 16, TRUE, 2, 0 );
  45. ImageList_AddMasked(
  46. himlState,
  47. LoadBitmap( FaxWizModuleHandle, MAKEINTRESOURCE(IDB_CHECKSTATES) ),
  48. RGB (255,0,0)
  49. );
  50. ListView_SetImageList( hwndList, himlState, LVSIL_STATE );
  51. //
  52. // set/initialize the columns
  53. //
  54. lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
  55. lvc.fmt = LVCFMT_LEFT;
  56. lvc.cx = 274;
  57. lvc.pszText = TEXT("Device Name");
  58. lvc.iSubItem = 0;
  59. ListView_InsertColumn( hwndList, lvc.iSubItem, &lvc );
  60. //
  61. // add the data to the list
  62. //
  63. for (i=0,lvi.iItem=0; i<FaxDevices; i++) {
  64. lvi.pszText = LineInfo[i].DeviceName;
  65. lvi.iItem += 1;
  66. lvi.iSubItem = 0;
  67. lvi.iImage = 0;
  68. lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM | LVIF_STATE;
  69. lvi.state = LineInfo[i].Selected ? LVIS_GCCHECK : LVIS_GCNOCHECK;
  70. lvi.stateMask = LVIS_STATEIMAGEMASK;
  71. iItem = ListView_InsertItem( hwndList, &lvi );
  72. }
  73. }
  74. break;
  75. case WM_NOTIFY:
  76. switch( ((LPNMHDR)lParam)->code ) {
  77. case PSN_SETACTIVE:
  78. if (Unattended) {
  79. SetWindowLong( hwnd, DWL_MSGRESULT, -1 );
  80. return TRUE;
  81. }
  82. if (InstallMode & INSTALL_UPGRADE || InstallMode & INSTALL_REMOVE || FaxDevices == 1) {
  83. SetWindowLong( hwnd, DWL_MSGRESULT, -1 );
  84. return TRUE;
  85. }
  86. break;
  87. case NM_CLICK:
  88. {
  89. DWORD dwpos;
  90. LV_HITTESTINFO lvhti;
  91. int iItemClicked;
  92. UINT state;
  93. //
  94. // Find out where the cursor was
  95. //
  96. dwpos = GetMessagePos();
  97. lvhti.pt.x = LOWORD(dwpos);
  98. lvhti.pt.y = HIWORD(dwpos);
  99. MapWindowPoints( HWND_DESKTOP, hwndList, &lvhti.pt, 1 );
  100. //
  101. // Now do a hittest with this point.
  102. //
  103. iItemClicked = ListView_HitTest( hwndList, &lvhti );
  104. if (lvhti.flags & LVHT_ONITEMSTATEICON) {
  105. //
  106. // Now lets get the state from the item and toggle it.
  107. //
  108. state = ListView_GetItemState(
  109. hwndList,
  110. iItemClicked,
  111. LVIS_STATEIMAGEMASK
  112. );
  113. if (state == LVIS_GCCHECK) {
  114. //
  115. // de-selecting a device
  116. //
  117. if (TotalDevicesSelected == 1) {
  118. MessageBeep(0);
  119. break;
  120. }
  121. TotalDevicesSelected -= 1;
  122. LineInfo[iItemClicked].Selected = FALSE;
  123. ListView_SetItemState(
  124. hwndList,
  125. iItemClicked,
  126. LVIS_GCNOCHECK,
  127. LVIS_STATEIMAGEMASK
  128. );
  129. } else {
  130. //
  131. // selecting a new device
  132. //
  133. if (RequestedSetupType & FAX_INSTALL_WORKSTATION && TotalDevicesSelected == MAX_DEVICES_NTW) {
  134. MessageBeep(0);
  135. break;
  136. }
  137. TotalDevicesSelected += 1;
  138. LineInfo[iItemClicked].Selected = TRUE;
  139. ListView_SetItemState(
  140. hwndList,
  141. iItemClicked,
  142. LVIS_GCNOCHECK,
  143. LVIS_STATEIMAGEMASK
  144. );
  145. }
  146. }
  147. }
  148. }
  149. break;
  150. }
  151. return FALSE;
  152. }