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.

268 lines
8.8 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. dialogs.c
  5. Abstract:
  6. This file implements the dialog proc for the server
  7. platforms 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. PlatformsDlgProc(
  17. HWND hwnd,
  18. UINT msg,
  19. WPARAM wParam,
  20. LPARAM lParam
  21. )
  22. {
  23. static HWND hwndList;
  24. static DWORD RequireThisPlatform ;
  25. SYSTEM_INFO SystemInfo;
  26. switch( msg ) {
  27. case WM_INITDIALOG:
  28. {
  29. HIMAGELIST himlState;
  30. int iItem = 0;
  31. DWORD i;
  32. LV_ITEM lvi;
  33. LV_COLUMN lvc = {0};
  34. GetSystemInfo( &SystemInfo );
  35. if ( (SystemInfo.wProcessorArchitecture > 3) || (EnumPlatforms[SystemInfo.wProcessorArchitecture] == WRONG_PLATFORM ) ) {
  36. return FALSE;
  37. }
  38. RequireThisPlatform = EnumPlatforms[SystemInfo.wProcessorArchitecture];
  39. if (InstallMode != INSTALL_NEW) {
  40. DWORD i, Mask;
  41. for (i=0,Mask=InstalledPlatforms; i<CountPlatforms; i++) {
  42. if (Mask & 1) {
  43. Platforms[i].Selected = TRUE;
  44. }
  45. Mask = Mask >> 1;
  46. }
  47. }
  48. if( RequireThisPlatform < 4 ) {
  49. Platforms[RequireThisPlatform].Selected = TRUE;
  50. }
  51. hwndList = GetDlgItem( hwnd, IDC_PLATFORM_LIST );
  52. //
  53. // set/initialize the image list(s)
  54. //
  55. himlState = ImageList_Create( 16, 16, TRUE, 2, 0 );
  56. ImageList_AddMasked(
  57. himlState,
  58. LoadBitmap( FaxWizModuleHandle, MAKEINTRESOURCE(IDB_CHECKSTATES) ),
  59. RGB (255,0,0)
  60. );
  61. ListView_SetImageList( hwndList, himlState, LVSIL_STATE );
  62. //
  63. // set/initialize the columns
  64. //
  65. lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
  66. lvc.fmt = LVCFMT_LEFT;
  67. lvc.cx = 274;
  68. lvc.pszText = TEXT("Platform");
  69. lvc.iSubItem = 0;
  70. ListView_InsertColumn( hwndList, lvc.iSubItem, &lvc );
  71. //
  72. // add the data to the list
  73. //
  74. for (i=0,lvi.iItem=0; i<MAX_PLATFORMS; i++) {
  75. lvi.pszText = Platforms[i].PrintPlatform;
  76. lvi.iItem += 1;
  77. lvi.iSubItem = 0;
  78. lvi.iImage = 0;
  79. lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM | LVIF_STATE;
  80. lvi.state = Platforms[i].Selected ? LVIS_GCCHECK : LVIS_GCNOCHECK;
  81. lvi.stateMask = LVIS_STATEIMAGEMASK;
  82. iItem = ListView_InsertItem( hwndList, &lvi );
  83. }
  84. //
  85. // Set focus to the list control and make first un-selected platform blue.
  86. //
  87. for (i = 0 ; i < MAX_PLATFORMS ; ++ i ){
  88. if ( !Platforms[i].Selected ){
  89. break ;
  90. }
  91. }
  92. if (i == MAX_PLATFORMS ){
  93. i = 0 ;
  94. }
  95. ListView_SetItemState( hwndList, i, LVIS_FOCUSED | LVNI_SELECTED, 0x000F );
  96. }
  97. break;
  98. case WM_NOTIFY:
  99. switch( ((LPNMHDR)lParam)->code ) {
  100. case PSN_SETACTIVE:
  101. if (Unattended) {
  102. WCHAR buf[128];
  103. LPWSTR p = buf;
  104. DWORD i;
  105. UnAttendGetAnswer(
  106. UAA_PLATFORM_LIST,
  107. (LPBYTE) buf,
  108. sizeof(buf)/sizeof(WCHAR)
  109. );
  110. p = wcstok( buf, L"," );
  111. do {
  112. for (i=0; i<CountPlatforms; i++) {
  113. if (_wcsicmp( Platforms[i].OsPlatform, p ) == 0) {
  114. Platforms[i].Selected = TRUE;
  115. break;
  116. }
  117. }
  118. p = wcstok( NULL, L"," );
  119. } while(p);
  120. SetWindowLong( hwnd, DWL_MSGRESULT, -1 );
  121. return TRUE;
  122. }
  123. if (InstallMode & INSTALL_UPGRADE || InstallMode & INSTALL_REMOVE) {
  124. SetWindowLong( hwnd, DWL_MSGRESULT, -1 );
  125. return TRUE;
  126. }
  127. break;
  128. case NM_CLICK:
  129. {
  130. DWORD dwpos;
  131. LV_HITTESTINFO lvhti;
  132. int iItemClicked;
  133. UINT state;
  134. //
  135. // Find out where the cursor was
  136. //
  137. dwpos = GetMessagePos();
  138. lvhti.pt.x = LOWORD(dwpos);
  139. lvhti.pt.y = HIWORD(dwpos);
  140. MapWindowPoints( HWND_DESKTOP, hwndList, &lvhti.pt, 1 );
  141. //
  142. // Now do a hittest with this point.
  143. //
  144. iItemClicked = ListView_HitTest( hwndList, &lvhti );
  145. if (lvhti.flags & LVHT_ONITEMSTATEICON) {
  146. //
  147. // Now lets get the state from the item and toggle it.
  148. //
  149. state = ListView_GetItemState(
  150. hwndList,
  151. iItemClicked,
  152. LVIS_STATEIMAGEMASK
  153. );
  154. if ((InstallMode & INSTALL_DRIVERS &&
  155. (1<<iItemClicked) & InstalledPlatforms &&
  156. state == LVIS_GCCHECK) ||
  157. ( (DWORD)iItemClicked == RequireThisPlatform)){
  158. MessageBeep( MB_ICONEXCLAMATION );
  159. }
  160. else {
  161. state = (state == LVIS_GCNOCHECK) ? LVIS_GCCHECK : LVIS_GCNOCHECK;
  162. ListView_SetItemState(
  163. hwndList,
  164. iItemClicked,
  165. state,
  166. LVIS_STATEIMAGEMASK
  167. );
  168. Platforms[iItemClicked].Selected = (state == LVIS_GCCHECK);
  169. }
  170. }
  171. }
  172. break;
  173. case LVN_KEYDOWN:
  174. //
  175. // Use space key to toggle check boxes
  176. //
  177. if (((LV_KEYDOWN *) lParam)->wVKey == VK_SPACE) {
  178. INT index ;
  179. UINT state ;
  180. index = ListView_GetNextItem(hwndList, -1, LVNI_ALL|LVNI_SELECTED);
  181. if (index == -1) {
  182. return FALSE ;
  183. }
  184. //
  185. // Toggle.
  186. //
  187. state = ListView_GetItemState(
  188. hwndList,
  189. index,
  190. LVIS_STATEIMAGEMASK,
  191. );
  192. if ((InstallMode & INSTALL_DRIVERS &&
  193. ( 1 << index ) & InstalledPlatforms &&
  194. state == LVIS_GCCHECK) ||
  195. ( (DWORD)index == RequireThisPlatform)){
  196. MessageBeep( MB_ICONEXCLAMATION );
  197. }
  198. else {
  199. state = ( state == LVIS_GCNOCHECK )? LVIS_GCCHECK : LVIS_GCNOCHECK ;
  200. ListView_SetItemState(
  201. hwndList,
  202. index,
  203. state,
  204. LVIS_STATEIMAGEMASK
  205. );
  206. Platforms[index].Selected = ( state == LVIS_GCCHECK );
  207. }
  208. return TRUE;
  209. }
  210. break;
  211. }
  212. break;
  213. }
  214. return FALSE;
  215. }