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.

979 lines
27 KiB

  1. #include "precomp.h"
  2. #pragma hdrstop
  3. /***************************************************************************/
  4. /****************** Special Dialog Handlers ****************************/
  5. /***************************************************************************/
  6. /* This module contains handlers for the optional windows components dialogs.
  7. ** Two dialog procedures are provided for doing the special check box and the
  8. ** dual dialog box procedures.
  9. */
  10. /* 1. Special Check Box Procedure to handle the Partial Install main dialog.
  11. */
  12. /*
  13. ** Purpose:
  14. ** Special CheckBox Dialog procedure for templates with one to ten checkbox
  15. ** controls. This handles notifications.
  16. ** Control IDs:
  17. ** The Checkbox controls must have sequential ids starting with IDC_B1
  18. ** and working up to a maximum of IDC_B10.
  19. ** Pushbuttons recognized are IDC_O, IDC_C, IDC_M, IDC_H, IDC_X, and IDC_B.
  20. ** Initialization:
  21. ** The symbol $(CheckItemsIn) is evaluated as a list of elements of
  22. ** either 'ON' or 'OFF'. So examples for a template with four
  23. ** checkbox controls would include {ON, ON, ON, ON},
  24. ** {ON, OFF, ON, OFF} and {OFF, OFF, OFF, OFF}. These elements
  25. ** determine if the initial state of the corresponding checkbox
  26. ** control is checked (ON) or unchecked (OFF). If there are more
  27. ** controls than elements, the extra controls will be initialized
  28. ** as unchecked. If there are more elements than controls, the
  29. ** extra elements are ignored.
  30. ** The symbol $(OptionsGreyed) is evaluated as a list of indexes
  31. ** (one-based) of check boxes to be disabled (greyed). Default is
  32. ** none.
  33. ** Termination:
  34. ** The state of each checkbox is queried and a list with the same format
  35. ** as the initialization list is created and stored in the symbol
  36. ** $(CheckItemsOut).
  37. ** The id of the Pushbutton (eg IDC_C) which caused termination is
  38. ** converted to a string and stored in the symbol $(ButtonPressed).
  39. **
  40. *****************************************************************************/
  41. INT_PTR APIENTRY FGstCheck1DlgProc(HWND hdlg,
  42. UINT wMsg,
  43. WPARAM wParam,
  44. LPARAM lParam)
  45. {
  46. CHP rgchNum[10];
  47. static INT nBoxes;
  48. static BOOL fChecked[10];
  49. static INT nSize[10];
  50. static INT nTotalSize;
  51. static INT nMaxSize;
  52. WORD idc;
  53. RGSZ rgsz, rgsz1;
  54. PSZ psz, psz1;
  55. SZ sz, sz1, sz2;
  56. Unused(lParam);
  57. switch (wMsg)
  58. {
  59. case STF_REINITDIALOG:
  60. if ((sz = SzFindSymbolValueInSymTab("ReInit")) == (SZ)NULL ||
  61. (CrcStringCompareI(sz, "YES") != crcEqual))
  62. return(fTrue);
  63. case WM_INITDIALOG:
  64. AssertDataSeg();
  65. if( wMsg == WM_INITDIALOG ) {
  66. FCenterDialogOnDesktop(hdlg);
  67. }
  68. //
  69. // Get the check box Checked/Not Checked variable
  70. //
  71. if ((sz = SzFindSymbolValueInSymTab("CheckItemsIn")) == (SZ)NULL)
  72. {
  73. PreCondition(fFalse, fTrue);
  74. return(fTrue);
  75. }
  76. while ((psz = rgsz = RgszFromSzListValue(sz)) == (RGSZ)NULL)
  77. if (!FHandleOOM(hdlg))
  78. {
  79. DestroyWindow(GetParent(hdlg));
  80. return(fTrue);
  81. }
  82. //
  83. // Get the sizes associated with each check box option
  84. //
  85. if ((sz1 = SzFindSymbolValueInSymTab("CheckItemsInSizes")) == (SZ)NULL)
  86. {
  87. PreCondition(fFalse, fTrue);
  88. return(fTrue);
  89. }
  90. while ((psz1 = rgsz1 = RgszFromSzListValue(sz1)) == (RGSZ)NULL)
  91. if (!FHandleOOM(hdlg))
  92. {
  93. DestroyWindow(GetParent(hdlg));
  94. return(fTrue);
  95. }
  96. //
  97. // Get the total size available
  98. //
  99. if ((sz2 = SzFindSymbolValueInSymTab("SizeAvailable")) == (SZ)NULL)
  100. {
  101. PreCondition(fFalse, fTrue);
  102. return(fTrue);
  103. }
  104. //
  105. // Get the check box states, the number of check boxes and the
  106. // sizes associated with each
  107. //
  108. idc = IDC_B1;
  109. nBoxes = 0;
  110. nTotalSize = 0;
  111. while (*psz != (SZ)NULL) {
  112. WORD wCheck = 0;
  113. HWND hwndItem = GetDlgItem(hdlg, IDC_SP1 + idc - IDC_B1);
  114. if (CrcStringCompare(*(psz++), "ON") == crcEqual) {
  115. wCheck = 1;
  116. }
  117. if(!wCheck) {
  118. if( GetFocus() == hwndItem ) {
  119. SetFocus(GetDlgItem(hdlg, IDC_C));
  120. }
  121. }
  122. EnableWindow(GetDlgItem(hdlg, IDC_SP1 + idc - IDC_B1), wCheck);
  123. CheckDlgButton(hdlg, idc++, wCheck);
  124. //
  125. // Maintain checked / not checked status
  126. //
  127. fChecked[nBoxes] = (BOOL) wCheck;
  128. if (*psz1 == (SZ)NULL) {
  129. PreCondition (fFalse, fTrue);
  130. return ( fTrue );
  131. }
  132. nSize[nBoxes] = atol (*(psz1++));
  133. nTotalSize = nTotalSize + (fChecked[nBoxes] ? nSize[nBoxes] : 0L);
  134. MySetDlgItemInt (
  135. hdlg,
  136. IDC_SIZE1 + nBoxes,
  137. fChecked[nBoxes] ? nSize[nBoxes] : 0
  138. );
  139. nBoxes++;
  140. }
  141. //
  142. // Update the total added size
  143. //
  144. MySetDlgItemInt (
  145. hdlg,
  146. IDC_TOTAL1,
  147. nTotalSize
  148. );
  149. //
  150. // Get the maximum size
  151. //
  152. nMaxSize = atol(sz2) * 1024L * 1024L; // M -> Bytes
  153. //
  154. // Update the mazimum size
  155. //
  156. MySetDlgItemInt (
  157. hdlg,
  158. IDC_MAX1,
  159. nMaxSize
  160. );
  161. //
  162. // Free the structure to the check lists
  163. //
  164. EvalAssert(FFreeRgsz(rgsz));
  165. EvalAssert(FFreeRgsz(rgsz1));
  166. //
  167. // If items are to be disabled, do this
  168. //
  169. if ((sz = SzFindSymbolValueInSymTab("OptionsGreyed")) == (SZ)NULL) {
  170. PreCondition(fFalse, fTrue);
  171. return(fTrue);
  172. }
  173. while ((psz = rgsz = RgszFromSzListValue(sz)) == (RGSZ)NULL) {
  174. if (!FHandleOOM(hdlg)) {
  175. DestroyWindow(GetParent(hdlg));
  176. return(fTrue);
  177. }
  178. }
  179. while (*psz != (SZ)NULL) {
  180. SZ sz = *(psz++);
  181. INT i = atoi(sz);
  182. if (i > 0 && i <= 10) {
  183. HWND hwndItem = GetDlgItem(hdlg, IDC_B0 + i);
  184. if( GetFocus() == hwndItem ) {
  185. //
  186. // transfer focus to the continue button
  187. //
  188. SetFocus(GetDlgItem(hdlg, IDC_C));
  189. }
  190. EnableWindow(hwndItem, 0);
  191. }
  192. else if (*sz != '\0') {
  193. PreCondition(fFalse, fTrue);
  194. }
  195. }
  196. EvalAssert(FFreeRgsz(rgsz));
  197. //
  198. // End processing
  199. //
  200. return(fTrue);
  201. // case STF_DLG_ACTIVATE:
  202. // case WM_MOUSEACTIVATE:
  203. // if (FActiveStackTop())
  204. // break;
  205. // EvalAssert(FInactivateHelp());
  206. // SetWindowPos(hdlg, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
  207. // /* fall through */
  208. // case STF_UILIB_ACTIVATE:
  209. // EvalAssert(FActivateStackTop());
  210. // return(fTrue);
  211. case WM_CLOSE:
  212. PostMessage(
  213. hdlg,
  214. WM_COMMAND,
  215. MAKELONG(IDC_X, BN_CLICKED),
  216. 0L
  217. );
  218. return(fTrue);
  219. case WM_COMMAND:
  220. switch (idc = LOWORD(wParam))
  221. {
  222. case IDC_B1:
  223. case IDC_B2:
  224. case IDC_B3:
  225. case IDC_B4:
  226. case IDC_B5:
  227. case IDC_B6:
  228. case IDC_B7:
  229. case IDC_B8:
  230. case IDC_B9:
  231. case IDC_B10:
  232. {
  233. INT nSizeItem;
  234. //
  235. // Toggle the check state
  236. //
  237. CheckDlgButton( hdlg, idc, (WORD)!IsDlgButtonChecked( hdlg, idc ) );
  238. //
  239. // Update the size of this item and the total
  240. //
  241. if (fChecked[idc - IDC_B1] = IsDlgButtonChecked (hdlg, idc )) {
  242. nSizeItem = nSize[idc - IDC_B1];
  243. nTotalSize = nTotalSize + nSizeItem;
  244. }
  245. else {
  246. nSizeItem = 0L;
  247. if ( (nTotalSize = nTotalSize - nSize[idc - IDC_B1]) < 0 ) {
  248. nTotalSize = 0;
  249. }
  250. }
  251. //
  252. // Update the customise window
  253. //
  254. EnableWindow(
  255. GetDlgItem(hdlg, IDC_SP1 + idc - IDC_B1),
  256. fChecked[idc - IDC_B1]
  257. );
  258. //
  259. // Update the check item size
  260. //
  261. MySetDlgItemInt (
  262. hdlg,
  263. IDC_SIZE1 + idc - IDC_B1,
  264. nSizeItem
  265. );
  266. //
  267. // Update the total added size
  268. //
  269. MySetDlgItemInt (
  270. hdlg,
  271. IDC_TOTAL1,
  272. nTotalSize
  273. );
  274. }
  275. break;
  276. case IDCANCEL:
  277. if (LOWORD(wParam) == IDCANCEL) {
  278. if (!GetDlgItem(hdlg, IDC_B) || HIWORD(GetKeyState(VK_CONTROL)) || HIWORD(GetKeyState(VK_SHIFT)) || HIWORD(GetKeyState(VK_MENU)))
  279. {
  280. break;
  281. }
  282. wParam = IDC_B;
  283. }
  284. case IDC_SP1:
  285. case IDC_SP2:
  286. case IDC_SP3:
  287. case IDC_SP4:
  288. case IDC_SP5:
  289. case IDC_SP6:
  290. case IDC_SP7:
  291. case IDC_SP8:
  292. case IDC_SP9:
  293. case IDC_SP10:
  294. case IDC_O:
  295. case IDC_C:
  296. case IDC_M:
  297. case IDC_B:
  298. case IDC_X:
  299. case IDC_BTN0:
  300. case IDC_BTN1: case IDC_BTN2: case IDC_BTN3:
  301. case IDC_BTN4: case IDC_BTN5: case IDC_BTN6:
  302. case IDC_BTN7: case IDC_BTN8: case IDC_BTN9:
  303. _itoa((INT)wParam, rgchNum, 10);
  304. while (!FAddSymbolValueToSymTab("ButtonPressed", rgchNum))
  305. if (!FHandleOOM(hdlg))
  306. {
  307. DestroyWindow(GetParent(hdlg));
  308. return(fTrue);
  309. }
  310. while ((psz = rgsz = (RGSZ)SAlloc((CB)(11 * sizeof(SZ)))) ==
  311. (RGSZ)NULL)
  312. if (!FHandleOOM(hdlg))
  313. {
  314. DestroyWindow(GetParent(hdlg));
  315. return(fTrue);
  316. }
  317. for (idc = IDC_B1; GetDlgItem(hdlg, idc); psz++, idc++)
  318. {
  319. BOOL fChecked = IsDlgButtonChecked(hdlg, idc);
  320. while ((*psz = SzDupl(fChecked ? "ON" : "OFF")) == (SZ)NULL)
  321. if (!FHandleOOM(hdlg))
  322. {
  323. DestroyWindow(GetParent(hdlg));
  324. return(fTrue);
  325. }
  326. }
  327. *psz = (SZ)NULL;
  328. while ((sz = SzListValueFromRgsz(rgsz)) == (SZ)NULL)
  329. if (!FHandleOOM(hdlg))
  330. {
  331. DestroyWindow(GetParent(hdlg));
  332. return(fTrue);
  333. }
  334. while (!FAddSymbolValueToSymTab("CheckItemsOut", sz))
  335. if (!FHandleOOM(hdlg))
  336. {
  337. DestroyWindow(GetParent(hdlg));
  338. return(fTrue);
  339. }
  340. SFree(sz);
  341. EvalAssert(FFreeRgsz(rgsz));
  342. PostMessage(GetParent(hdlg), (WORD)STF_UI_EVENT, 0, 0L);
  343. break;
  344. }
  345. break;
  346. case STF_DESTROY_DLG:
  347. PostMessage(GetParent(hdlg), (WORD)STF_CHECK_DLG_DESTROYED, 0, 0L);
  348. DestroyWindow(hdlg);
  349. return(fTrue);
  350. }
  351. return(fFalse);
  352. }
  353. /* 2. The dual list dialog box procedure to handle detailed selection of
  354. ** optional files
  355. */
  356. //
  357. // Macros for the dual list box
  358. //
  359. #define nSizeOfItem(lItem) atol( ((RGSZ)lItem)[1] )
  360. //
  361. // External dual list box handling routines (defined in dualproc.c)
  362. //
  363. BOOL fFillListBoxFromSzList (HWND, WORD, SZ);
  364. BOOL fFreeListBoxEntries (HWND, WORD);
  365. SZ szGetSzListFromListBox (HWND, WORD);
  366. //
  367. // Local function to update the status fields in the partial dual list box
  368. //
  369. static BOOL fUpdateStatus ( HDLG, WORD );
  370. /*
  371. ** Author:
  372. ** Sunil Pai, 8/21/91, Adapted from Win3.1 setup code.
  373. **
  374. ** Purpose:
  375. ** Dual Listbox Dialog procedure for templates with two listboxes
  376. ** exchanging selection items. This is implemented with owner draw
  377. ** list boxes.
  378. **
  379. ** Control IDs:
  380. ** The Listbox controls must have the id IDC_LIST1 and IDC_LIST2.
  381. ** Pushbuttons recognized are IDC_O, IDC_C, IDC_M, IDC_H, IDC_X, and IDC_B.
  382. ** In addition to these the following IDs are processed:
  383. ** - IDC_A: To move a selected item(s) in listbox1 to listbox2
  384. ** - IDC_R: To move a selected item(s) in listbox2 to listbox1
  385. ** - IDC_S: To move all items in listbox1 to listbox2
  386. **
  387. ** Initialization:
  388. ** The symbol $(ListItemsIn) is a list of strings to insert into the
  389. ** listbox 1. The symbol $(ListItemOut) is a list of strings to insert
  390. ** into listbox 2. Items can be added to listbox2 or removed to
  391. ** listbox1. All items can be shifted to listbox2 using the Add All
  392. ** button.
  393. **
  394. ** The $(ListItemsIn) and $(ListItemsOut can be:
  395. **
  396. ** a) A Simple List:
  397. ** {$(ListElem1), $(ListElem2)...}
  398. **
  399. ** b) A Compound List:
  400. **
  401. ** { {$(ListItem1Data), $(ListItem1Aux1), $(ListItem1Aux2)...},
  402. ** {$(ListItem2Data), $(ListItem2Aux1), $(ListItem2Aux2)...},
  403. ** ...
  404. ** }
  405. **
  406. ** In the case of a compound list the $(ListItemnData) field is displayed
  407. ** in the listbox. When any item is selected the selection displays the
  408. ** fields in the selection in the status fields in the dialog.
  409. ** - ListItemnData is displayed in the IDC_TEXT1 field if present
  410. ** - ListItemnAux1 is displayed in the IDC_TEXT2 field if present
  411. ** - ListItemnAux2 is displayed in the IDC_TEXT3 field if present
  412. ** ...
  413. **
  414. ** Termination:
  415. ** The items in listbox2 are returned in
  416. ** $(ListItemsOut). The id of the Pushbutton (eg IDC_C) which caused
  417. ** termination is converted to a string and stored in the symbol
  418. **
  419. *****************************************************************************/
  420. INT_PTR APIENTRY FGstDual1DlgProc(HWND hdlg, UINT wMsg, WPARAM wParam, LPARAM lParam)
  421. {
  422. CHP rgchNum[10];
  423. SZ szList;
  424. INT i, nCount;
  425. WORD idc, idcSrc, idcDst;
  426. LONG_PTR lItem;
  427. RGSZ rgszItem;
  428. PSZ pszItem;
  429. switch (wMsg)
  430. {
  431. case WM_INITDIALOG:
  432. AssertDataSeg();
  433. FCenterDialogOnDesktop(hdlg);
  434. // Find the List Items In and initialise the first list box
  435. if ((szList = SzFindSymbolValueInSymTab("ListItemsIn")) == (SZ)NULL)
  436. {
  437. Assert(fFalse);
  438. return(fTrue);
  439. }
  440. if(!fFillListBoxFromSzList (hdlg, IDC_LIST1, szList))
  441. {
  442. EvalAssert(fFreeListBoxEntries (hdlg, IDC_LIST1));
  443. Assert(fFalse);
  444. return(fTrue);
  445. }
  446. // Find the List Items Out and initialise the second list box
  447. if ((szList = SzFindSymbolValueInSymTab("ListItemsOut")) == (SZ)NULL)
  448. {
  449. Assert(fFalse);
  450. return(fTrue);
  451. }
  452. if(!fFillListBoxFromSzList (hdlg, IDC_LIST2, szList))
  453. {
  454. EvalAssert(fFreeListBoxEntries (hdlg, IDC_LIST1));
  455. EvalAssert(fFreeListBoxEntries (hdlg, IDC_LIST2));
  456. Assert(fFalse);
  457. return(fTrue);
  458. }
  459. EnableWindow(GetDlgItem(hdlg,IDC_A), fFalse);
  460. EnableWindow(GetDlgItem(hdlg,IDC_R), fFalse);
  461. if ((INT)SendDlgItemMessage(hdlg, IDC_LIST1, LB_GETCOUNT, 0, 0L) <= 0) {
  462. EnableWindow(GetDlgItem(hdlg,IDC_S),fFalse);
  463. }
  464. else {
  465. EnableWindow(GetDlgItem(hdlg,IDC_S),fTrue);
  466. }
  467. EvalAssert (fUpdateStatus ( hdlg, IDC_LIST1 ));
  468. EvalAssert (fUpdateStatus ( hdlg, IDC_LIST2 ));
  469. EvalAssert (fUpdateStatus ( hdlg, IDC_MAX1 ));
  470. //
  471. // Return
  472. //
  473. return(fTrue);
  474. case STF_REINITDIALOG:
  475. return(fTrue);
  476. // case STF_DLG_ACTIVATE:
  477. // case WM_MOUSEACTIVATE:
  478. // if (FActiveStackTop())
  479. // break;
  480. // EvalAssert(FInactivateHelp());
  481. // SetWindowPos(hdlg, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
  482. // /* fall through */
  483. // case STF_UILIB_ACTIVATE:
  484. // EvalAssert(FActivateStackTop());
  485. // return(fTrue);
  486. case WM_CLOSE:
  487. PostMessage(
  488. hdlg,
  489. WM_COMMAND,
  490. MAKELONG(IDC_X, BN_CLICKED),
  491. 0L
  492. );
  493. return(fTrue);
  494. case WM_COMMAND:
  495. switch(idc = LOWORD(wParam))
  496. {
  497. case IDC_LIST1:
  498. case IDC_LIST2:
  499. nCount = (INT)SendDlgItemMessage(hdlg, idc, LB_GETSELCOUNT, 0, 0L);
  500. EnableWindow(GetDlgItem(hdlg, (idc == IDC_LIST1) ? IDC_A : IDC_R),
  501. nCount ? fTrue : fFalse
  502. );
  503. switch (HIWORD(wParam))
  504. {
  505. case LBN_SELCHANGE:
  506. i = (INT)SendDlgItemMessage(hdlg, idc, LB_GETCURSEL, 0, 0L);
  507. if (i >= 0) {
  508. EvalAssert(fUpdateStatus( hdlg, idc ));
  509. }
  510. break;
  511. default:
  512. return fFalse;
  513. }
  514. break;
  515. case IDC_A:
  516. case IDC_R:
  517. {
  518. #define MAXSEL 100 // should be big enough
  519. INT sel[MAXSEL];
  520. if (idc == IDC_A)
  521. {
  522. idcSrc = IDC_LIST1;
  523. idcDst = IDC_LIST2;
  524. }
  525. else
  526. {
  527. idcSrc = IDC_LIST2;
  528. idcDst = IDC_LIST1;
  529. }
  530. nCount = (INT)SendDlgItemMessage(hdlg,
  531. idcSrc,
  532. LB_GETSELITEMS,
  533. MAXSEL,
  534. (LPARAM)sel);
  535. if (nCount <= 0)
  536. break;
  537. // dup everything over to the other list
  538. SendDlgItemMessage(hdlg, idcSrc, WM_SETREDRAW, fFalse, 0L);
  539. SendDlgItemMessage(hdlg, idcDst, WM_SETREDRAW, fFalse, 0L);
  540. for (i = 0; i < nCount; i++)
  541. {
  542. SendDlgItemMessage(hdlg, idcSrc, LB_GETTEXT, sel[i],
  543. (LPARAM)&lItem);
  544. SendDlgItemMessage(hdlg, idcDst, LB_ADDSTRING, 0,
  545. (LPARAM)lItem);
  546. }
  547. SendDlgItemMessage(hdlg, idcDst, WM_SETREDRAW, fTrue, 0L);
  548. InvalidateRect(GetDlgItem(hdlg, idcDst), NULL, fTrue);
  549. // and delete the source stuff (backwards to get order right)
  550. for (i = nCount - 1; i >= 0; i--)
  551. SendDlgItemMessage(hdlg, idcSrc, LB_DELETESTRING,
  552. sel[i], 0L);
  553. SendDlgItemMessage(hdlg, idcSrc, WM_SETREDRAW, fTrue, 0L);
  554. InvalidateRect(GetDlgItem(hdlg, idcSrc), NULL, fTrue);
  555. if (idc == IDC_A)
  556. {
  557. if ((INT)SendDlgItemMessage(hdlg, IDC_LIST1,
  558. LB_GETCOUNT, 0, 0L) <= 0)
  559. {
  560. EnableWindow(GetDlgItem(hdlg,IDC_S),fFalse);
  561. }
  562. else
  563. EnableWindow(GetDlgItem(hdlg,IDC_S),fTrue);
  564. }
  565. else
  566. EnableWindow(GetDlgItem(hdlg,IDC_S),fTrue);
  567. if ((INT)SendDlgItemMessage(hdlg, IDC_LIST2,
  568. LB_GETCOUNT, 0, 0L) <= 0)
  569. {
  570. SetFocus(GetDlgItem(hdlg, IDC_S));
  571. SendMessage(hdlg, DM_SETDEFID, IDC_S, 0L);
  572. }
  573. else
  574. {
  575. SetFocus(GetDlgItem(hdlg, IDC_C));
  576. SendMessage(hdlg, DM_SETDEFID, IDC_C, 0L);
  577. }
  578. EnableWindow(GetDlgItem(hdlg,idc),fFalse);
  579. EvalAssert (fUpdateStatus ( hdlg, IDC_LIST1 ));
  580. EvalAssert (fUpdateStatus ( hdlg, IDC_LIST2));
  581. EvalAssert (fUpdateStatus ( hdlg, IDC_MAX1));
  582. return fFalse;
  583. }
  584. case IDC_S:
  585. nCount = (INT)SendDlgItemMessage(hdlg, IDC_LIST1, LB_GETCOUNT, 0, 0L);
  586. SendDlgItemMessage(hdlg, IDC_LIST2, WM_SETREDRAW, fFalse, 0L);
  587. for (i = 0; i < nCount; i++)
  588. {
  589. SendDlgItemMessage(hdlg, IDC_LIST1, LB_GETTEXT, i,
  590. (LPARAM)&lItem);
  591. SendDlgItemMessage(hdlg, IDC_LIST2, LB_ADDSTRING, 0,
  592. (LPARAM)lItem);
  593. }
  594. SendDlgItemMessage(hdlg, IDC_LIST1, LB_RESETCONTENT, 0, 0L);
  595. SendDlgItemMessage(hdlg, IDC_LIST2, WM_SETREDRAW, fTrue, 0L);
  596. InvalidateRect(GetDlgItem(hdlg, IDC_LIST2), NULL, fFalse);
  597. EnableWindow(GetDlgItem(hdlg,IDC_A),fFalse);
  598. EnableWindow(GetDlgItem(hdlg,IDC_S),fFalse);
  599. SetFocus(GetDlgItem(hdlg, IDC_C));
  600. SendMessage(hdlg, DM_SETDEFID, IDC_C, 0L);
  601. EvalAssert (fUpdateStatus ( hdlg, IDC_LIST1 ));
  602. EvalAssert (fUpdateStatus ( hdlg, IDC_LIST2 ));
  603. EvalAssert (fUpdateStatus ( hdlg, IDC_MAX1 ));
  604. return fFalse;
  605. case IDCANCEL:
  606. if (LOWORD(wParam) == IDCANCEL) {
  607. if (!GetDlgItem(hdlg, IDC_B) || HIWORD(GetKeyState(VK_CONTROL)) || HIWORD(GetKeyState(VK_SHIFT)) || HIWORD(GetKeyState(VK_MENU)))
  608. {
  609. break;
  610. }
  611. wParam = IDC_B;
  612. }
  613. case IDC_O:
  614. case IDC_C:
  615. case IDC_M:
  616. case IDC_B:
  617. case IDC_X:
  618. // Indicate the Button selected.
  619. _itoa((INT)wParam, rgchNum, 10);
  620. while (!FAddSymbolValueToSymTab("ButtonPressed", rgchNum))
  621. if (!FHandleOOM(hdlg))
  622. {
  623. DestroyWindow(GetParent(hdlg));
  624. return(fTrue);
  625. }
  626. // Fetch the list from first list and put it into ListItemsIn
  627. EvalAssert((szList = szGetSzListFromListBox(hdlg, IDC_LIST1)) != (SZ) NULL) ;
  628. while (!FAddSymbolValueToSymTab("ListItemsIn", szList))
  629. if (!FHandleOOM(hdlg))
  630. {
  631. DestroyWindow(GetParent(hdlg));
  632. return(fTrue);
  633. }
  634. // Fetch the list from second list and put it into ListItemsIn
  635. EvalAssert((szList = szGetSzListFromListBox(hdlg, IDC_LIST2)) != (SZ) NULL) ;
  636. while (!FAddSymbolValueToSymTab("ListItemsOut", szList))
  637. if (!FHandleOOM(hdlg))
  638. {
  639. DestroyWindow(GetParent(hdlg));
  640. return(fTrue);
  641. }
  642. PostMessage(GetParent(hdlg), (WORD)STF_UI_EVENT, 0, 0L);
  643. break;
  644. }
  645. break;
  646. case WM_COMPAREITEM:
  647. #define lpci ((LPCOMPAREITEMSTRUCT)lParam)
  648. return(CrcStringCompareI((SZ) *((RGSZ)lpci->itemData1),
  649. (SZ) *((RGSZ)lpci->itemData2)
  650. )
  651. );
  652. case WM_CHARTOITEM:
  653. {
  654. HWND hLB;
  655. INT i, j, nCount;
  656. LONG_PTR lItem;
  657. CHP chpBuf1[2], chpBuf2[2]; //used because we only have str cmp
  658. chpBuf1[1] = chpBuf2[1] = 0;
  659. chpBuf1[0] = (CHAR)LOWORD(wParam);
  660. // See if we need to process this character at all
  661. if (CrcStringCompareI(chpBuf1, " ") == crcSecondHigher)
  662. return -1; //tell windows to do its default key processing
  663. // Extract the list box handle and the index of the current
  664. // selection item
  665. hLB = (HWND)lParam;
  666. i = HIWORD(wParam);
  667. // Find the number of items in the list
  668. nCount = (INT)SendMessage(hLB, LB_GETCOUNT, 0, 0L);
  669. // From the next item downwards (circularly) look at all the
  670. // items to see if the char is the same as the first char in the
  671. // list box display item.
  672. for (j = 1; j < nCount; j++)
  673. {
  674. // get the data here
  675. SendMessage(hLB, LB_GETTEXT, (i + j) % nCount, (LPARAM)&lItem);
  676. // make a dummy string
  677. chpBuf2[0] = (*((RGSZ) lItem))[0];
  678. // do a case insensitive cmp of key and string
  679. if (CrcStringCompareI(chpBuf1, chpBuf2) == crcEqual)
  680. break;
  681. }
  682. return ((j == nCount) ? -2 : (i +j) % nCount);
  683. break;
  684. }
  685. case WM_DRAWITEM:
  686. #define lpDrawItem ((LPDRAWITEMSTRUCT)lParam)
  687. if (lpDrawItem->itemState & ODS_SELECTED) {
  688. SetTextColor(lpDrawItem->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
  689. SetBkColor(lpDrawItem->hDC, GetSysColor(COLOR_HIGHLIGHT));
  690. }
  691. else{
  692. SetTextColor(lpDrawItem->hDC, GetSysColor(COLOR_WINDOWTEXT));
  693. SetBkColor(lpDrawItem->hDC, GetSysColor(COLOR_WINDOW));
  694. }
  695. if (lpDrawItem->itemID != (UINT)-1){
  696. if (pszItem = rgszItem = (RGSZ) lpDrawItem->itemData ) {
  697. ExtTextOut(lpDrawItem->hDC,
  698. lpDrawItem->rcItem.left,
  699. lpDrawItem->rcItem.top,
  700. ETO_OPAQUE, &lpDrawItem->rcItem,
  701. (SZ)(*pszItem), lstrlen((SZ)(*pszItem)), NULL);
  702. }
  703. if (lpDrawItem->itemState & ODS_FOCUS) {
  704. DrawFocusRect(lpDrawItem->hDC, &lpDrawItem->rcItem);
  705. }
  706. }
  707. else {
  708. RECT rc;
  709. if ( (lpDrawItem->itemAction & ODA_FOCUS) &&
  710. (SendMessage( GetDlgItem( hdlg, (int)wParam ), LB_GETITEMRECT, (WPARAM)0, (LPARAM)&rc ) != LB_ERR)
  711. ) {
  712. DrawFocusRect(lpDrawItem->hDC, &rc);
  713. }
  714. }
  715. return( fTrue );
  716. case STF_DESTROY_DLG:
  717. EvalAssert(fFreeListBoxEntries (hdlg, IDC_LIST1));
  718. EvalAssert(fFreeListBoxEntries (hdlg, IDC_LIST2));
  719. PostMessage(GetParent(hdlg), (WORD)STF_DUAL_DLG_DESTROYED, 0, 0L);
  720. DestroyWindow(hdlg);
  721. return(fTrue);
  722. }
  723. return(fFalse);
  724. }
  725. BOOL
  726. fUpdateStatus(
  727. HDLG hdlg,
  728. WORD idc
  729. )
  730. {
  731. #define MAXSEL 100 // should be big enough
  732. INT sel[MAXSEL];
  733. INT nCount, i;
  734. INT nSize;
  735. LONG_PTR lItem;
  736. //
  737. // Find out what we need to update
  738. //
  739. switch ( idc ) {
  740. case IDC_LIST1:
  741. case IDC_LIST2:
  742. //
  743. // Find out the selected items in the list box and the total size
  744. // associated with them.
  745. //
  746. nCount = (INT)SendDlgItemMessage(
  747. hdlg,
  748. idc,
  749. LB_GETSELITEMS,
  750. MAXSEL,
  751. (LPARAM)sel
  752. );
  753. nSize = 0;
  754. for (i = 0; i < nCount; i++) {
  755. SendDlgItemMessage(hdlg, idc, LB_GETTEXT, sel[i], (LPARAM)&lItem);
  756. nSize = nSize + nSizeOfItem(lItem);
  757. }
  758. //
  759. // Update the number of files and the size associated
  760. //
  761. MySetDlgItemInt ( hdlg, IDC_STATUS1 + idc - IDC_LIST1, nCount );
  762. MySetDlgItemInt ( hdlg, IDC_TOTAL1 + idc - IDC_LIST1, nSize );
  763. break;
  764. case IDC_MAX1:
  765. //
  766. // find all the items associated with the list box and the size assoc
  767. //
  768. nCount = (INT)SendDlgItemMessage(hdlg, IDC_LIST2, LB_GETCOUNT, 0, 0L);
  769. nSize = 0;
  770. for (i = 0; i < nCount; i++) {
  771. SendDlgItemMessage(hdlg, IDC_LIST2, LB_GETTEXT, i, (LPARAM)&lItem);
  772. nSize = nSize + nSizeOfItem(lItem);
  773. }
  774. MySetDlgItemInt ( hdlg, idc, nSize );
  775. break;
  776. default:
  777. return ( fFalse );
  778. }
  779. return ( fTrue );
  780. }