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.

7019 lines
161 KiB

  1. /*++
  2. Copyright (c) 1990-1995 Microsoft Corporation
  3. Module Name:
  4. dlgctrl.c
  5. Abstract:
  6. This module contains most of dialog control update procedures
  7. Author:
  8. 24-Aug-1995 Thu 19:42:09 created -by- Daniel Chou (danielc)
  9. [Environment:]
  10. NT Windows - Common Printer Driver UI DLL.
  11. [Notes:]
  12. Revision History:
  13. --*/
  14. #include "precomp.h"
  15. #pragma hdrstop
  16. #define DBG_CPSUIFILENAME DbgDlgCtrl
  17. #define DBG_CTB 0x00000001
  18. #define DBG_CUDA 0x00000002
  19. #define DBG_INITTBSB 0x00000004
  20. #define DBG_UCBC 0x00000008
  21. #define DBG_DOCB 0x00000010
  22. #define DBG_DOPB 0x00000020
  23. #define DBG_CS 0x00000040
  24. #define DBG_INITLBCB 0x00000080
  25. #define DBGITEM_CB 0x00000100
  26. #define DBGITEM_PUSH 0x00000200
  27. #define DBGITEM_CS 0x00000400
  28. #define DBG_UDARROW 0x00000800
  29. #define DBG_HELP 0x00001000
  30. #define DBG_FNLC 0x00002000
  31. #define DBG_CLBCB 0x00004000
  32. #define DBG_IFW 0x00008000
  33. #define DBG_SCID 0x00010000
  34. #define DBG_VALIDATE_UD 0x00020000
  35. #define DBG_CB_CY 0x00040000
  36. #define DBG_FOCUS 0x00080000
  37. #define DBG_CBWNDPROC 0x00100000
  38. #define DBG_TMP 0x80000000
  39. DEFINE_DBGVAR(0);
  40. #define SPSF_USE_BUTTON_CY 0x0001
  41. #define SPSF_ALIGN_EXTPUSH 0x0002
  42. #define PUSH_CY_EXTRA 12
  43. #define PUSH_CX_EXTRA_W 2
  44. #define ICON16_CX_SPACE 6
  45. #define LBCBID_DISABLED 0x80000000L
  46. #define LBCBID_FILL 0x40000000L
  47. #define LBCBID_NONE 0x20000000L
  48. #define INTDMPUB_CHANGED 0x0001
  49. #define INTDMPUB_REINIT 0x0002
  50. //
  51. // Following EDF_xxx is used for Up-Down-Arrow control
  52. //
  53. #define EDF_MINUS_OK 0x80
  54. #define EDF_IN_TVPAGE 0x40
  55. #define EDF_NUMBERS 0x20
  56. #define EDF_BACKSPACE 0x10
  57. #define EDF_BEGIDXMASK 0x07
  58. #define EDF_STATIC_MASK (EDF_MINUS_OK | EDF_IN_TVPAGE)
  59. #define MAX_UDARROW_TEXT_LEN 7
  60. extern HINSTANCE hInstDLL;
  61. extern BYTE cTVOTCtrls[];
  62. extern OPTTYPE OptTypeHdrPush;
  63. extern EXTPUSH ExtPushAbout;
  64. extern BYTE cTVOTCtrls[];
  65. typedef struct _ABOUTINFO {
  66. PTVWND pTVWnd;
  67. HICON hIcon;
  68. LPARAM Pos;
  69. } ABOUTINFO, *PABOUTINFO;
  70. typedef struct _ABOUTPOS {
  71. _CPSUICALLBACK pfnCallBack;
  72. PCPSUICBPARAM pCBParam;
  73. HWND hFocus;
  74. LPARAM Pos;
  75. } ABOUTPOS, *PABOUTPOS;
  76. extern
  77. LONG
  78. APIENTRY
  79. HTUI_ColorAdjustmentA(
  80. LPSTR pDeviceName,
  81. HANDLE hDIB,
  82. LPSTR pDIBTitle,
  83. PCOLORADJUSTMENT pca,
  84. BOOL ShowMonoOnly,
  85. BOOL UpdatePermission
  86. );
  87. extern
  88. LONG
  89. APIENTRY
  90. HTUI_ColorAdjustmentW(
  91. LPWSTR pDeviceName,
  92. HANDLE hDIB,
  93. LPWSTR pDIBTitle,
  94. PCOLORADJUSTMENT pca,
  95. BOOL ShowMonoOnly,
  96. BOOL UpdatePermission
  97. );
  98. extern
  99. LONG
  100. APIENTRY
  101. HTUI_DeviceColorAdjustmentA(
  102. LPSTR pDeviceName,
  103. PDEVHTADJDATA pDevHTAdjData
  104. );
  105. extern
  106. LONG
  107. APIENTRY
  108. HTUI_DeviceColorAdjustmentW(
  109. LPWSTR pDeviceName,
  110. PDEVHTADJDATA pDevHTAdjData
  111. );
  112. #define IS_TVDLG (InitFlags & INITCF_TVDLG)
  113. #define SHOWCTRL(hCtrl, Enable, swMode) \
  114. { \
  115. EnableWindow(hCtrl, (Enable) && (InitFlags & INITCF_ENABLE)); \
  116. ShowWindow(hCtrl, (swMode)); \
  117. }
  118. #define SETCTRLTEXT(hCtrl, pTitle) \
  119. { \
  120. GSBUF_RESET; GSBUF_GETSTR(pTitle); \
  121. SetWindowText(hCtrl, GSBUF_BUF); \
  122. }
  123. #define GETHCTRL(i) \
  124. if (i) { hCtrl=GetDlgItem(hDlg,(i)); } else { hCtrl=NULL; }
  125. #define HCTRL_TEXT(h,p) if (h) { SETCTRLTEXT(h,(p)); }
  126. #define HCTRL_STATE(h,e,m) if (h) { SHOWCTRL((h),(e),(m)); }
  127. #define HCTRL_TEXTSTATE(hCtrl, pTitle, Enable, swMode) \
  128. { \
  129. if (hCtrl) { \
  130. \
  131. SETCTRLTEXT(hCtrl, (pTitle)); \
  132. SHOWCTRL(hCtrl, (Enable), (swMode)); \
  133. } \
  134. }
  135. #define ID_TEXTSTATE(i,p,e,m) GETHCTRL(i); HCTRL_TEXTSTATE(hCtrl,p,e,m)
  136. #define SET_EXTICON(IS_ECB) \
  137. { \
  138. BOOL swIcon = swMode; \
  139. \
  140. if ((!(hCtrl2 = GetDlgItem(hDlg, ExtIconID))) || \
  141. ((!IconResID) && (!(IconMode & MIM_MASK)))) { \
  142. \
  143. swIcon = SW_HIDE; \
  144. Enable = FALSE; \
  145. } \
  146. \
  147. HCTRL_STATE(hCtrl2, Enable, swIcon); \
  148. HCTRL_SETCTRLDATA(hCtrl2, CTRLS_ECBICON, 0xFF); \
  149. \
  150. if (swIcon == SW_SHOW) { \
  151. \
  152. SetIcon(_OI_HINST(pItem), \
  153. hCtrl2, \
  154. IconResID, \
  155. MK_INTICONID(0, IconMode), \
  156. (IS_TVDLG) ? pTVWnd->cxcyECBIcon : 32); \
  157. } \
  158. \
  159. if (IS_ECB) { \
  160. \
  161. if (hCtrl2) { \
  162. \
  163. DWORD dw = (DWORD)GetWindowLongPtr(hCtrl2, GWL_STYLE); \
  164. \
  165. if ((swIcon == SW_SHOW) && \
  166. (Enable) && \
  167. (InitFlags & INITCF_ENABLE)) { \
  168. \
  169. dw |= SS_NOTIFY; \
  170. \
  171. } else { \
  172. \
  173. dw &= ~SS_NOTIFY; \
  174. } \
  175. \
  176. SetWindowLongPtr(hCtrl2, GWL_STYLE, dw); \
  177. } \
  178. } \
  179. \
  180. return((BOOL)(swMode == SW_SHOW)); \
  181. }
  182. #if 0
  183. static const CHAR szShellDLL[] = "shell32";
  184. static const CHAR szShellAbout[] = "ShellAboutW";
  185. #endif
  186. static const CHAR szHTUIClrAdj[] = "HTUI_ColorAdjustmentW";
  187. static const CHAR szHTUIDevClrAdj[] = "HTUI_DeviceColorAdjustmentW";
  188. BOOL
  189. CALLBACK
  190. SetUniqChildIDProc(
  191. HWND hWnd,
  192. LPARAM lParam
  193. )
  194. {
  195. DWORD dw;
  196. UINT DlgID;
  197. if (GetWindowLongPtr(hWnd, GWLP_ID)) {
  198. CPSUIDBG(DBG_SCID, ("The hWnd=%08lx has GWLP_ID=%ld, CtrlID=%ld",
  199. hWnd, GetWindowLongPtr(hWnd, GWLP_ID), GetDlgCtrlID(hWnd)));
  200. } else {
  201. HWND hCtrl;
  202. DLGIDINFO DlgIDInfo = *(PDLGIDINFO)lParam;
  203. while (hCtrl = GetDlgItem(DlgIDInfo.hDlg, DlgIDInfo.CurID)) {
  204. CPSUIDBG(DBG_SCID, ("The ID=%ld is used by hCtrl=%08lx",
  205. DlgIDInfo.CurID, hCtrl));
  206. --DlgIDInfo.CurID;
  207. }
  208. SetWindowLongPtr(hWnd, GWLP_ID, (LONG)DlgIDInfo.CurID);
  209. CPSUIDBG(DBG_SCID, ("The hWnd=%08lx, GWLP_ID set to %ld",
  210. hWnd, DlgIDInfo.CurID));
  211. }
  212. return(TRUE);
  213. }
  214. VOID
  215. SetUniqChildID(
  216. HWND hDlg
  217. )
  218. /*++
  219. Routine Description:
  220. Arguments:
  221. Return Value:
  222. Author:
  223. 22-Nov-1995 Wed 15:40:38 created -by- Daniel Chou (danielc)
  224. Revision History:
  225. --*/
  226. {
  227. DLGIDINFO DlgIDInfo;
  228. DlgIDInfo.hDlg = hDlg;
  229. DlgIDInfo.CurID = 0xFFFF;
  230. EnumChildWindows(hDlg, SetUniqChildIDProc, (LPARAM)&DlgIDInfo);
  231. }
  232. BOOL
  233. hCtrlrcWnd(
  234. HWND hDlg,
  235. HWND hCtrl,
  236. RECT *prc
  237. )
  238. /*++
  239. Routine Description:
  240. Arguments:
  241. Return Value:
  242. Author:
  243. 17-Sep-1995 Sun 07:34:41 created -by- Daniel Chou (danielc)
  244. Revision History:
  245. --*/
  246. {
  247. if (hCtrl) {
  248. GetWindowRect(hCtrl, prc);
  249. MapWindowPoints(NULL, hDlg, (LPPOINT)prc, 2);
  250. return(TRUE);
  251. } else {
  252. return(FALSE);
  253. }
  254. }
  255. HWND
  256. CtrlIDrcWnd(
  257. HWND hDlg,
  258. UINT CtrlID,
  259. RECT *prc
  260. )
  261. /*++
  262. Routine Description:
  263. Arguments:
  264. Return Value:
  265. Author:
  266. 17-Sep-1995 Sun 07:34:41 created -by- Daniel Chou (danielc)
  267. Revision History:
  268. --*/
  269. {
  270. HWND hCtrl;
  271. if ((CtrlID) && (hCtrl = GetDlgItem(hDlg, CtrlID))) {
  272. GetWindowRect(hCtrl, prc);
  273. MapWindowPoints(NULL, hDlg, (LPPOINT)prc, 2);
  274. return(hCtrl);
  275. } else {
  276. return(NULL);
  277. }
  278. }
  279. BOOL
  280. ChkhWndEdit0KEYDOWN(
  281. HWND hWnd,
  282. WPARAM VKey
  283. )
  284. /*++
  285. Routine Description:
  286. Arguments:
  287. Return Value:
  288. Author:
  289. 13-Aug-1998 Thu 11:13:41 created -by- Daniel Chou (danielc)
  290. Revision History:
  291. --*/
  292. {
  293. PTVWND pTVWnd;
  294. switch (VKey) {
  295. case VK_LEFT:
  296. case VK_BACK:
  297. case VK_RIGHT:
  298. if (pTVWnd = (PTVWND)GetProp(hWnd, CPSUIPROP_PTVWND)) {
  299. switch (VKey) {
  300. case VK_LEFT:
  301. case VK_BACK:
  302. if ((pTVWnd->hWndTV) &&
  303. (GetDlgCtrlID(pTVWnd->hWndTV) == IDD_TV_WND)) {
  304. SetFocus(pTVWnd->hWndTV);
  305. return(TRUE);
  306. }
  307. break;
  308. case VK_RIGHT:
  309. if (hWnd = pTVWnd->hWndEdit[1]) {
  310. SetFocus(hWnd);
  311. }
  312. return(TRUE);
  313. }
  314. }
  315. break;
  316. }
  317. return(FALSE);
  318. }
  319. LRESULT
  320. CALLBACK
  321. MyCBWndProc(
  322. HWND hWnd,
  323. UINT Msg,
  324. WPARAM wParam,
  325. LPARAM lParam
  326. )
  327. /*++
  328. Routine Description:
  329. This is the subclass WNDPROC for the numberical edit control, it check
  330. valid input for the number entered.
  331. Arguments:
  332. WNDPROC standard
  333. Return Value:
  334. INT (The original WNDPROC returned), if the entered keys are not valid
  335. then it return right away without processing
  336. Author:
  337. 20-Mar-1996 Wed 15:36:48 created -by- Daniel Chou (danielc)
  338. Revision History:
  339. --*/
  340. {
  341. HWND hDlg;
  342. PTVWND pTVWnd;
  343. HWND hWndTV;
  344. LONG_PTR SelIdx;
  345. WNDPROC OldWndProc;
  346. if (OldWndProc = (WNDPROC)GetProp(hWnd, CPSUIPROP_WNDPROC)) {
  347. switch (Msg) {
  348. case WM_KEYDOWN:
  349. CPSUIDBG(DBG_CBWNDPROC,
  350. ("MyCBWndProc: WM_KEYDOWN, VKey=%ld", wParam));
  351. if (SendMessage(hWnd, CB_GETDROPPEDSTATE, 0, 0)) {
  352. //
  353. // When user hit escape during the drop down box open AND
  354. // the selection did changed, then we post message to change
  355. // the selection back to original and post a selection
  356. // change message (POST since this will be done after CLOSEUP)
  357. //
  358. if ((wParam == VK_ESCAPE) &&
  359. (SelIdx = (LONG_PTR)GetProp(hWnd, CPSUIPROP_CBPRESEL)) &&
  360. ((SelIdx - 1) != SendMessage(hWnd, CB_GETCURSEL, 0, 0))) {
  361. CPSUIDBG(DBG_CBWNDPROC,
  362. ("MyCBWndProc: ESCAPE: Restore SEL from %ld to %ld",
  363. (DWORD)SendMessage(hWnd, CB_GETCURSEL, 0, 0),
  364. SelIdx - 1));
  365. PostMessage(hWnd, CB_SETCURSEL, (WPARAM)(SelIdx - 1), 0L);
  366. PostMessage(GetParent(hWnd),
  367. WM_COMMAND,
  368. MAKEWPARAM(GetDlgCtrlID(hWnd), CBN_SELCHANGE),
  369. (LPARAM)hWnd);
  370. break;
  371. }
  372. } else if (ChkhWndEdit0KEYDOWN(hWnd, wParam)) {
  373. return(0);
  374. }
  375. break;
  376. case WM_DESTROY:
  377. CPSUIDBG(DBG_CBWNDPROC, ("MyCBWndProc: WM_DESTROY"));
  378. SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LPARAM)OldWndProc);
  379. RemoveProp(hWnd, CPSUIPROP_WNDPROC);
  380. RemoveProp(hWnd, CPSUIPROP_PTVWND);
  381. RemoveProp(hWnd, CPSUIPROP_CBPRESEL);
  382. break;
  383. default:
  384. break;
  385. }
  386. return(CallWindowProc(OldWndProc, hWnd, Msg, wParam, lParam));
  387. } else {
  388. CPSUIERR(("MyCBWndProc: GetProc(%08lx) FAILED", hWnd));
  389. return(0);
  390. }
  391. }
  392. DWORD
  393. ReCreateLBCB(
  394. HWND hDlg,
  395. UINT CtrlID,
  396. BOOL IsLB
  397. )
  398. /*++
  399. Routine Description:
  400. This functon create a new listbox/combobox which has same control ID and
  401. size of the original one except with the owner draw item
  402. Arguments:
  403. hDlg - Handle to the dialog
  404. CtrlID - The original control ID for the LB/CB
  405. IsLB - True if this is a List box
  406. Return Value:
  407. BOOL
  408. Author:
  409. 12-Sep-1995 Tue 00:23:17 created -by- Daniel Chou (danielc)
  410. Revision History:
  411. --*/
  412. {
  413. HWND hLBCB;
  414. WORD cxRet = 0;
  415. WORD cyRet = 0;
  416. RECT rc;
  417. if (hLBCB = CtrlIDrcWnd(hDlg, CtrlID, &rc)) {
  418. HWND hNewLBCB;
  419. DWORD dw;
  420. RECT rcDrop;
  421. WORD cxSize;
  422. WORD cySize;
  423. BOOL SetExtUI = FALSE;
  424. CPSUIDBG(DBG_CLBCB, ("Dropped=(%ld, %ld)-(%ld, %ld), %ld x %ld",
  425. rc.left, rc.top, rc.right, rc.bottom,
  426. rc.right - rc.left, rc.bottom - rc.top));
  427. dw = (DWORD)(GetWindowLongPtr(hLBCB, GWL_STYLE) |
  428. (WS_VSCROLL | WS_GROUP | WS_TABSTOP | WS_BORDER));
  429. if ((!IsLB) && (dw & (CBS_DROPDOWNLIST | CBS_DROPDOWN))) {
  430. SetExtUI = TRUE;
  431. CPSUIDBG(DBG_TMP, ("Original CB Edit CY=%ld",
  432. (LONG)SendMessage(hLBCB,
  433. CB_GETITEMHEIGHT,
  434. (WPARAM)-1,
  435. 0)));
  436. SendMessage(hLBCB, CB_SETEXTENDEDUI, (WPARAM)TRUE, 0L);
  437. SendMessage(hLBCB, CB_GETDROPPEDCONTROLRECT, 0, (LPARAM)&rcDrop);
  438. CPSUIDBG(DBG_CLBCB, ("Dropped=(%ld, %ld)-(%ld, %ld), %ld x %ld",
  439. rcDrop.left, rcDrop.top, rcDrop.right, rcDrop.bottom,
  440. rcDrop.right - rcDrop.left, rcDrop.bottom - rcDrop.top));
  441. rc.bottom += (rcDrop.bottom - rcDrop.top) * 2;
  442. }
  443. cxSize = (WORD)(rc.right - rc.left);
  444. cySize = (WORD)(rc.bottom - rc.top);
  445. CPSUIDBG(DBG_CLBCB, ("%ws: cxSize=%ld, cySize=%ld",
  446. (IsLB) ? L"ListBox" : L"ComboBox", cxSize, cySize));
  447. if (IsLB) {
  448. dw &= ~LBS_OWNERDRAWVARIABLE;
  449. dw |= (LBS_OWNERDRAWFIXED |
  450. LBS_HASSTRINGS |
  451. LBS_SORT |
  452. LBS_NOINTEGRALHEIGHT);
  453. } else {
  454. dw &= ~(CBS_OWNERDRAWVARIABLE | CBS_NOINTEGRALHEIGHT);
  455. dw |= (CBS_OWNERDRAWFIXED | CBS_HASSTRINGS | CBS_SORT);
  456. }
  457. CPSUIDBG(DBG_CLBCB, ("dwStyle=%08lx", dw));
  458. if (hNewLBCB = CreateWindowEx(WS_EX_NOPARENTNOTIFY | WS_EX_CLIENTEDGE,
  459. (IsLB) ? L"listbox" : L"combobox",
  460. L"",
  461. dw | WS_CHILD | WS_TABSTOP | WS_GROUP,
  462. rc.left,
  463. rc.top,
  464. rc.right - rc.left,
  465. cySize,
  466. hDlg,
  467. (HMENU)UIntToPtr(CtrlID),
  468. hInstDLL,
  469. 0)) {
  470. SetWindowPos(hNewLBCB,
  471. hLBCB,
  472. 0, 0, 0, 0,
  473. SWP_NOMOVE | SWP_NOSIZE | SWP_NOREDRAW);
  474. SendMessage(hNewLBCB,
  475. WM_SETFONT,
  476. (WPARAM)SendMessage(hLBCB, WM_GETFONT, 0, 0),
  477. TRUE);
  478. if (SetExtUI) {
  479. SendMessage(hNewLBCB, CB_SETEXTENDEDUI, (WPARAM)TRUE, 0L);
  480. }
  481. DestroyWindow(hLBCB);
  482. if ((hLBCB = GetDlgItem(hDlg, CtrlID)) == hNewLBCB) {
  483. cxRet = (WORD)((GetSystemMetrics(SM_CXFIXEDFRAME) * 2) +
  484. (GetSystemMetrics(SM_CXEDGE ) * 2) +
  485. (GetSystemMetrics(SM_CXVSCROLL)));
  486. CPSUIDBG(DBG_CLBCB, ("SM_CXFIXEDFRAME=%ld, SM_CXEDGE=%ld, SM_CXVSCROLL=%ld",
  487. GetSystemMetrics(SM_CXFIXEDFRAME),
  488. GetSystemMetrics(SM_CXEDGE ),
  489. GetSystemMetrics(SM_CXVSCROLL)));
  490. if (!IsLB) {
  491. WNDPROC OldWndProc;
  492. OldWndProc = (WNDPROC)GetWindowLongPtr(hLBCB, GWLP_WNDPROC);
  493. if ((ULONG_PTR)OldWndProc != (ULONG_PTR)MyCBWndProc) {
  494. SetProp(hLBCB, CPSUIPROP_WNDPROC, (HANDLE)OldWndProc);
  495. SetProp(hLBCB,
  496. CPSUIPROP_PTVWND,
  497. (HANDLE)GET_PTVWND(hDlg));
  498. SetWindowLongPtr(hLBCB,
  499. GWLP_WNDPROC,
  500. (LPARAM)MyCBWndProc);
  501. }
  502. }
  503. cyRet = cySize;
  504. } else {
  505. CPSUIASSERT(0, "Newly Create LBCB's ID=%08lx is different",
  506. hLBCB == hNewLBCB, UIntToPtr(CtrlID));
  507. }
  508. } else {
  509. CPSUIERR(("CreateLBCB: CreateWindowEx() FAILED"));
  510. }
  511. } else {
  512. CPSUIERR(("CreateLBCB: GetDlgItem() failed"));
  513. }
  514. return((DWORD)MAKELONG(cxRet, cyRet));
  515. }
  516. HWND
  517. CreateTrackBar(
  518. HWND hDlg,
  519. UINT TrackBarID
  520. )
  521. /*++
  522. Routine Description:
  523. Arguments:
  524. Return Value:
  525. Author:
  526. 24-Aug-1995 Thu 19:43:08 created -by- Daniel Chou (danielc)
  527. Revision History:
  528. --*/
  529. {
  530. HWND hCtrl;
  531. HWND hTrackBar;
  532. RECT rc;
  533. //
  534. // Create TrackBar Control
  535. //
  536. if (hCtrl = CtrlIDrcWnd(hDlg, TrackBarID, &rc)) {
  537. CPSUIDBG(DBG_CTB,
  538. ("\nCreate TrackBar Control=%ld, rc=(%ld, %ld) - (%ld, %ld)",
  539. TrackBarID, rc.left, rc.top, rc.right, rc.bottom));
  540. if (hTrackBar = CreateWindowEx(0,
  541. TRACKBAR_CLASS,
  542. L"",
  543. WS_VISIBLE |
  544. WS_CHILD |
  545. WS_TABSTOP |
  546. WS_GROUP |
  547. TBS_AUTOTICKS,
  548. rc.left,
  549. rc.top,
  550. rc.right - rc.left,
  551. rc.bottom - rc.top,
  552. hDlg,
  553. (HMENU)UIntToPtr(TrackBarID),
  554. hInstDLL,
  555. 0)) {
  556. SetWindowPos(hTrackBar,
  557. hCtrl,
  558. 0, 0, 0, 0,
  559. SWP_NOMOVE | SWP_NOSIZE | SWP_NOREDRAW);
  560. DestroyWindow(hCtrl);
  561. SetWindowLongPtr(hTrackBar, GWLP_ID, (LONG)TrackBarID);
  562. hCtrl = GetDlgItem(hDlg, TrackBarID);
  563. CPSUIINT(("hDlg=%08lx, hTrackBar=%08lx, TrackBarID=%08lx",
  564. hDlg, hTrackBar, hCtrl));
  565. }
  566. #if 0
  567. HCTRL_SETCTRLDATA(hCtrl, CTRLS_NOINPUT, 0);
  568. ShowWindow(hCtrl, SW_HIDE);
  569. EnableWindow(hCtrl, FALSE);
  570. #endif
  571. return(hTrackBar);
  572. } else {
  573. return(NULL);
  574. }
  575. }
  576. BOOL
  577. ChkEditKEYDOWN(
  578. HWND hWnd,
  579. WPARAM VKey
  580. )
  581. /*++
  582. Routine Description:
  583. Arguments:
  584. Return Value:
  585. Author:
  586. 13-Aug-1998 Thu 10:56:21 created -by- Daniel Chou (danielc)
  587. Revision History:
  588. --*/
  589. {
  590. PTVWND pTVWnd;
  591. LONG SelBeg;
  592. LONG SelEnd;
  593. switch (VKey) {
  594. case VK_LEFT:
  595. case VK_BACK:
  596. case VK_RIGHT:
  597. SelEnd = (LONG)SendMessage(hWnd, EM_GETSEL, 0, 0);
  598. SelBeg = (LONG)LOWORD(SelEnd);
  599. SelEnd = (LONG)HIWORD(SelEnd);
  600. CPSUIDBG(DBG_CBWNDPROC,
  601. ("ChkEditKEYDOWN: WM_KEYDOWN, VKey=%ld, Sel=%ld-%ld, Len=%ld",
  602. VKey, SelBeg, SelEnd, GetWindowTextLength(hWnd)));
  603. if ((SelBeg == SelEnd) &&
  604. (pTVWnd = (PTVWND)GetProp(hWnd, CPSUIPROP_PTVWND))) {
  605. switch (VKey) {
  606. case VK_LEFT:
  607. case VK_BACK:
  608. //
  609. // If already at position 0, and a left key go back to
  610. // treeview
  611. //
  612. if ((!SelBeg) &&
  613. (pTVWnd->hWndTV) &&
  614. (GetDlgCtrlID(pTVWnd->hWndTV) == IDD_TV_WND)) {
  615. SetFocus(pTVWnd->hWndTV);
  616. return(TRUE);
  617. }
  618. break;
  619. case VK_RIGHT:
  620. //
  621. // If already at end position and there is a extended checkbox
  622. // or extended push then move a right key move to it
  623. //
  624. if ((pTVWnd->hWndEdit[1]) &&
  625. (SelEnd == (LONG)GetWindowTextLength(hWnd))) {
  626. SetFocus(pTVWnd->hWndEdit[1]);
  627. return(TRUE);
  628. }
  629. break;
  630. }
  631. }
  632. }
  633. return(FALSE);
  634. }
  635. LRESULT
  636. CALLBACK
  637. CPSUIUDArrowWndProc(
  638. HWND hWnd,
  639. UINT Msg,
  640. WPARAM wParam,
  641. LPARAM lParam
  642. )
  643. /*++
  644. Routine Description:
  645. This is the subclass WNDPROC for the numberical edit control, it check
  646. valid input for the number entered.
  647. Arguments:
  648. WNDPROC standard
  649. Return Value:
  650. INT (The original WNDPROC returned), if the entered keys are not valid
  651. then it return right away without processing
  652. Author:
  653. 20-Mar-1996 Wed 15:36:48 created -by- Daniel Chou (danielc)
  654. Revision History:
  655. --*/
  656. {
  657. WNDPROC OldWndProc;
  658. WCHAR wch;
  659. DWORD dw;
  660. LONG SelBegIdx;
  661. LONG SelEndIdx;
  662. WORD InitItemIdx;
  663. BYTE CtrlData;
  664. BYTE CtrlStyle;
  665. if (OldWndProc = (WNDPROC)GetProp(hWnd, CPSUIPROP_WNDPROC)) {
  666. CPSUIDBG(DBG_VALIDATE_UD,
  667. ("CPSUIUDArrowWndProc: hWnd=%08lx, OldWndProc=%08lx",
  668. hWnd, OldWndProc));
  669. switch (Msg) {
  670. case WM_KEYDOWN:
  671. if (ChkEditKEYDOWN(hWnd, (DWORD)wParam)) {
  672. return(0);
  673. }
  674. break;
  675. case WM_CHAR:
  676. wch = (WCHAR)wParam;
  677. dw = (DWORD)GetWindowLongPtr(hWnd, GWLP_USERDATA);
  678. GETCTRLDATA(dw, InitItemIdx, CtrlStyle, CtrlData);
  679. SendMessage(hWnd, EM_GETSEL, (WPARAM)&SelBegIdx, (LPARAM)&SelEndIdx);
  680. CPSUIDBG(DBG_VALIDATE_UD,
  681. ("WM_CHAR=0x%04lx, ItemIdx=%u, Style=0x%02lx, Data=0x%02lx (%ld, %ld)",
  682. wch, InitItemIdx, CtrlStyle, CtrlData,
  683. SelBegIdx, SelEndIdx));
  684. CtrlData &= EDF_STATIC_MASK;
  685. CtrlData |= (BYTE)(SelBegIdx & EDF_BEGIDXMASK);
  686. if (wch < L' ') {
  687. if (wch == 0x08) {
  688. CtrlData |= EDF_BACKSPACE;
  689. }
  690. } else if (((wch == L'-') && (CtrlData & EDF_MINUS_OK)) ||
  691. ((wch >= L'0') && (wch <= L'9'))) {
  692. WCHAR SelBuf[MAX_UDARROW_TEXT_LEN+1];
  693. WCHAR LastCh;
  694. LONG Len;
  695. Len = (LONG)GetWindowText(hWnd, SelBuf, ARRAYSIZE(SelBuf));
  696. LastCh = (SelEndIdx >= Len) ? L'\0' : SelBuf[SelEndIdx];
  697. if ((SelBegIdx == 0) && (LastCh == L'-')) {
  698. wch = 0;
  699. } else if (wch == L'-') {
  700. if (SelBegIdx) {
  701. wch = 0;
  702. }
  703. } else if (wch == L'0') {
  704. if (LastCh) {
  705. if (((SelBegIdx == 1) && (SelBuf[0] == L'-')) ||
  706. ((SelBegIdx == 0) && (LastCh != L'-'))) {
  707. wch = 0;
  708. }
  709. }
  710. }
  711. if ((wch >= L'0') && (wch <= L'9')) {
  712. CtrlData |= EDF_NUMBERS;
  713. }
  714. } else {
  715. wch = 0;
  716. }
  717. SETCTRLDATA(hWnd, CtrlStyle, CtrlData);
  718. if (!wch) {
  719. MessageBeep(MB_ICONHAND);
  720. return(0);
  721. }
  722. break;
  723. case WM_DESTROY:
  724. CPSUIDBG(DBG_VALIDATE_UD, ("UDArrow: WM_DESTROY"));
  725. SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LPARAM)OldWndProc);
  726. RemoveProp(hWnd, CPSUIPROP_WNDPROC);
  727. RemoveProp(hWnd, CPSUIPROP_PTVWND);
  728. break;
  729. default:
  730. break;
  731. }
  732. return(CallWindowProc(OldWndProc, hWnd, Msg, wParam, lParam));
  733. } else {
  734. CPSUIERR(("CPSUIUDArrowWndProc: GetProc(%08lx) FAILED", hWnd));
  735. return(0);
  736. }
  737. }
  738. HWND
  739. CreateUDArrow(
  740. HWND hDlg,
  741. UINT EditBoxID,
  742. UINT UDArrowID,
  743. LONG RangeL,
  744. LONG RangeH,
  745. LONG Pos
  746. )
  747. /*++
  748. Routine Description:
  749. Arguments:
  750. Return Value:
  751. Author:
  752. 24-Aug-1995 Thu 18:55:07 created -by- Daniel Chou (danielc)
  753. Revision History:
  754. --*/
  755. {
  756. HWND hUDArrow;
  757. HWND hCtrl;
  758. RECT rc;
  759. WNDPROC OldWndProc;
  760. if (hCtrl = CtrlIDrcWnd(hDlg, EditBoxID, &rc)) {
  761. if (Pos < RangeL) {
  762. Pos = RangeL;
  763. } else if (Pos > RangeH) {
  764. Pos = RangeH;
  765. }
  766. CPSUIDBG(DBG_CUDA, ("CreateUDArrow Window, rc=(%ld, %ld) - (%ld, %ld), Range=%ld-%ld (%ld)",
  767. rc.left, rc.top, rc.right, rc.bottom,
  768. RangeL, RangeH, Pos));
  769. if (hUDArrow = CreateUpDownControl(WS_BORDER |
  770. WS_CHILD |
  771. WS_TABSTOP |
  772. WS_GROUP |
  773. UDS_ARROWKEYS |
  774. UDS_NOTHOUSANDS |
  775. UDS_ALIGNRIGHT |
  776. UDS_SETBUDDYINT,
  777. rc.right,
  778. rc.top,
  779. rc.bottom - rc.top,
  780. rc.bottom - rc.top,
  781. hDlg,
  782. UDArrowID,
  783. hInstDLL,
  784. hCtrl,
  785. (INT)RangeH,
  786. (INT)RangeL,
  787. (INT)Pos)) {
  788. SetWindowLongPtr(hUDArrow,
  789. GWL_EXSTYLE,
  790. GetWindowLongPtr(hUDArrow, GWL_EXSTYLE) |
  791. WS_EX_NOPARENTNOTIFY | WS_EX_CONTEXTHELP);
  792. SetWindowPos(hUDArrow,
  793. hCtrl,
  794. 0, 0, 0, 0,
  795. SWP_NOMOVE | SWP_NOSIZE | SWP_NOREDRAW);
  796. SendMessage(hUDArrow, UDM_SETBASE, (WPARAM)10, 0L);
  797. OldWndProc = (WNDPROC)GetWindowLongPtr(hCtrl, GWLP_WNDPROC);
  798. if ((ULONG_PTR)OldWndProc != (ULONG_PTR)CPSUIUDArrowWndProc) {
  799. SetProp(hCtrl, CPSUIPROP_WNDPROC, (HANDLE)OldWndProc);
  800. SetProp(hCtrl, CPSUIPROP_PTVWND, (HANDLE)GET_PTVWND(hDlg));
  801. SetWindowLongPtr(hCtrl,
  802. GWLP_WNDPROC,
  803. (LPARAM)CPSUIUDArrowWndProc);
  804. CPSUIDBG(DBG_VALIDATE_UD, ("hUDArrow=%08lx: Save OldWndProc=%08lx",
  805. hUDArrow, OldWndProc));
  806. }
  807. }
  808. return(hUDArrow);
  809. } else {
  810. return(NULL);
  811. }
  812. }
  813. BOOL
  814. SetDlgPageItemName(
  815. HWND hDlg,
  816. PTVWND pTVWnd,
  817. POPTITEM pItem,
  818. UINT InitFlags,
  819. UINT UDArrowHelpID
  820. )
  821. /*++
  822. Routine Description:
  823. Arguments:
  824. Return Value:
  825. Author:
  826. 19-Sep-1995 Tue 18:29:44 created -by- Daniel Chou (danielc)
  827. Revision History:
  828. --*/
  829. {
  830. HWND hCtrl = NULL;
  831. POPTTYPE pOptType;
  832. UINT TitleID;
  833. BOOL AddItemSep;
  834. GSBUF_DEF(pItem, MAX_RES_STR_CHARS * 2);
  835. if (pOptType = GET_POPTTYPE(pItem)) {
  836. GSBUF_FLAGS |= GBF_PREFIX_OK;
  837. if ((TitleID = pOptType->BegCtrlID) &&
  838. (hCtrl = GetDlgItem(hDlg, TitleID))) {
  839. if (pItem->Flags & OPTIF_NO_GROUPBOX_NAME) {
  840. //
  841. // If we don't display the group name for TitleID and TitleID
  842. // exists in the page, we will enable/disable the group box
  843. // depending on InitFlag value. This is mainly for the "Tray
  844. // Selection" group, since it has both TitleID and TitleID + 1
  845. // in the page.
  846. //
  847. SHOWCTRL(hCtrl, TRUE, SW_SHOW);
  848. AddItemSep = TRUE;
  849. hCtrl = GetDlgItem(hDlg, TitleID + 1);
  850. } else {
  851. AddItemSep = FALSE;
  852. }
  853. } else {
  854. AddItemSep = TRUE;
  855. hCtrl = GetDlgItem(hDlg, TitleID + 1);
  856. }
  857. if (hCtrl) {
  858. POPTPARAM pOptParam = pOptType->pOptParam;
  859. //
  860. // Get the name first, and add in the seperator add needed
  861. //
  862. GSBUF_GETSTR(pItem->pName);
  863. if (InitFlags & INITCF_ADDSELPOSTFIX) {
  864. GSBUF_GETSTR(IDS_CPSUI_COLON_SEP);
  865. GSBUF_ADDNUM(pItem->Sel, TRUE);
  866. if (!(pOptType->Flags & OPTTF_NOSPACE_BEFORE_POSTFIX)) {
  867. GSBUF_ADD_SPACE(1);
  868. }
  869. GSBUF_GETSTR(pOptParam[0].pData);
  870. } else if (AddItemSep) {
  871. GSBUF_GETSTR(IDS_CPSUI_COLON_SEP);
  872. }
  873. //
  874. // If we have the UDARROW Help ID and it does not have control
  875. // associated it then put the range on the title bar
  876. //
  877. if ((UDArrowHelpID) && (!GetDlgItem(hDlg, UDArrowHelpID))) {
  878. GSBUF_ADD_SPACE(2);
  879. if (pOptParam[1].pData) {
  880. GSBUF_GETSTR(pOptParam[1].pData);
  881. } else {
  882. GSBUF_COMPOSE(IDS_INT_CPSUI_RANGE,
  883. NULL,
  884. pOptParam[1].IconID,
  885. pOptParam[1].lParam);
  886. }
  887. }
  888. //
  889. // We actually don't want the title enabled because we end up having this problem
  890. // with the shortcuts. When you have a shortcut to a static label (let's say
  891. // "Page&s Per Sheet") and you hit Alt-S, but the control this caption is
  892. // referring to is disabled then the focus goes into the next enabled control
  893. // in the tab order which has the WS_TABSTOP bit up (in out case this is the
  894. // "Advanced" button. We don't want this behavior.
  895. //
  896. // InitFlags |= INITCF_ENABLE;
  897. SetWindowText(hCtrl, (LPCTSTR)GSBUF_BUF);
  898. SHOWCTRL(hCtrl, TRUE, SW_SHOW);
  899. return(TRUE);
  900. }
  901. }
  902. return(FALSE);
  903. }
  904. #if (DO_IN_PLACE == 0)
  905. VOID
  906. SetPushSize(
  907. PTVWND pTVWnd,
  908. HWND hPush,
  909. LPWSTR pPushText,
  910. UINT cPushText,
  911. UINT SPSFlags
  912. )
  913. /*++
  914. Routine Description:
  915. Arguments:
  916. Return Value:
  917. Author:
  918. 02-Nov-1995 Thu 12:25:49 created -by- Daniel Chou (danielc)
  919. Revision History:
  920. --*/
  921. {
  922. HWND hExtPush;
  923. HDC hDC;
  924. HGDIOBJ hOld;
  925. SIZE szl;
  926. LONG xAdd;
  927. RECT rc;
  928. //
  929. // Adjust the size of push button
  930. //
  931. hOld = SelectObject(hDC = GetWindowDC(hPush),
  932. (HANDLE)SendMessage(hPush, WM_GETFONT, 0, 0L));
  933. GetTextExtentPoint32(hDC, L"W", 1, &szl);
  934. LPtoDP(hDC, (LPPOINT)&szl, 1);
  935. xAdd = szl.cx * PUSH_CX_EXTRA_W;
  936. GetTextExtentPoint32(hDC, pPushText, cPushText, &szl);
  937. LPtoDP(hDC, (LPPOINT)&szl, 1);
  938. SelectObject(hDC, hOld);
  939. ReleaseDC(hPush, hDC);
  940. hCtrlrcWnd(pTVWnd->hDlgTV, hPush, &rc);
  941. szl.cx += xAdd;
  942. szl.cy = (SPSFlags & SPSF_USE_BUTTON_CY) ? rc.bottom - rc.top :
  943. (szl.cy + PUSH_CY_EXTRA);
  944. CPSUIINT(("SetPushSize: Text=%ld x %ld, xAdd=%ld, Push=%ld x %ld",
  945. szl.cx - xAdd, szl.cy, xAdd, szl.cx, szl.cy));
  946. if ((SPSFlags & SPSF_ALIGN_EXTPUSH) &&
  947. (hExtPush = GetDlgItem(pTVWnd->hDlgTV, IDD_TV_EXTPUSH)) &&
  948. (hCtrlrcWnd(pTVWnd->hDlgTV, hExtPush, &rc))) {
  949. if ((xAdd = rc.right - rc.left) > szl.cx) {
  950. //
  951. // Increase the CX of the push button
  952. //
  953. CPSUIINT(("SetPushSize: Adjust PUSH equal to ExtPush (%ld)", xAdd));
  954. szl.cx = xAdd;
  955. } else if (xAdd < szl.cx) {
  956. //
  957. // Ext PUSH's CX is smaller, increase the cx
  958. //
  959. CPSUIINT(("SetPushSize: Adjust ExtPush equal to PUSH (%ld)", szl.cx));
  960. SetWindowPos(hExtPush, NULL,
  961. 0, 0,
  962. szl.cx, rc.bottom - rc.top,
  963. SWP_NOMOVE | SWP_NOZORDER |
  964. SWP_FRAMECHANGED | SWP_DRAWFRAME);
  965. }
  966. }
  967. SetWindowPos(hPush, NULL, 0, 0, szl.cx, szl.cy,
  968. SWP_NOMOVE | SWP_NOZORDER | SWP_FRAMECHANGED | SWP_DRAWFRAME);
  969. }
  970. #endif
  971. BOOL
  972. InitExtPush(
  973. PTVWND pTVWnd,
  974. HWND hDlg,
  975. POPTITEM pItem,
  976. UINT ExtChkBoxID,
  977. UINT ExtPushID,
  978. UINT ExtIconID,
  979. WORD InitItemIdx,
  980. WORD InitFlags
  981. )
  982. /*++
  983. Routine Description:
  984. This fucntion initialize the extended check box, and if will not allowed
  985. a item to be udpated if TWF_CAN_UPDATE is clear
  986. Arguments:
  987. Return Value:
  988. Author:
  989. 28-Aug-1995 Mon 21:01:35 created -by- Daniel Chou (danielc)
  990. Revision History:
  991. --*/
  992. {
  993. HWND hCtrl;
  994. if ((InitFlags & INITCF_INIT) &&
  995. (ExtChkBoxID) &&
  996. (ExtChkBoxID != ExtPushID) &&
  997. (hCtrl = GetDlgItem(hDlg, ExtChkBoxID))) {
  998. EnableWindow(hCtrl, FALSE);
  999. ShowWindow(hCtrl, SW_HIDE);
  1000. }
  1001. if ((ExtPushID) &&
  1002. (hCtrl = GetDlgItem(hDlg, ExtPushID))) {
  1003. HWND hCtrl2;
  1004. PEXTPUSH pEP;
  1005. BOOL Enable = FALSE;
  1006. UINT swMode = SW_SHOW;
  1007. BYTE CtrlData;
  1008. ULONG_PTR IconResID = 0;
  1009. WORD IconMode = 0;
  1010. GSBUF_DEF(pItem, MAX_RES_STR_CHARS);
  1011. #if DO_IN_PLACE
  1012. if (!IS_TVDLG) {
  1013. #else
  1014. {
  1015. #endif
  1016. GSBUF_FLAGS |= GBF_PREFIX_OK;
  1017. }
  1018. if (pItem == PIDX_INTOPTITEM(pTVWnd, INTIDX_TVROOT)) {
  1019. InitFlags |= INITCF_ENABLE;
  1020. } else if (!(pTVWnd->Flags & TWF_CAN_UPDATE)) {
  1021. InitFlags &= ~INITCF_ENABLE;
  1022. }
  1023. if ((!(pEP = pItem->pExtPush)) ||
  1024. // (!(pItem->pOptType)) ||
  1025. (pItem->Flags & (OPTIF_HIDE | OPTIF_EXT_HIDE))) {
  1026. swMode = SW_HIDE;
  1027. } else if (!(pItem->Flags & (OPTIF_HIDE | OPTIF_EXT_DISABLED))) {
  1028. Enable = TRUE;
  1029. }
  1030. #if DO_IN_PLACE
  1031. pTVWnd->hWndEdit[1] = ((IS_TVDLG) && (swMode == SW_SHOW)) ? hCtrl :
  1032. NULL;
  1033. #endif
  1034. CtrlData = (BYTE)((pEP->Flags & EPF_PUSH_TYPE_DLGPROC) ? 1 : 0);
  1035. HCTRL_SETCTRLDATA(hCtrl, CTRLS_EXTPUSH, CtrlData);
  1036. HCTRL_STATE(hCtrl, Enable, swMode);
  1037. if ((InitFlags & INITCF_INIT) && (pEP)) {
  1038. if (pEP == &ExtPushAbout) {
  1039. GSBUF_COMPOSE(IDS_INT_CPSUI_ABOUT,
  1040. pTVWnd->ComPropSheetUI.pCallerName,
  1041. 0,
  1042. 0);
  1043. } else {
  1044. if (pEP->Flags & EPF_INCL_SETUP_TITLE) {
  1045. GSBUF_COMPOSE(IDS_INT_CPSUI_SETUP, pEP->pTitle, 0, 0);
  1046. } else {
  1047. GSBUF_GETSTR(pEP->pTitle);
  1048. }
  1049. }
  1050. if (!(pEP->Flags & EPF_NO_DOT_DOT_DOT)) {
  1051. GSBUF_GETSTR(IDS_CPSUI_MORE);
  1052. }
  1053. if (IS_TVDLG) {
  1054. SIZEL szlText;
  1055. //
  1056. // Adjust the size of push button
  1057. //
  1058. #if DO_IN_PLACE
  1059. szlText.cx = 0;
  1060. GetTextExtentPoint(pTVWnd->hDCTVWnd,
  1061. GSBUF_BUF,
  1062. GSBUF_COUNT,
  1063. &szlText);
  1064. _OI_CXEXT(pItem) = (WORD)szlText.cx +
  1065. (WORD)(pTVWnd->cxSpace * 4);
  1066. _OI_CYEXTADD(pItem) = 0;
  1067. #else
  1068. SetPushSize(pTVWnd,
  1069. hCtrl,
  1070. GSBUF_BUF,
  1071. GSBUF_COUNT,
  1072. SPSF_USE_BUTTON_CY);
  1073. #endif
  1074. }
  1075. SetWindowText(hCtrl, GSBUF_BUF);
  1076. }
  1077. #if DO_IN_PLACE
  1078. if (IS_TVDLG) {
  1079. return((BOOL)(swMode == SW_SHOW));
  1080. }
  1081. #endif
  1082. if (pEP) {
  1083. if (pEP->Flags & EPF_OVERLAY_WARNING_ICON) {
  1084. IconMode |= MIM_WARNING_OVERLAY;
  1085. }
  1086. if (pEP->Flags & EPF_OVERLAY_STOP_ICON) {
  1087. IconMode |= MIM_STOP_OVERLAY;
  1088. }
  1089. if (pEP->Flags & EPF_OVERLAY_NO_ICON) {
  1090. IconMode |= MIM_NO_OVERLAY;
  1091. }
  1092. IconResID = GET_ICONID(pEP, EPF_ICONID_AS_HICON);
  1093. }
  1094. SET_EXTICON(TRUE);
  1095. } else {
  1096. return(FALSE);
  1097. }
  1098. }
  1099. BOOL
  1100. InitExtChkBox(
  1101. PTVWND pTVWnd,
  1102. HWND hDlg,
  1103. POPTITEM pItem,
  1104. UINT ExtChkBoxID,
  1105. UINT ExtPushID,
  1106. UINT ExtIconID,
  1107. WORD InitItemIdx,
  1108. WORD InitFlags
  1109. )
  1110. /*++
  1111. Routine Description:
  1112. This fucntion initialize the extended check box, and if will not allowed
  1113. a item to be udpated if TWF_CAN_UPDATE is clear
  1114. Arguments:
  1115. Return Value:
  1116. Author:
  1117. 28-Aug-1995 Mon 21:01:35 created -by- Daniel Chou (danielc)
  1118. Revision History:
  1119. --*/
  1120. {
  1121. HWND hCtrl;
  1122. if ((InitFlags & INITCF_INIT) &&
  1123. (ExtPushID) &&
  1124. (ExtPushID != ExtChkBoxID) &&
  1125. (hCtrl = GetDlgItem(hDlg, ExtPushID))) {
  1126. EnableWindow(hCtrl, FALSE);
  1127. ShowWindow(hCtrl, SW_HIDE);
  1128. }
  1129. if ((ExtChkBoxID) &&
  1130. (hCtrl = GetDlgItem(hDlg, ExtChkBoxID))) {
  1131. HWND hCtrl2;
  1132. PEXTCHKBOX pECB;
  1133. BOOL Enable = FALSE;
  1134. UINT swMode = SW_SHOW;
  1135. ULONG_PTR IconResID = 0;
  1136. WORD IconMode = 0;
  1137. GSBUF_DEF(pItem, MAX_RES_STR_CHARS);
  1138. #if DO_IN_PLACE
  1139. if (!IS_TVDLG) {
  1140. #else
  1141. {
  1142. #endif
  1143. GSBUF_FLAGS |= GBF_PREFIX_OK;
  1144. }
  1145. if (pItem == PIDX_INTOPTITEM(pTVWnd, INTIDX_TVROOT)) {
  1146. InitFlags |= INITCF_ENABLE;
  1147. } else if (!(pTVWnd->Flags & TWF_CAN_UPDATE)) {
  1148. InitFlags &= ~INITCF_ENABLE;
  1149. }
  1150. if ((!(pECB = pItem->pExtChkBox)) ||
  1151. // (!(pItem->pOptType)) ||
  1152. (pItem->Flags & (OPTIF_HIDE | OPTIF_EXT_HIDE))) {
  1153. swMode = SW_HIDE;
  1154. } else if (!(pItem->Flags & OPTIF_EXT_DISABLED)) {
  1155. Enable = TRUE;
  1156. }
  1157. #if DO_IN_PLACE
  1158. pTVWnd->hWndEdit[1] = ((IS_TVDLG) && (swMode == SW_SHOW)) ? hCtrl :
  1159. NULL;
  1160. #endif
  1161. HCTRL_SETCTRLDATA(hCtrl, CTRLS_EXTCHKBOX, 0);
  1162. HCTRL_STATE(hCtrl, Enable, swMode);
  1163. if ((InitFlags & INITCF_INIT) && (pECB)) {
  1164. LPTSTR pTitle;
  1165. if (!(pTitle = pECB->pCheckedName)) {
  1166. pTitle = pECB->pTitle;
  1167. }
  1168. HCTRL_TEXT(hCtrl, pTitle);
  1169. #if DO_IN_PLACE
  1170. if (IS_TVDLG) {
  1171. SIZEL szlText;
  1172. szlText.cx = 0;
  1173. GSBUF_FLAGS &= ~GBF_PREFIX_OK;
  1174. GSBUF_RESET;
  1175. GSBUF_GETSTR(pTitle);
  1176. szlText.cy = (LONG)GSBUF_COUNT;
  1177. pTitle = &GSBUF_BUF[szlText.cy - 1];
  1178. while (*pTitle == L' ') {
  1179. --pTitle;
  1180. --szlText.cy;
  1181. }
  1182. pTitle = GSBUF_BUF;
  1183. while (*pTitle == L' ') {
  1184. ++pTitle;
  1185. --szlText.cy;
  1186. }
  1187. GetTextExtentPoint(pTVWnd->hDCTVWnd,
  1188. pTitle,
  1189. szlText.cy,
  1190. &szlText);
  1191. CPSUIINT(("ExtChkBox: '%ws' = %ld", GSBUF_BUF, szlText.cx));
  1192. _OI_CXEXT(pItem) = (WORD)szlText.cx +
  1193. (WORD)GetSystemMetrics(SM_CXSMICON) +
  1194. (WORD)pTVWnd->cxSpace * 2;
  1195. _OI_CYEXTADD(pItem) = 0;
  1196. }
  1197. #endif
  1198. }
  1199. CheckDlgButton(hDlg,
  1200. ExtChkBoxID,
  1201. (pItem->Flags & OPTIF_ECB_CHECKED) ? BST_CHECKED :
  1202. BST_UNCHECKED);
  1203. #if DO_IN_PLACE
  1204. if (IS_TVDLG) {
  1205. return((BOOL)(swMode == SW_SHOW));
  1206. }
  1207. #endif
  1208. if (pECB) {
  1209. if (pECB->Flags & ECBF_OVERLAY_WARNING_ICON) {
  1210. IconMode |= MIM_WARNING_OVERLAY;
  1211. }
  1212. if (pECB->Flags & ECBF_OVERLAY_STOP_ICON) {
  1213. IconMode |= MIM_STOP_OVERLAY;
  1214. }
  1215. if (pECB->Flags & ECBF_OVERLAY_NO_ICON) {
  1216. IconMode |= MIM_NO_OVERLAY;
  1217. }
  1218. IconResID = GET_ICONID(pECB, ECBF_ICONID_AS_HICON);
  1219. }
  1220. SET_EXTICON(TRUE);
  1221. } else {
  1222. return(FALSE);
  1223. }
  1224. }
  1225. UINT
  1226. InitStates(
  1227. PTVWND pTVWnd,
  1228. HWND hDlg,
  1229. POPTITEM pItem,
  1230. POPTTYPE pOptType,
  1231. UINT IDState1,
  1232. WORD InitItemIdx,
  1233. LONG NewSel,
  1234. WORD InitFlags
  1235. )
  1236. /*++
  1237. Routine Description:
  1238. Arguments:
  1239. Return Value:
  1240. Author:
  1241. 24-Aug-1995 Thu 20:16:29 created -by- Daniel Chou (danielc)
  1242. Revision History:
  1243. --*/
  1244. {
  1245. HWND hCtrl;
  1246. HWND hCtrlIcon;
  1247. POPTPARAM pOP;
  1248. UINT CtrlID;
  1249. UINT i;
  1250. UINT MaxStates;
  1251. MaxStates = (UINT)(pOptType->Count - 1);
  1252. if (InitFlags & INITCF_INIT) {
  1253. for (i = 0, CtrlID = IDState1, pOP = pOptType->pOptParam;
  1254. i <= (UINT)MaxStates;
  1255. i++, CtrlID += 2, pOP++) {
  1256. INT swMode;
  1257. BOOL Enable;
  1258. GSBUF_DEF(pItem, MAX_RES_STR_CHARS);
  1259. GSBUF_FLAGS |= GBF_PREFIX_OK;
  1260. //
  1261. // All the radio hide button already hided
  1262. //
  1263. if (pOP->Flags & OPTPF_HIDE) {
  1264. CPSUIASSERT(0, "2/3 States %d: 'Sel' item is OPTPF_HIDE",
  1265. NewSel != (LONG)i, UIntToPtr(i + 1));
  1266. if (NewSel == (LONG)i) {
  1267. if (++NewSel > (LONG)MaxStates) {
  1268. NewSel = 0;
  1269. }
  1270. }
  1271. } else {
  1272. hCtrl = NULL;
  1273. if (CtrlID) {
  1274. hCtrl = GetDlgItem(hDlg, CtrlID);
  1275. }
  1276. hCtrlIcon = GetDlgItem(hDlg, CtrlID + 1);
  1277. if (hCtrl) {
  1278. HCTRL_SETCTRLDATA(hCtrl, CTRLS_RADIO, i);
  1279. if (InitFlags & INITCF_INIT) {
  1280. HCTRL_TEXT(hCtrl, pOP->pData);
  1281. }
  1282. Enable = !(BOOL)(pOP->Flags & OPTPF_DISABLED);
  1283. HCTRL_STATE(hCtrl,
  1284. !(BOOL)(pOP->Flags & OPTPF_DISABLED),
  1285. SW_SHOW);
  1286. }
  1287. HCTRL_STATE(hCtrlIcon, TRUE, SW_SHOW);
  1288. }
  1289. }
  1290. }
  1291. CheckRadioButton(hDlg,
  1292. IDState1,
  1293. IDState1 + (WORD)(MaxStates << 1),
  1294. IDState1 + (DWORD)(NewSel << 1));
  1295. return(NewSel);
  1296. }
  1297. LONG
  1298. InitUDArrow(
  1299. PTVWND pTVWnd,
  1300. HWND hDlg,
  1301. POPTITEM pItem,
  1302. POPTPARAM pOptParam,
  1303. UINT UDArrowID,
  1304. UINT EditBoxID,
  1305. UINT PostfixID,
  1306. UINT HelpID,
  1307. WORD InitItemIdx,
  1308. LONG NewPos,
  1309. WORD InitFlags
  1310. )
  1311. /*++
  1312. Routine Description:
  1313. Arguments:
  1314. Return Value:
  1315. Author:
  1316. 24-Aug-1995 Thu 18:55:07 created -by- Daniel Chou (danielc)
  1317. Revision History:
  1318. --*/
  1319. {
  1320. HWND hUDArrow;
  1321. HWND hEdit;
  1322. HWND hCtrl;
  1323. DWORD dw;
  1324. LONG Range[2];
  1325. BYTE CtrlData;
  1326. GSBUF_DEF(pItem, MAX_RES_STR_CHARS * 2);
  1327. //
  1328. // Create Up/Down Control
  1329. //
  1330. GSBUF_FLAGS |= GBF_PREFIX_OK;
  1331. hUDArrow = (UDArrowID) ? GetDlgItem(hDlg, UDArrowID) : NULL;
  1332. hEdit = (EditBoxID) ? GetDlgItem(hDlg, EditBoxID) : NULL;
  1333. if ((!hUDArrow) || (!hEdit)) {
  1334. return(ERR_CPSUI_CREATE_UDARROW_FAILED);
  1335. }
  1336. Range[0] = (LONG)pOptParam[1].IconID;
  1337. Range[1] = (LONG)pOptParam[1].lParam;
  1338. if (NewPos < Range[0]) {
  1339. NewPos = Range[0];
  1340. } else if (NewPos > Range[1]) {
  1341. NewPos = Range[1];
  1342. }
  1343. if (InitFlags & INITCF_SETCTRLDATA) {
  1344. CtrlData = ((Range[0] < 0) || (Range[1] < 0)) ? EDF_MINUS_OK : 0;
  1345. if (IS_TVDLG) {
  1346. CtrlData |= EDF_IN_TVPAGE;
  1347. }
  1348. HCTRL_SETCTRLDATA(hEdit, CTRLS_UDARROW_EDIT, CtrlData);
  1349. HCTRL_SETCTRLDATA(hUDArrow, CTRLS_UDARROW, CtrlData);
  1350. }
  1351. if (InitFlags & INITCF_INIT) {
  1352. RECT rc;
  1353. #if DO_IN_PLACE
  1354. PostfixID =
  1355. HelpID = 0;
  1356. #endif
  1357. HCTRL_STATE(hEdit, FALSE, SW_HIDE);
  1358. HCTRL_STATE(hUDArrow, FALSE, SW_HIDE);
  1359. if ((PostfixID) && (hCtrl = GetDlgItem(hDlg, PostfixID))) {
  1360. GSBUF_RESET;
  1361. GSBUF_GETSTR(pOptParam[0].pData);
  1362. SetWindowText(hCtrl, GSBUF_BUF);
  1363. HCTRL_STATE(hCtrl, TRUE, SW_SHOW);
  1364. }
  1365. if ((HelpID) && (hCtrl = GetDlgItem(hDlg, HelpID))) {
  1366. GSBUF_RESET;
  1367. if (pOptParam[1].pData) {
  1368. GSBUF_GETSTR(pOptParam[1].pData);
  1369. } else {
  1370. GSBUF_COMPOSE(IDS_INT_CPSUI_RANGE,
  1371. NULL,
  1372. Range[0],
  1373. Range[1]);
  1374. }
  1375. SetWindowText(hCtrl, GSBUF_BUF);
  1376. HCTRL_STATE(hCtrl, TRUE, SW_SHOW);
  1377. }
  1378. //
  1379. // Set the style so that it only take numbers v4.0 or later
  1380. //
  1381. SetWindowLongPtr(hEdit,
  1382. GWL_STYLE,
  1383. GetWindowLong(hEdit, GWL_STYLE) | ES_NUMBER);
  1384. //
  1385. // Set the UD arrow edit control to maximum 7 characters
  1386. //
  1387. SendMessage(hEdit, EM_SETLIMITTEXT, MAX_UDARROW_TEXT_LEN, 0L);
  1388. #if DO_IN_PLACE
  1389. if ((IS_TVDLG) &&
  1390. (TreeView_GetItemRect(pTVWnd->hWndTV,
  1391. _OI_HITEM(pItem),
  1392. &rc,
  1393. TRUE))) {
  1394. LONG OrgL;
  1395. pTVWnd->ptCur.x = rc.left;
  1396. pTVWnd->ptCur.y = rc.top;
  1397. OrgL = rc.right;
  1398. rc.left = rc.right + pTVWnd->cxSelAdd;
  1399. rc.right = rc.left + pTVWnd->cxMaxUDEdit;
  1400. SetWindowPos(pTVWnd->hWndEdit[0] = hEdit,
  1401. NULL,
  1402. rc.left,
  1403. rc.top,
  1404. rc.right - rc.left,
  1405. rc.bottom - rc.top + 1,
  1406. SWP_NOZORDER | SWP_FRAMECHANGED | SWP_DRAWFRAME);
  1407. //
  1408. // Following code is only for exposing edit box name in MSAA
  1409. //
  1410. {
  1411. TVITEM tvi;
  1412. HWND hCtrl;
  1413. GSBUF_DEF(pItem, MAX_RES_STR_CHARS);
  1414. tvi.hItem = _OI_HITEM(pItem);
  1415. tvi.mask = TVIF_TEXT;
  1416. tvi.pszText = GSBUF_BUF;
  1417. tvi.cchTextMax = MAX_RES_STR_CHARS;
  1418. if (TreeView_GetItem(pTVWnd->hWndTV, &tvi) && (hCtrl = GetDlgItem(pTVWnd->hWndTV, IDD_TV_MSAA_NAME)))
  1419. {
  1420. SetWindowText(hCtrl, tvi.pszText);
  1421. //
  1422. // Insert the invisible label ahead of the combo box.
  1423. //
  1424. SetWindowPos(hCtrl, hEdit, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOREDRAW);
  1425. SetWindowPos(hEdit, hCtrl, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOREDRAW);
  1426. }
  1427. }
  1428. DestroyWindow(hUDArrow);
  1429. pTVWnd->hWndEdit[2] =
  1430. hUDArrow = CreateUDArrow(hDlg,
  1431. IDD_TV_UDARROW_EDIT,
  1432. IDD_TV_UDARROW,
  1433. Range[0],
  1434. Range[1],
  1435. NewPos);
  1436. HCTRL_SETCTRLDATA(hUDArrow, CTRLS_UDARROW, CtrlData);
  1437. if (pTVWnd->hWndEdit[1]) {
  1438. rc.left = rc.right + pTVWnd->cxExtAdd;
  1439. rc.right = rc.left + (LONG)_OI_CXEXT(pItem);
  1440. SetWindowPos(pTVWnd->hWndEdit[1],
  1441. hUDArrow,
  1442. rc.left,
  1443. rc.top,
  1444. rc.right - rc.left,
  1445. rc.bottom - rc.top + (LONG)_OI_CYEXTADD(pItem),
  1446. SWP_FRAMECHANGED | SWP_DRAWFRAME);
  1447. }
  1448. pTVWnd->chWndEdit = 3;
  1449. pTVWnd->cxEdit = (WORD)(rc.right - OrgL);
  1450. pTVWnd->cxItem = (WORD)(rc.right - pTVWnd->ptCur.x);
  1451. }
  1452. #endif
  1453. SendMessage(hUDArrow,
  1454. UDM_SETRANGE,
  1455. (WPARAM)0,
  1456. (LPARAM)MAKELONG((SHORT)Range[1], (SHORT)Range[0]));
  1457. Range[0] = 0;
  1458. Range[1] = -1;
  1459. } else {
  1460. SendMessage(hEdit, EM_GETSEL, (WPARAM)&Range[0], (LPARAM)&Range[1]);
  1461. }
  1462. HCTRL_STATE(hEdit, TRUE, SW_SHOW);
  1463. HCTRL_STATE(hUDArrow, TRUE, SW_SHOW);
  1464. SendMessage(hUDArrow, UDM_SETPOS, 0, (LPARAM)MAKELONG(NewPos, 0));
  1465. SendMessage(hEdit, EM_SETSEL, (WPARAM)Range[0], (LPARAM)Range[1]);
  1466. CPSUIDBG(DBG_VALIDATE_UD, ("InitUDArrow: NewPos=%ld, SELECT=%ld / %ld",
  1467. NewPos, Range[0], Range[1]));
  1468. return(1);
  1469. }
  1470. VOID
  1471. InitTBSB(
  1472. PTVWND pTVWnd,
  1473. HWND hDlg,
  1474. POPTITEM pItem,
  1475. HWND hTBSB,
  1476. POPTTYPE pOptType,
  1477. UINT PostfixID,
  1478. UINT RangeLID,
  1479. UINT RangeHID,
  1480. WORD InitItemIdx,
  1481. LONG NewPos,
  1482. WORD InitFlags
  1483. )
  1484. /*++
  1485. Routine Description:
  1486. Arguments:
  1487. Return Value:
  1488. Author:
  1489. 25-Aug-1995 Fri 14:25:50 created -by- Daniel Chou (danielc)
  1490. Revision History:
  1491. --*/
  1492. {
  1493. HWND hCtrl;
  1494. POPTPARAM pOptParam;
  1495. LONG Range[2];
  1496. LONG CurRange;
  1497. LONG MulFactor;
  1498. UINT i;
  1499. BOOL IsTB;
  1500. GSBUF_DEF(pItem, MAX_RES_STR_CHARS);
  1501. IsTB = (BOOL)(GetWindowLongPtr(hTBSB, GWLP_ID) == IDD_TV_TRACKBAR);
  1502. pOptParam = pOptType->pOptParam;
  1503. Range[0] = (LONG)pOptParam[1].IconID;
  1504. Range[1] = (LONG)pOptParam[1].lParam;
  1505. MulFactor = (LONG)pOptParam[2].IconID;
  1506. if ((NewPos < Range[0]) || (NewPos > Range[1])) {
  1507. NewPos = Range[0];
  1508. }
  1509. if (InitFlags & INITCF_INIT) {
  1510. #if DO_IN_PLACE
  1511. RECT rc;
  1512. LONG MaxR;
  1513. GetClientRect(pTVWnd->hWndTV, &rc);
  1514. MaxR = rc.right;
  1515. #endif
  1516. CPSUIDBG(DBG_INITTBSB, ("TB/SB Range=%ld to %ld", Range[0], Range[1]));
  1517. //
  1518. // Set Low/High range text
  1519. //
  1520. #if DO_IN_PLACE
  1521. if ((IS_TVDLG) &&
  1522. (TreeView_GetItemRect(pTVWnd->hWndTV,
  1523. _OI_HITEM(pItem),
  1524. &rc,
  1525. TRUE))) {
  1526. LONG OrgL;
  1527. pTVWnd->ptCur.x = rc.left;
  1528. pTVWnd->ptCur.y = rc.top;
  1529. OrgL = rc.right;
  1530. rc.left = rc.right + pTVWnd->cxSelAdd;
  1531. rc.right = rc.left + (pTVWnd->cxAveChar * 32);
  1532. SetWindowPos(pTVWnd->hWndEdit[0] = hTBSB,
  1533. NULL,
  1534. rc.left,
  1535. rc.top,
  1536. rc.right - rc.left,
  1537. rc.bottom - rc.top,
  1538. SWP_NOZORDER | SWP_FRAMECHANGED | SWP_DRAWFRAME);
  1539. if (pTVWnd->hWndEdit[1]) {
  1540. pTVWnd->chWndEdit = 2;
  1541. rc.left = rc.right + pTVWnd->cxExtAdd;
  1542. rc.right = rc.left + (LONG)_OI_CXEXT(pItem);
  1543. SetWindowPos(pTVWnd->hWndEdit[1],
  1544. hTBSB,
  1545. rc.left,
  1546. rc.top,
  1547. rc.right - rc.left,
  1548. rc.bottom - rc.top + (LONG)_OI_CYEXTADD(pItem),
  1549. SWP_FRAMECHANGED | SWP_DRAWFRAME);
  1550. } else {
  1551. pTVWnd->chWndEdit = 1;
  1552. }
  1553. pTVWnd->cxEdit = (WORD)(rc.right - OrgL);
  1554. pTVWnd->cxItem = (WORD)(rc.right - pTVWnd->ptCur.x);
  1555. PostfixID =
  1556. RangeLID =
  1557. RangeHID = 0;
  1558. GSBUF_FLAGS |= GBF_PREFIX_OK;
  1559. }
  1560. #endif
  1561. if ((PostfixID) && (hCtrl = GetDlgItem(hDlg, PostfixID))) {
  1562. GSBUF_RESET;
  1563. if (!(pOptType->Flags & OPTTF_NOSPACE_BEFORE_POSTFIX)) {
  1564. GSBUF_ADD_SPACE(1);
  1565. }
  1566. GSBUF_GETSTR(pOptParam[0].pData);
  1567. SetWindowText(hCtrl, GSBUF_BUF);
  1568. SHOWCTRL(hCtrl, TRUE, SW_SHOW);
  1569. }
  1570. for (i = 1; i <= 2; i++, RangeLID = RangeHID) {
  1571. if ((RangeLID) && (hCtrl = GetDlgItem(hDlg, RangeLID))) {
  1572. LPTSTR pRangeText;
  1573. GSBUF_RESET;
  1574. if (pRangeText = pOptParam[i].pData) {
  1575. GSBUF_GETSTR(pRangeText);
  1576. } else {
  1577. CurRange = Range[i - 1] * MulFactor;
  1578. GSBUF_ADDNUM(Range[i - 1] * MulFactor, TRUE);
  1579. if (!(pOptType->Flags & OPTTF_NOSPACE_BEFORE_POSTFIX)) {
  1580. GSBUF_ADD_SPACE(1);
  1581. }
  1582. GSBUF_GETSTR(pOptParam[0].pData);
  1583. }
  1584. SetWindowText(hCtrl, GSBUF_BUF);
  1585. SHOWCTRL(hCtrl, TRUE, SW_SHOW);
  1586. }
  1587. }
  1588. if (IsTB) {
  1589. SendMessage(hTBSB,
  1590. TBM_SETRANGE,
  1591. (WPARAM)TRUE,
  1592. (LPARAM)MAKELONG((SHORT)Range[0], (SHORT)Range[1]));
  1593. SendMessage(hTBSB,
  1594. TBM_SETPAGESIZE,
  1595. (WPARAM)0,
  1596. (LPARAM)pOptParam[2].lParam);
  1597. CurRange = Range[1] - Range[0];
  1598. if ((!(MulFactor = (LONG)pOptParam[2].lParam)) ||
  1599. ((CurRange / MulFactor) > 25)) {
  1600. MulFactor = CurRange / 25;
  1601. }
  1602. CPSUIINT(("Tick Freq set to %ld, Range=%ld", MulFactor, CurRange));
  1603. SendMessage(hTBSB,
  1604. TBM_SETTICFREQ,
  1605. (WPARAM)MulFactor,
  1606. (LPARAM)NewPos);
  1607. } else {
  1608. SendMessage(hTBSB,
  1609. SBM_SETRANGE,
  1610. (WPARAM)(SHORT)Range[0],
  1611. (LPARAM)(SHORT)Range[1]);
  1612. }
  1613. }
  1614. //
  1615. // Set Static text
  1616. //
  1617. if (IsTB) {
  1618. HCTRL_SETCTRLDATA(hTBSB, CTRLS_TRACKBAR, 0);
  1619. SendMessage(hTBSB, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)NewPos);
  1620. } else {
  1621. HCTRL_SETCTRLDATA(hTBSB, CTRLS_HSCROLL, 0);
  1622. SendMessage(hTBSB, SBM_SETPOS, (WPARAM)NewPos, (LPARAM)TRUE);
  1623. }
  1624. HCTRL_STATE(hTBSB, TRUE, SW_SHOW);
  1625. }
  1626. VOID
  1627. InitLBCB(
  1628. PTVWND pTVWnd,
  1629. HWND hDlg,
  1630. POPTITEM pItem,
  1631. UINT idLBCB,
  1632. UINT SetCurSelID,
  1633. POPTTYPE pOptType,
  1634. WORD InitItemIdx,
  1635. LONG NewSel,
  1636. WORD InitFlags,
  1637. UINT cyLBCBMax
  1638. )
  1639. /*++
  1640. Routine Description:
  1641. Arguments:
  1642. Return Value:
  1643. Author:
  1644. 25-Aug-1995 Fri 14:32:19 created -by- Daniel Chou (danielc)
  1645. Revision History:
  1646. --*/
  1647. {
  1648. HWND hLBCB;
  1649. DWORD dw;
  1650. LONG Ret;
  1651. LONG CurSel;
  1652. BOOL IsLB = (BOOL)(SetCurSelID == LB_SETCURSEL);
  1653. GSBUF_DEF(pItem, MAX_RES_STR_CHARS);
  1654. if ((!idLBCB) || (!(hLBCB = GetDlgItem(hDlg, idLBCB)))) {
  1655. return;
  1656. }
  1657. if ((!IsLB) &&
  1658. (InitFlags & INITCF_INIT) &&
  1659. (SendMessage(hLBCB, CB_GETDROPPEDSTATE, 0, 0))) {
  1660. InitFlags &= ~INITCF_INIT;
  1661. }
  1662. if (InitFlags & INITCF_INIT) {
  1663. HWND hCtrl;
  1664. HDC hDC;
  1665. HGDIOBJ hOld;
  1666. POPTPARAM pOP;
  1667. TEXTMETRIC tm;
  1668. RECT rc;
  1669. RECT rcC;
  1670. INT InsertID;
  1671. INT SetItemDataID;
  1672. UINT i;
  1673. LONG cxCBEdit = 0;
  1674. LONG cyCBEdit;
  1675. LONG cMaxLB = 0;
  1676. LONG cShow;
  1677. UINT cyLBCB;
  1678. UINT cyFrame;
  1679. SIZEL szlText;
  1680. //
  1681. // Figure we need to draw icon
  1682. //
  1683. _OT_FLAGS(pOptType) &= ~OTINTF_ITEM_HAS_ICON16;
  1684. if (!(pOptType->Style & OTS_LBCB_NO_ICON16_IN_ITEM)) {
  1685. ULONG_PTR IconID;
  1686. i = (UINT)pOptType->Count;
  1687. pOP = pOptType->pOptParam;
  1688. if (((DWORD)NewSel >= (DWORD)pOptType->Count) ||
  1689. (pOptType->Style & OTS_LBCB_INCL_ITEM_NONE)) {
  1690. IconID = pTVWnd->OptParamNone.IconID;
  1691. } else {
  1692. IconID = pOP->IconID;
  1693. }
  1694. while (i--) {
  1695. if (!(pOP->Flags & OPTPF_HIDE)) {
  1696. if (// (IconID) ||
  1697. (IconID != pOP->IconID) ||
  1698. (pOP->Flags & (OPTPF_OVERLAY_WARNING_ICON |
  1699. OPTPF_OVERLAY_STOP_ICON |
  1700. OPTPF_OVERLAY_NO_ICON))) {
  1701. _OT_FLAGS(pOptType) |= OTINTF_ITEM_HAS_ICON16;
  1702. break;
  1703. }
  1704. }
  1705. pOP++;
  1706. }
  1707. }
  1708. hOld = SelectObject(hDC = GetWindowDC(hLBCB),
  1709. (HANDLE)SendMessage(hLBCB, WM_GETFONT, 0, 0L));
  1710. GetTextMetrics(hDC, &tm);
  1711. CPSUIINT(("InitLBCB: Font Height=%ld, cyEdge=%ld",
  1712. tm.tmHeight, GetSystemMetrics(SM_CYEDGE)));
  1713. if ((_OT_FLAGS(pOptType) & OTINTF_ITEM_HAS_ICON16) &&
  1714. (tm.tmHeight < (LONG)pTVWnd->cyImage)) {
  1715. cyLBCB = (UINT)pTVWnd->cyImage;
  1716. } else {
  1717. cyLBCB = (UINT)tm.tmHeight + 2;
  1718. }
  1719. CPSUIDBG(DBG_TMP, ("CB: cyImage=%ld, cyicon=%ld, tmHeight=%ld",
  1720. pTVWnd->cyImage, CYICON, tm.tmHeight));
  1721. #if DO_IN_PLACE
  1722. //
  1723. // If it is in Treeview then we need to have exact tmHeight, otherwise
  1724. // we need to add 2 for focus rect and another two to compensate the
  1725. // cyImage, 16+2+2=20=CYICON, at dialog box template we need to add
  1726. // one dialog box unit for the spacing.
  1727. //
  1728. cyCBEdit = tm.tmHeight + ((IS_TVDLG) ? 0 : 4);
  1729. #else
  1730. cyCBEdit = (LONG)cyLBCB;
  1731. #endif
  1732. tm.tmHeight = (LONG)cyLBCB;
  1733. CPSUIDBG(DBG_CB_CY, ("cyCBEdit=%ld, ItemHeight=%ld",
  1734. cyCBEdit, tm.tmHeight));
  1735. SendMessage(hLBCB, WM_SETREDRAW, (WPARAM)FALSE, 0L);
  1736. if (IsLB) {
  1737. //
  1738. // Resize the listbox based on the height
  1739. //
  1740. hCtrlrcWnd(hDlg, hLBCB, &rc);
  1741. GetClientRect(hLBCB, &rcC);
  1742. cyLBCB = (UINT)(rc.bottom - rc.top);
  1743. cyFrame = (UINT)(cyLBCB - rcC.bottom);
  1744. i = (UINT)((cyLBCBMax - cyFrame) % tm.tmHeight);
  1745. CPSUIRECT(0, " rcLBCB", &rc, cyLBCB, cyFrame);
  1746. CPSUIRECT(0, "rcClient", &rcC, i,
  1747. (UINT)((cyLBCBMax - cyFrame) / tm.tmHeight));
  1748. if ((IS_TVDLG) || (!(InitFlags & INITCF_ENABLE))) {
  1749. cMaxLB = -(LONG)((cyLBCBMax - cyFrame) / tm.tmHeight);
  1750. }
  1751. cyLBCB = cyLBCBMax - i;
  1752. if (IS_TVDLG) {
  1753. rc.top = pTVWnd->tLB;
  1754. }
  1755. SetWindowPos(hLBCB, NULL,
  1756. rc.left, rc.top += (i / 2),
  1757. rc.right - rc.left, cyLBCB,
  1758. SWP_NOZORDER | SWP_FRAMECHANGED | SWP_DRAWFRAME);
  1759. CPSUIINT(("LB: Frame=%ld, cyLBCB=%ld, Count=%ld, %ld less pels",
  1760. cyFrame, cyLBCB, cMaxLB, tm.tmHeight - i));
  1761. InsertID = (pOptType->Style & OTS_LBCB_SORT) ? LB_ADDSTRING :
  1762. LB_INSERTSTRING;
  1763. SendMessage(hLBCB, LB_SETITEMHEIGHT, 0, MAKELPARAM(tm.tmHeight,0));
  1764. SendMessage(hLBCB, LB_RESETCONTENT, 0, 0L);
  1765. SetItemDataID = LB_SETITEMDATA;
  1766. HCTRL_SETCTRLDATA(hLBCB, CTRLS_LISTBOX, pOptType->Type);
  1767. } else {
  1768. InsertID = (pOptType->Style & OTS_LBCB_SORT) ? CB_ADDSTRING :
  1769. CB_INSERTSTRING;
  1770. SendMessage(hLBCB,
  1771. CB_SETITEMHEIGHT,
  1772. (WPARAM)-1,
  1773. MAKELPARAM(cyCBEdit, 0));
  1774. //
  1775. // Aligned the static text with new combox edit field when this
  1776. // combo box is not in treeview page
  1777. //
  1778. if ((!IS_TVDLG) &&
  1779. (hCtrl = GetDlgItem(hDlg, idLBCB - 1)) &&
  1780. (hCtrlrcWnd(hDlg, hCtrl, &rcC)) &&
  1781. (hCtrlrcWnd(hDlg, hLBCB, &rc))) {
  1782. SetWindowPos(hCtrl,
  1783. NULL,
  1784. rcC.left,
  1785. rc.top + ((rc.bottom - rc.top) -
  1786. (rcC.bottom - rcC.top)) / 2,
  1787. 0, 0,
  1788. SWP_NOZORDER | SWP_NOSIZE);
  1789. }
  1790. SendMessage(hLBCB,
  1791. CB_SETITEMHEIGHT,
  1792. (WPARAM)0,
  1793. MAKELPARAM(tm.tmHeight, 0));
  1794. SendMessage(hLBCB, CB_RESETCONTENT, 0, 0L);
  1795. SetItemDataID = CB_SETITEMDATA;
  1796. HCTRL_SETCTRLDATA(hLBCB, CTRLS_COMBOBOX, pOptType->Type);
  1797. }
  1798. for (i = 0, cShow = 0, pOP = pOptType->pOptParam;
  1799. i < (UINT)pOptType->Count;
  1800. i++, pOP++) {
  1801. if (!(pOP->Flags & OPTPF_HIDE)) {
  1802. GSBUF_RESET;
  1803. GSBUF_GETSTR(pOP->pData);
  1804. CurSel = (LONG)SendMessage(hLBCB,
  1805. InsertID,
  1806. (WPARAM)-1,
  1807. (LPARAM)GSBUF_BUF);
  1808. #if DO_IN_PLACE
  1809. GetTextExtentPoint(hDC, GSBUF_BUF, GSBUF_COUNT, &szlText);
  1810. if (szlText.cx > cxCBEdit) {
  1811. cxCBEdit = szlText.cx;
  1812. }
  1813. #endif
  1814. dw = (DWORD)i;
  1815. if (pOP->Flags & OPTPF_DISABLED) {
  1816. dw |= LBCBID_DISABLED;
  1817. } else {
  1818. ++cShow;
  1819. }
  1820. SendMessage(hLBCB, SetItemDataID, (WPARAM)CurSel, (LPARAM)dw);
  1821. ++cMaxLB;
  1822. }
  1823. }
  1824. if ((!cShow) ||
  1825. ((DWORD)NewSel >= (DWORD)pOptType->Count) ||
  1826. (pOptType->Style & OTS_LBCB_INCL_ITEM_NONE)) {
  1827. //
  1828. // Always add it to the begnining
  1829. //
  1830. GSBUF_RESET;
  1831. GSBUF_GETSTR(pTVWnd->OptParamNone.pData);
  1832. CurSel = (LONG)SendMessage(hLBCB,
  1833. (IsLB) ? LB_INSERTSTRING :
  1834. CB_INSERTSTRING,
  1835. (WPARAM)0,
  1836. (LPARAM)GSBUF_BUF);
  1837. #if DO_IN_PLACE
  1838. GetTextExtentPoint(hDC, GSBUF_BUF, GSBUF_COUNT, &szlText);
  1839. if (szlText.cx > cxCBEdit) {
  1840. cxCBEdit = szlText.cx;
  1841. }
  1842. #endif
  1843. SendMessage(hLBCB,
  1844. SetItemDataID,
  1845. (WPARAM)CurSel,
  1846. (LPARAM)LBCBID_NONE);
  1847. ++cShow;
  1848. ++cMaxLB;
  1849. }
  1850. if ((IsLB) && (IS_TVDLG)) {
  1851. if (cMaxLB < 0) {
  1852. //
  1853. // We got some items which is blank, then re-size the LISTBOX
  1854. //
  1855. CPSUIINT(("Resize LB: cMaxLB=%ld, cyLBCB=%ld [%ld]",
  1856. cMaxLB, cyLBCB, -cMaxLB * tm.tmHeight));
  1857. cMaxLB = -cMaxLB * tm.tmHeight;
  1858. SetWindowPos(hLBCB, NULL,
  1859. rc.left, rc.top + (cMaxLB / 2),
  1860. rc.right - rc.left, cyLBCB - (UINT)cMaxLB,
  1861. SWP_NOZORDER | SWP_FRAMECHANGED | SWP_DRAWFRAME);
  1862. }
  1863. cMaxLB = 0;
  1864. }
  1865. while (cMaxLB++ < 0) {
  1866. CurSel = (LONG)SendMessage(hLBCB,
  1867. (IsLB) ? LB_INSERTSTRING :
  1868. CB_INSERTSTRING,
  1869. (WPARAM)-1,
  1870. (LPARAM)L"");
  1871. SendMessage(hLBCB,
  1872. SetItemDataID,
  1873. (WPARAM)CurSel,
  1874. (LPARAM)LBCBID_FILL);
  1875. }
  1876. HCTRL_STATE(hLBCB, TRUE, SW_SHOW);
  1877. #if DO_IN_PLACE
  1878. if ((!IsLB) &&
  1879. (IS_TVDLG) &&
  1880. (pTVWnd->hWndTV) &&
  1881. (TreeView_GetItemRect(pTVWnd->hWndTV,
  1882. _OI_HITEM(pItem),
  1883. &rc,
  1884. TRUE))) {
  1885. LONG cxReal;
  1886. LONG OrgL;
  1887. RECT rcWnd;
  1888. pTVWnd->ptCur.x = rc.left;
  1889. pTVWnd->ptCur.y = rc.top;
  1890. OrgL = rc.right;
  1891. rc.left = rc.right + pTVWnd->cxSelAdd;
  1892. if (_OT_FLAGS(pOptType) & OTINTF_ITEM_HAS_ICON16) {
  1893. cxCBEdit += (CXIMAGE + LBCB_ICON_TEXT_X_SEP);
  1894. }
  1895. cxCBEdit += (LBCB_ICON_X_OFF + pTVWnd->cxCBAdd);
  1896. cxReal = cxCBEdit;
  1897. GetClientRect(pTVWnd->hWndTV, &rcWnd);
  1898. rcWnd.right -= pTVWnd->cxSelAdd;
  1899. if (pTVWnd->hWndEdit[1]) {
  1900. rcWnd.right -= (pTVWnd->cxExtAdd + _OI_CXEXT(pItem));
  1901. }
  1902. if ((cxCBEdit + rc.left) > rcWnd.right && cxCBEdit > (LONG)(pTVWnd->cxAveChar * 20)) {
  1903. cxCBEdit = rcWnd.right - rc.left;
  1904. if (cxCBEdit < (LONG)(pTVWnd->cxAveChar * 20)) {
  1905. cxCBEdit = (LONG)(pTVWnd->cxAveChar * 20);
  1906. }
  1907. }
  1908. rc.right = rc.left + cxCBEdit;
  1909. SetWindowPos(pTVWnd->hWndEdit[0] = hLBCB,
  1910. NULL,
  1911. rc.left,
  1912. rc.top,
  1913. rc.right - rc.left,
  1914. tm.tmHeight * 14,
  1915. SWP_NOZORDER | SWP_FRAMECHANGED | SWP_DRAWFRAME);
  1916. CPSUIINT(("LBCB Combo = (%ld, %ld): %ld x %ld",
  1917. rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top));
  1918. SendMessage(hLBCB, CB_SETDROPPEDWIDTH, (WPARAM)cxReal, 0);
  1919. //
  1920. // Following code is only for exposing combo box name in MSAA
  1921. //
  1922. {
  1923. TVITEM tvi;
  1924. HWND hCtrl;
  1925. GSBUF_DEF(pItem, MAX_RES_STR_CHARS);
  1926. tvi.hItem = _OI_HITEM(pItem);
  1927. tvi.mask = TVIF_TEXT;
  1928. tvi.pszText = GSBUF_BUF;
  1929. tvi.cchTextMax = MAX_RES_STR_CHARS;
  1930. if (TreeView_GetItem(pTVWnd->hWndTV, &tvi) && (hCtrl = GetDlgItem(pTVWnd->hWndTV, IDD_TV_MSAA_NAME)))
  1931. {
  1932. SetWindowText(hCtrl, tvi.pszText);
  1933. //
  1934. // Insert the invisible label ahead of the combo box.
  1935. //
  1936. SetWindowPos(hCtrl, hLBCB, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOREDRAW);
  1937. SetWindowPos(hLBCB, hCtrl, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOREDRAW);
  1938. }
  1939. }
  1940. if (pTVWnd->hWndEdit[1]) {
  1941. pTVWnd->chWndEdit = 2;
  1942. rc.left = rc.right + pTVWnd->cxExtAdd;
  1943. rc.right = rc.left + (LONG)_OI_CXEXT(pItem);
  1944. SetWindowPos(pTVWnd->hWndEdit[1],
  1945. hLBCB,
  1946. rc.left,
  1947. rc.top,
  1948. rc.right - rc.left,
  1949. rc.bottom - rc.top + 1, // (LONG)_OI_CYEXTADD(pItem),
  1950. SWP_FRAMECHANGED | SWP_DRAWFRAME);
  1951. } else {
  1952. pTVWnd->chWndEdit = 1;
  1953. }
  1954. pTVWnd->cxEdit = (WORD)(rc.right - OrgL);
  1955. pTVWnd->cxItem = (WORD)(rc.right - pTVWnd->ptCur.x);
  1956. CPSUIINT(("!! cxEdit=%ld, cxItem=%ld, cxMaxItem==%ld",
  1957. pTVWnd->cxEdit, pTVWnd->cxItem, pTVWnd->cxMaxItem));
  1958. }
  1959. #endif
  1960. SelectObject(hDC, hOld);
  1961. ReleaseDC(hLBCB, hDC);
  1962. SendMessage(hLBCB, WM_SETREDRAW, (WPARAM)TRUE, 0L);
  1963. InvalidateRect(hLBCB, NULL, FALSE);
  1964. }
  1965. GSBUF_RESET;
  1966. if ((DWORD)NewSel >= (DWORD)pOptType->Count) {
  1967. GSBUF_GETSTR(pTVWnd->OptParamNone.pData);
  1968. } else {
  1969. GSBUF_GETSTR(pOptType->pOptParam[NewSel].pData);
  1970. }
  1971. if (IsLB) {
  1972. if ((CurSel = (LONG)SendMessage(hLBCB,
  1973. LB_FINDSTRINGEXACT,
  1974. (WPARAM)-1,
  1975. (LPARAM)GSBUF_BUF)) == LB_ERR) {
  1976. CurSel = 0;
  1977. }
  1978. } else {
  1979. if ((CurSel = (LONG)SendMessage(hLBCB,
  1980. CB_FINDSTRINGEXACT,
  1981. (WPARAM)-1,
  1982. (LPARAM)GSBUF_BUF)) == CB_ERR) {
  1983. CurSel = 0;
  1984. }
  1985. }
  1986. _OI_LBCBSELIDX(pItem) = (WORD)CurSel;
  1987. if ((InitFlags & INITCF_INIT) && (!IsLB)) {
  1988. CPSUIDBG(DBG_CBWNDPROC, ("CBPreSel=%ld", CurSel));
  1989. SetProp(hLBCB, CPSUIPROP_CBPRESEL, LongToHandle(CurSel + 1));
  1990. }
  1991. if (((Ret = (LONG)SendMessage(hLBCB,
  1992. (IsLB) ? LB_GETCURSEL : CB_GETCURSEL,
  1993. 0,
  1994. 0)) == LB_ERR) ||
  1995. (Ret != CurSel)) {
  1996. SendMessage(hLBCB, SetCurSelID, (WPARAM)CurSel, 0);
  1997. }
  1998. }
  1999. VOID
  2000. InitEditBox(
  2001. PTVWND pTVWnd,
  2002. HWND hDlg,
  2003. POPTITEM pItem,
  2004. POPTPARAM pOptParam,
  2005. UINT EditBoxID,
  2006. UINT PostfixID,
  2007. UINT HelpID,
  2008. WORD InitItemIdx,
  2009. LPTSTR pCurText,
  2010. WORD InitFlags
  2011. )
  2012. /*++
  2013. Routine Description:
  2014. Arguments:
  2015. Return Value:
  2016. Author:
  2017. 25-Aug-1995 Fri 14:44:59 created -by- Daniel Chou (danielc)
  2018. Revision History:
  2019. --*/
  2020. {
  2021. HWND hCtrl;
  2022. hCtrl = GetDlgItem(hDlg, EditBoxID);
  2023. HCTRL_SETCTRLDATA(hCtrl, CTRLS_EDITBOX, (BYTE)pOptParam[1].IconID);
  2024. HCTRL_STATE(hCtrl, TRUE, SW_SHOW);
  2025. if (InitFlags & INITCF_INIT) {
  2026. RECT rc;
  2027. GSBUF_DEF(pItem, MAX_RES_STR_CHARS);
  2028. GSBUF_FLAGS |= GBF_PREFIX_OK;
  2029. if (hCtrl) {
  2030. SendMessageW(hCtrl,
  2031. EM_SETLIMITTEXT,
  2032. (WPARAM)pOptParam[1].IconID - 1,
  2033. 0L);
  2034. GSBUF_GETSTR(pCurText);
  2035. SetWindowText(hCtrl, GSBUF_BUF);
  2036. }
  2037. #if DO_IN_PLACE
  2038. PostfixID =
  2039. HelpID = 0;
  2040. #endif
  2041. #if DO_IN_PLACE
  2042. if ((IS_TVDLG) &&
  2043. (TreeView_GetItemRect(pTVWnd->hWndTV,
  2044. _OI_HITEM(pItem),
  2045. &rc,
  2046. TRUE))) {
  2047. LONG cxEdit;
  2048. LONG OrgL;
  2049. RECT rcWnd;
  2050. pTVWnd->ptCur.x = rc.left;
  2051. pTVWnd->ptCur.y = rc.top;
  2052. OrgL = rc.right;
  2053. rc.left = rc.right + pTVWnd->cxSelAdd;
  2054. cxEdit = (LONG)(pOptParam[1].IconID - 1) * (LONG)pTVWnd->cxAveChar;
  2055. GetClientRect(pTVWnd->hWndTV, &rcWnd);
  2056. rcWnd.right -= pTVWnd->cxSelAdd;
  2057. if (pTVWnd->hWndEdit[1]) {
  2058. rcWnd.right -= (pTVWnd->cxExtAdd + _OI_CXEXT(pItem));
  2059. }
  2060. if ((cxEdit + rc.left) > rcWnd.right) {
  2061. cxEdit = rcWnd.right - rc.left;
  2062. if (cxEdit < (LONG)(pTVWnd->cxAveChar * 16)) {
  2063. cxEdit = (LONG)(pTVWnd->cxAveChar * 16);
  2064. }
  2065. }
  2066. rc.right = rc.left + cxEdit;
  2067. SetWindowPos(pTVWnd->hWndEdit[0] = hCtrl,
  2068. NULL,
  2069. rc.left,
  2070. rc.top,
  2071. rc.right - rc.left,
  2072. rc.bottom - rc.top + 1,
  2073. SWP_NOZORDER | SWP_FRAMECHANGED | SWP_DRAWFRAME);
  2074. if (pTVWnd->hWndEdit[1]) {
  2075. pTVWnd->chWndEdit = 2;
  2076. rc.left = rc.right + pTVWnd->cxExtAdd;
  2077. rc.right = rc.left + _OI_CXEXT(pItem);
  2078. SetWindowPos(pTVWnd->hWndEdit[1],
  2079. hCtrl,
  2080. rc.left,
  2081. rc.top,
  2082. rc.right - rc.left,
  2083. rc.bottom - rc.top + (LONG)_OI_CYEXTADD(pItem),
  2084. SWP_FRAMECHANGED | SWP_DRAWFRAME);
  2085. } else {
  2086. pTVWnd->chWndEdit = 1;
  2087. }
  2088. pTVWnd->cxEdit = (WORD)(rc.right - OrgL);
  2089. pTVWnd->cxItem = (WORD)(rc.right - pTVWnd->ptCur.x);
  2090. }
  2091. #endif
  2092. ID_TEXTSTATE(PostfixID, pOptParam[0].pData, TRUE, SW_SHOW);
  2093. ID_TEXTSTATE(HelpID, pOptParam[1].pData, TRUE, SW_SHOW);
  2094. }
  2095. }
  2096. VOID
  2097. InitPushButton(
  2098. PTVWND pTVWnd,
  2099. HWND hDlg,
  2100. POPTITEM pItem,
  2101. WORD PushID,
  2102. WORD InitItemIdx,
  2103. WORD InitFlags
  2104. )
  2105. /*++
  2106. Routine Description:
  2107. Arguments:
  2108. Return Value:
  2109. Author:
  2110. 25-Aug-1995 Fri 15:36:54 created -by- Daniel Chou (danielc)
  2111. Revision History:
  2112. --*/
  2113. {
  2114. HWND hPush;
  2115. RECT rc;
  2116. if (hPush = CtrlIDrcWnd(hDlg, PushID, &rc)) {
  2117. SETCTRLDATA(hPush, CTRLS_PUSHBUTTON, 0);
  2118. if (InitFlags & INITCF_INIT) {
  2119. POPTTYPE pOptType;
  2120. GSBUF_DEF(pItem, MAX_RES_STR_CHARS + 40);
  2121. #if (DO_IN_PLACE == 0)
  2122. GSBUF_FLAGS |= GBF_PREFIX_OK;
  2123. #endif
  2124. if ((IS_HDR_PUSH(pOptType = GET_POPTTYPE(pItem))) &&
  2125. (IS_TVDLG)) {
  2126. #if DO_IN_PLACE
  2127. GSBUF_GETSTR(IDS_CPSUI_REVERT);
  2128. #else
  2129. GSBUF_GETINTSTR((pTVWnd->Flags & TWF_ONE_REVERT_ITEM) ?
  2130. IDS_INT_CPSUI_UNDO_OPT :
  2131. IDS_INT_CPSUI_UNDO_OPTS);
  2132. #endif
  2133. } else {
  2134. #if DO_IN_PLACE
  2135. GSBUF_GETSTR((pOptType->Style & OTS_PUSH_INCL_SETUP_TITLE) ?
  2136. IDS_CPSUI_SETUP : IDS_CPSUI_PROPERTIES);
  2137. GSBUF_GETSTR(IDS_CPSUI_MORE);
  2138. #else
  2139. if (pOptType->Style & OTS_PUSH_INCL_SETUP_TITLE) {
  2140. GSBUF_COMPOSE(IDS_INT_CPSUI_SETUP, pItem->pName, 0, 0);
  2141. } else {
  2142. GSBUF_GETSTR(pItem->pName);
  2143. }
  2144. #endif
  2145. }
  2146. #if (DO_IN_PLACE == 0)
  2147. if (!(pOptType->Style & OTS_PUSH_NO_DOT_DOT_DOT)) {
  2148. GSBUF_GETSTR(IDS_CPSUI_MORE);
  2149. }
  2150. if (IS_TVDLG) {
  2151. //
  2152. // Adjust the size of push button
  2153. //
  2154. SetPushSize(pTVWnd,
  2155. hPush,
  2156. GSBUF_BUF,
  2157. GSBUF_COUNT,
  2158. SPSF_USE_BUTTON_CY |
  2159. ((InitFlags & INITCF_HAS_EXT) ?
  2160. SPSF_ALIGN_EXTPUSH : 0));
  2161. }
  2162. #endif
  2163. SetWindowText(hPush, GSBUF_BUF);
  2164. #if DO_IN_PLACE
  2165. if ((IS_TVDLG) &&
  2166. (TreeView_GetItemRect(pTVWnd->hWndTV,
  2167. _OI_HITEM(pItem),
  2168. &rc,
  2169. TRUE))) {
  2170. SIZEL szlText;
  2171. LONG OrgL;
  2172. pTVWnd->ptCur.x = rc.left;
  2173. pTVWnd->ptCur.y = rc.top;
  2174. OrgL = rc.right;
  2175. rc.left = rc.right + pTVWnd->cxSelAdd + 1;
  2176. GetTextExtentPoint(pTVWnd->hDCTVWnd,
  2177. GSBUF_BUF,
  2178. GSBUF_COUNT,
  2179. &szlText);
  2180. rc.right = rc.left + szlText.cx + (LONG)(pTVWnd->cxSpace * 4);
  2181. SetWindowPos(pTVWnd->hWndEdit[0] = hPush,
  2182. NULL,
  2183. rc.left,
  2184. rc.top,
  2185. rc.right - rc.left,
  2186. rc.bottom - rc.top,
  2187. SWP_NOZORDER | SWP_DRAWFRAME | SWP_FRAMECHANGED);
  2188. if (pTVWnd->hWndEdit[1]) {
  2189. pTVWnd->chWndEdit = 2;
  2190. rc.left = rc.right + pTVWnd->cxExtAdd;
  2191. rc.right = rc.left + (LONG)_OI_CXEXT(pItem);
  2192. SetWindowPos(pTVWnd->hWndEdit[1],
  2193. hPush,
  2194. rc.left,
  2195. rc.top,
  2196. rc.right - rc.left,
  2197. rc.bottom - rc.top + (LONG)_OI_CYEXTADD(pItem),
  2198. SWP_FRAMECHANGED | SWP_DRAWFRAME);
  2199. } else {
  2200. pTVWnd->chWndEdit = 1;
  2201. }
  2202. pTVWnd->cxEdit = (WORD)(rc.right - OrgL);
  2203. pTVWnd->cxItem = (WORD)(rc.right - pTVWnd->ptCur.x);
  2204. }
  2205. #endif
  2206. }
  2207. SHOWCTRL(hPush, TRUE, SW_SHOW);
  2208. }
  2209. }
  2210. VOID
  2211. InitChkBox(
  2212. PTVWND pTVWnd,
  2213. HWND hDlg,
  2214. POPTITEM pItem,
  2215. UINT ChkBoxID,
  2216. LPTSTR pTitle,
  2217. WORD InitItemIdx,
  2218. BOOL Checked,
  2219. WORD InitFlags
  2220. )
  2221. /*++
  2222. Routine Description:
  2223. Arguments:
  2224. Return Value:
  2225. Author:
  2226. 25-Aug-1995 Fri 15:41:15 created -by- Daniel Chou (danielc)
  2227. Revision History:
  2228. --*/
  2229. {
  2230. HWND hCtrl;
  2231. RECT rc;
  2232. hCtrl = GetDlgItem(hDlg, ChkBoxID);
  2233. HCTRL_SETCTRLDATA(hCtrl, CTRLS_CHKBOX, 0);
  2234. if (InitFlags & INITCF_INIT) {
  2235. GSBUF_DEF(pItem, MAX_RES_STR_CHARS);
  2236. GSBUF_FLAGS |= GBF_PREFIX_OK;
  2237. HCTRL_TEXT(hCtrl, pTitle);
  2238. #if DO_IN_PLACE
  2239. if ((IS_TVDLG) &&
  2240. (TreeView_GetItemRect(pTVWnd->hWndTV,
  2241. _OI_HITEM(pItem),
  2242. &rc,
  2243. TRUE))) {
  2244. TV_ITEM tvi;
  2245. TVLP tvlp;
  2246. LONG cxChkBox;
  2247. pTVWnd->ptCur.x = rc.left;
  2248. pTVWnd->ptCur.y = rc.top;
  2249. tvi.mask = TVIF_PARAM | TVIF_TEXT;
  2250. tvi.hItem = _OI_HITEM(pItem);
  2251. tvi.pszText = GSBUF_BUF;
  2252. tvi.cchTextMax = MAX_RES_STR_CHARS;
  2253. if (TreeView_GetItem(pTVWnd->hWndTV, &tvi)) {
  2254. HDC hDC;
  2255. HGDIOBJ hOld;
  2256. SIZEL szlText;
  2257. hDC = GetWindowDC(pTVWnd->hWndTV);
  2258. if (hDC) {
  2259. hOld = SelectObject(hDC, (HANDLE)SendMessage(pTVWnd->hWndTV,
  2260. WM_GETFONT,
  2261. 0,
  2262. 0L));
  2263. if (hOld) {
  2264. tvlp = GET_TVLP(tvi.lParam);
  2265. GetTextExtentPoint(hDC, tvi.pszText, tvlp.cName, &szlText);
  2266. rc.left += szlText.cx;
  2267. GetTextExtentPoint(hDC, GSBUF_BUF, GSBUF_COUNT, &szlText);
  2268. cxChkBox = szlText.cx;
  2269. GetTextExtentPoint(hDC, L"M", 1, &szlText);
  2270. cxChkBox += szlText.cx;
  2271. SelectObject(hDC, hOld);
  2272. }
  2273. ReleaseDC(pTVWnd->hWndTV, hDC);
  2274. }
  2275. } else {
  2276. cxChkBox = rc.right - rc.left;
  2277. }
  2278. cxChkBox += pTVWnd->cxChkBoxAdd;
  2279. if ((rc.left + cxChkBox) < rc.right) {
  2280. cxChkBox = rc.right - rc.left;
  2281. }
  2282. SetWindowText(hCtrl, L" ");
  2283. SetWindowPos(pTVWnd->hWndEdit[0] = hCtrl,
  2284. NULL,
  2285. rc.left,
  2286. rc.top,
  2287. cxChkBox,
  2288. rc.bottom - rc.top,
  2289. SWP_NOZORDER | SWP_FRAMECHANGED | SWP_DRAWFRAME);
  2290. if (pTVWnd->hWndEdit[1]) {
  2291. pTVWnd->chWndEdit = 2;
  2292. SetWindowPos(pTVWnd->hWndEdit[1],
  2293. hCtrl,
  2294. rc.left + cxChkBox + pTVWnd->cxExtAdd,
  2295. rc.top,
  2296. (LONG)_OI_CXEXT(pItem),
  2297. rc.bottom - rc.top + (LONG)_OI_CYEXTADD(pItem),
  2298. SWP_FRAMECHANGED | SWP_DRAWFRAME);
  2299. } else {
  2300. pTVWnd->chWndEdit = 1;
  2301. }
  2302. }
  2303. #endif
  2304. }
  2305. HCTRL_STATE(hCtrl, TRUE, SW_SHOW);
  2306. CheckDlgButton(hDlg, ChkBoxID, (Checked) ? BST_CHECKED : BST_UNCHECKED);
  2307. }
  2308. BOOL
  2309. IsItemChangeOnce(
  2310. PTVWND pTVWnd,
  2311. POPTITEM pItem
  2312. )
  2313. /*++
  2314. Routine Description:
  2315. Arguments:
  2316. Return Value:
  2317. Author:
  2318. 18-Sep-1995 Mon 17:43:35 created -by- Daniel Chou (danielc)
  2319. Revision History:
  2320. --*/
  2321. {
  2322. POPTTYPE pOptType;
  2323. POPTPARAM pOptParam;
  2324. PDEVHTADJDATA pDevHTAdjData;
  2325. if (IS_HDR_PUSH(pOptType = GET_POPTTYPE(pItem))) {
  2326. pItem->Flags &= ~OPTIF_CHANGEONCE;
  2327. return(FALSE);
  2328. } else {
  2329. DWORD FlagsAnd = OPTIF_CHANGEONCE;
  2330. DWORD FlagsOr = 0;
  2331. CPSUIINT(("Sel=%08lx, DefSel=%08lx",
  2332. pItem->Sel, _OI_PDEFSEL(pItem)));
  2333. switch (pOptType->Type) {
  2334. case TVOT_EDITBOX:
  2335. if (pTVWnd->Flags & TWF_ANSI_CALL) {
  2336. CPSUIINT(("pEdit=%hs, pDefEdit=%hs",
  2337. pItem->pSel, _OI_PDEFSEL(pItem)));
  2338. if (lstrcmpA((LPSTR)pItem->pSel, (LPSTR)_OI_PDEFSEL(pItem))) {
  2339. FlagsOr = OPTIF_CHANGEONCE;
  2340. }
  2341. } else {
  2342. CPSUIINT(("pEdit=%s, pDefEdit=%s",
  2343. pItem->pSel, (LPTSTR)_OI_PDEFSEL(pItem)));
  2344. if (lstrcmp(pItem->pSel, (LPTSTR)_OI_PDEFSEL(pItem))) {
  2345. FlagsOr = OPTIF_CHANGEONCE;
  2346. }
  2347. }
  2348. break;
  2349. case TVOT_PUSHBUTTON:
  2350. //
  2351. // The push button never changed
  2352. //
  2353. pOptParam = pOptType->pOptParam;
  2354. switch (pOptParam->Style) {
  2355. case PUSHBUTTON_TYPE_HTSETUP:
  2356. pDevHTAdjData = (PDEVHTADJDATA)(pOptParam->pData);
  2357. if (memcmp(_OI_PDEFSEL(pItem),
  2358. pDevHTAdjData->pAdjHTInfo,
  2359. sizeof(DEVHTINFO))) {
  2360. FlagsOr = OPTIF_CHANGEONCE;
  2361. }
  2362. break;
  2363. case PUSHBUTTON_TYPE_HTCLRADJ:
  2364. if (memcmp(_OI_PDEFSEL(pItem),
  2365. pOptParam->pData,
  2366. sizeof(COLORADJUSTMENT))) {
  2367. FlagsOr = OPTIF_CHANGEONCE;
  2368. }
  2369. break;
  2370. default:
  2371. FlagsAnd = 0;
  2372. break;
  2373. }
  2374. break;
  2375. default:
  2376. if (pItem->pSel != (LPVOID)_OI_PDEFSEL(pItem)) {
  2377. FlagsOr = OPTIF_CHANGEONCE;
  2378. }
  2379. break;
  2380. }
  2381. //
  2382. // Now check the extended check box
  2383. //
  2384. if ((pItem->pExtChkBox) &&
  2385. (!(pItem->Flags & OPTIF_EXT_IS_EXTPUSH)) &&
  2386. ((pItem->Flags & OPTIF_ECB_MASK) !=
  2387. (_OI_DEF_OPTIF(pItem) & OPTIF_ECB_MASK))) {
  2388. FlagsOr = OPTIF_CHANGEONCE;
  2389. }
  2390. pItem->Flags &= ~FlagsAnd;
  2391. pItem->Flags |= FlagsOr;
  2392. return((BOOL)FlagsOr);
  2393. }
  2394. }
  2395. UINT
  2396. InternalDMPUB_COPIES_COLLATE(
  2397. HWND hDlg,
  2398. PTVWND pTVWnd,
  2399. POPTITEM pItem
  2400. )
  2401. /*++
  2402. Routine Description:
  2403. Arguments:
  2404. Return Value:
  2405. Author:
  2406. 18-Sep-1995 Mon 15:11:07 created -by- Daniel Chou (danielc)
  2407. Revision History:
  2408. --*/
  2409. {
  2410. HWND hCtrl;
  2411. LONG Sel;
  2412. UINT CtrlID;
  2413. BOOL IsTVDlg;
  2414. Sel = pItem->Sel;
  2415. //
  2416. // Now check the copies or copy end text
  2417. //
  2418. if (IsTVDlg = (BOOL)(pTVWnd->Flags & TWF_IN_TVPAGE)) {
  2419. CtrlID = IDD_TV_UDARROW_ENDTEXT;
  2420. } else {
  2421. CtrlID = (UINT)(pItem->pOptType->BegCtrlID + 4);
  2422. }
  2423. if (hCtrl = GetDlgItem(hDlg, CtrlID)) {
  2424. LPTSTR pData;
  2425. pData = (LPTSTR)((ULONG_PTR)((Sel > 1) ? IDS_CPSUI_COPIES : IDS_CPSUI_COPY));
  2426. if (pData != pItem->pOptType->pOptParam[0].pData) {
  2427. GSBUF_DEF(pItem, MAX_RES_STR_CHARS);
  2428. GSBUF_FLAGS |= GBF_PREFIX_OK;
  2429. GSBUF_GETSTR(pData);
  2430. SetWindowText(hCtrl, GSBUF_BUF);
  2431. //
  2432. // We also have set the ID here
  2433. //
  2434. pItem->pOptType->pOptParam[0].pData = pData;
  2435. }
  2436. }
  2437. //
  2438. // ONLY DO THIS IF THE ITEM IS CHANGABLE
  2439. //
  2440. if ((pTVWnd->Flags & TWF_CAN_UPDATE) &&
  2441. (!(pItem->Flags & (OPTIF_EXT_HIDE |
  2442. #if DO_IN_PLACE
  2443. OPTIF_HIDE |
  2444. #else
  2445. OPTIF_ITEM_HIDE |
  2446. #endif
  2447. OPTIF_DISABLED))) &&
  2448. (pItem->pExtChkBox)) {
  2449. DWORD dw;
  2450. dw = (Sel <= 1) ? OPTIF_EXT_DISABLED : 0;
  2451. if ((pItem->Flags & OPTIF_EXT_DISABLED) != dw) {
  2452. pItem->Flags ^= OPTIF_EXT_DISABLED;
  2453. pItem->Flags |= OPTIF_CHANGED;
  2454. CtrlID = (UINT)((IsTVDlg) ? IDD_TV_EXTCHKBOX :
  2455. pItem->pOptType->BegCtrlID + 7);
  2456. if (hCtrl = GetDlgItem(hDlg, CtrlID)) {
  2457. EnableWindow(hCtrl, !(BOOL)(pItem->Flags & OPTIF_EXT_DISABLED));
  2458. }
  2459. CPSUIINT(("InternalDMPUB_COPIES_COLLATE(Enable=%u)", (dw) ? 1 : 0));
  2460. return(INTDMPUB_CHANGED);
  2461. }
  2462. }
  2463. CPSUIINT(("InternalDMPUB_COPIES_COLLATE(), NO Changes"));
  2464. return(0);
  2465. }
  2466. UINT
  2467. InternalDMPUB_QUALITY(
  2468. HWND hDlg,
  2469. PTVWND pTVWnd,
  2470. POPTITEM pQuality
  2471. )
  2472. /*++
  2473. Routine Description:
  2474. Arguments:
  2475. Return Value:
  2476. Author:
  2477. 18-Sep-1995 Mon 16:03:45 created -by- Daniel Chou (danielc)
  2478. Revision History:
  2479. --*/
  2480. {
  2481. UINT Result = 0;
  2482. if (pTVWnd->Flags & TWF_CAN_UPDATE) {
  2483. POPTPARAM pParam = pQuality->pOptType->pOptParam;
  2484. INT Count = pQuality->pOptType->Count;
  2485. BOOL bChecked = (pQuality->Flags & OPTIF_ECB_CHECKED) ? TRUE: FALSE;
  2486. while (Count--) {
  2487. if (bChecked){
  2488. pParam->Flags |= OPTPF_DISABLED;
  2489. } else {
  2490. if (pParam->dwReserved[0] == FALSE)
  2491. pParam->Flags &=~OPTPF_DISABLED;
  2492. }
  2493. pParam++;
  2494. }
  2495. pQuality->Flags |= OPTIF_CHANGED;
  2496. Result |= INTDMPUB_CHANGED;
  2497. }
  2498. CPSUIINT(("InternalDMPUB_QUALITY(), Result=%04lx", Result));
  2499. return(Result);
  2500. }
  2501. UINT
  2502. InternalDMPUB_COLOR(
  2503. HWND hDlg,
  2504. PTVWND pTVWnd,
  2505. POPTITEM pItemColor
  2506. )
  2507. /*++
  2508. Routine Description:
  2509. Arguments:
  2510. Return Value:
  2511. Author:
  2512. 18-Sep-1995 Mon 16:03:45 created -by- Daniel Chou (danielc)
  2513. Revision History:
  2514. --*/
  2515. {
  2516. UINT Result = 0;
  2517. if (pTVWnd->Flags & TWF_CAN_UPDATE) {
  2518. POPTITEM pICMItem;
  2519. UINT DMPubID;
  2520. DWORD dw;
  2521. UINT Idx;
  2522. UINT i;
  2523. dw = (pItemColor->Sel >= 1) ? 0 : OPTIF_DISABLED;
  2524. i = 2;
  2525. DMPubID = DMPUB_ICMINTENT;
  2526. while (i--) {
  2527. if (pICMItem = GET_PITEMDMPUB(pTVWnd, DMPubID, Idx)) {
  2528. if ((pICMItem->Flags & OPTIF_DISABLED) != dw) {
  2529. pICMItem->Flags ^= OPTIF_DISABLED;
  2530. pICMItem->Flags |= OPTIF_CHANGED;
  2531. Result |= INTDMPUB_CHANGED;
  2532. }
  2533. }
  2534. DMPubID = DMPUB_ICMMETHOD;
  2535. }
  2536. }
  2537. CPSUIINT(("InternalDMPUB_COLOR(), Result=%04lx", Result));
  2538. return(Result);
  2539. }
  2540. UINT
  2541. InternalDMPUB_ORIENTATION(
  2542. HWND hDlg,
  2543. PTVWND pTVWnd,
  2544. POPTITEM pItem
  2545. )
  2546. /*++
  2547. Routine Description:
  2548. Arguments:
  2549. Return Value:
  2550. Author:
  2551. 07-Nov-1995 Tue 12:49:59 created -by- Daniel Chou (danielc)
  2552. Revision History:
  2553. --*/
  2554. {
  2555. POPTITEM pOIDuplex;
  2556. UINT Idx;
  2557. UINT Result = 0;
  2558. DWORD DuplexIcon[] = { IDI_CPSUI_DUPLEX_NONE,
  2559. IDI_CPSUI_DUPLEX_HORZ,
  2560. IDI_CPSUI_DUPLEX_VERT,
  2561. IDI_CPSUI_DUPLEX_NONE_L,
  2562. IDI_CPSUI_DUPLEX_HORZ_L,
  2563. IDI_CPSUI_DUPLEX_VERT_L };
  2564. if ((pTVWnd->Flags & TWF_CAN_UPDATE) &&
  2565. (pOIDuplex = GET_PITEMDMPUB(pTVWnd, DMPUB_DUPLEX, Idx))) {
  2566. LPDWORD pdwID1;
  2567. LPDWORD pdwID2;
  2568. POPTPARAM pOPDuplex;
  2569. UINT Count;
  2570. if ((pItem->pOptType->pOptParam + pItem->Sel)->IconID ==
  2571. IDI_CPSUI_PORTRAIT) {
  2572. //
  2573. // Portrait;
  2574. //
  2575. pdwID1 = &DuplexIcon[3];
  2576. pdwID2 = DuplexIcon;
  2577. } else {
  2578. //
  2579. // Landscape;
  2580. //
  2581. pdwID1 = DuplexIcon;
  2582. pdwID2 = &DuplexIcon[3];
  2583. }
  2584. pOPDuplex = pOIDuplex->pOptType->pOptParam;
  2585. Count = pOIDuplex->pOptType->Count;
  2586. while (Count--) {
  2587. DWORD IconIDOld;
  2588. DWORD IconIDCur;
  2589. IconIDOld =
  2590. IconIDCur = (DWORD)pOPDuplex->IconID;
  2591. if (IconIDOld == pdwID1[0]) {
  2592. IconIDCur = pdwID2[0];
  2593. } else if (IconIDOld == pdwID1[1]) {
  2594. IconIDCur = pdwID2[1];
  2595. } else if (IconIDOld == pdwID1[2]) {
  2596. IconIDCur = pdwID2[2];
  2597. }
  2598. if (IconIDCur != IconIDOld) {
  2599. pOPDuplex->IconID = IconIDCur;
  2600. Result |= INTDMPUB_REINIT;
  2601. }
  2602. pOPDuplex++;
  2603. }
  2604. if (Result) {
  2605. pOIDuplex->Flags |= OPTIF_CHANGED;
  2606. }
  2607. }
  2608. CPSUIINT(("InternalDMPUB_ORIENTATION(), Result=%04lx", Result));
  2609. return(Result);
  2610. }
  2611. UINT
  2612. UpdateInternalDMPUB(
  2613. HWND hDlg,
  2614. PTVWND pTVWnd,
  2615. POPTITEM pItem
  2616. )
  2617. /*++
  2618. Routine Description:
  2619. Arguments:
  2620. Return Value:
  2621. Author:
  2622. 18-Sep-1995 Mon 15:52:09 created -by- Daniel Chou (danielc)
  2623. Revision History:
  2624. --*/
  2625. {
  2626. HWND hParent;
  2627. hParent = (pTVWnd->Flags & TWF_IN_TVPAGE) ? pTVWnd->hWndTV : hDlg;
  2628. switch (pItem->DMPubID) {
  2629. case DMPUB_COPIES_COLLATE:
  2630. return(InternalDMPUB_COPIES_COLLATE(hParent, pTVWnd, pItem));
  2631. case DMPUB_COLOR:
  2632. return(InternalDMPUB_COLOR(hParent, pTVWnd, pItem));
  2633. case DMPUB_ORIENTATION:
  2634. return(InternalDMPUB_ORIENTATION(hParent, pTVWnd, pItem));
  2635. case DMPUB_QUALITY:
  2636. return (InternalDMPUB_QUALITY(hParent, pTVWnd, pItem));
  2637. default:
  2638. return(0);
  2639. }
  2640. }
  2641. LONG
  2642. UpdateCallBackChanges(
  2643. HWND hDlg,
  2644. PTVWND pTVWnd,
  2645. BOOL ReInit
  2646. )
  2647. /*++
  2648. Routine Description:
  2649. Arguments:
  2650. Return Value:
  2651. Author:
  2652. 23-Aug-1995 Wed 19:05:53 created -by- Daniel Chou (danielc)
  2653. Revision History:
  2654. --*/
  2655. {
  2656. PMYDLGPAGE pMyDP;
  2657. PMYDLGPAGE pCurMyDP;
  2658. POPTITEM pItem;
  2659. WORD MyDPFlags;
  2660. UINT cItem;
  2661. UINT DlgPageIdx;
  2662. UINT TVPageIdx;
  2663. INT cUpdated = 0;
  2664. pCurMyDP = GET_PMYDLGPAGE(hDlg);
  2665. pMyDP = pTVWnd->pMyDlgPage;
  2666. TVPageIdx = (UINT)pTVWnd->TVPageIdx;
  2667. pItem = pTVWnd->ComPropSheetUI.pOptItem;
  2668. cItem = (UINT)pTVWnd->ComPropSheetUI.cOptItem;
  2669. while (cItem--) {
  2670. BYTE DMPubID;
  2671. if (((DMPubID = pItem->DMPubID) >= DMPUB_FIRST) &&
  2672. (DMPubID <= DMPUB_LAST)) {
  2673. if (UpdateInternalDMPUB(hDlg, pTVWnd, pItem) & INTDMPUB_REINIT) {
  2674. ReInit = TRUE;
  2675. }
  2676. }
  2677. pItem++;
  2678. }
  2679. pItem = pTVWnd->ComPropSheetUI.pOptItem;
  2680. cItem = (UINT)pTVWnd->ComPropSheetUI.cOptItem;
  2681. MyDPFlags = MYDPF_CHANGED | MYDPF_CHANGEONCE | ((ReInit) ? MYDPF_REINIT :
  2682. 0);
  2683. while (cItem--) {
  2684. if (pItem->Flags & OPTIF_CHANGED) {
  2685. #if 0
  2686. if ((pItem->Flags & (OPTIF_CHANGED | OPTIF_INT_HIDE)) ==
  2687. OPTIF_CHANGED) {
  2688. #endif
  2689. DlgPageIdx = (UINT)pItem->DlgPageIdx;
  2690. pMyDP[DlgPageIdx].Flags |= MyDPFlags;
  2691. //
  2692. // turn off the CHANGEONCE flags if it change back
  2693. //
  2694. IsItemChangeOnce(pTVWnd, pItem);
  2695. pItem->Flags |= OPTIF_INT_TV_CHANGED;
  2696. if (DlgPageIdx != TVPageIdx) {
  2697. pItem->Flags |= OPTIF_INT_CHANGED;
  2698. }
  2699. pItem->Flags &= ~OPTIF_CHANGED;
  2700. ++cUpdated;
  2701. }
  2702. pItem++;
  2703. }
  2704. if ((cUpdated) && (TVPageIdx != PAGEIDX_NONE)) {
  2705. pMyDP[TVPageIdx].Flags |= MyDPFlags;
  2706. }
  2707. //
  2708. // Now if this page is need to change, then change it now
  2709. //
  2710. if (pCurMyDP->Flags & MYDPF_CHANGED) {
  2711. if (pCurMyDP->PageIdx == TVPageIdx) {
  2712. UpdateTreeView(hDlg, pCurMyDP);
  2713. } else {
  2714. UpdatePropPage(hDlg, pCurMyDP);
  2715. }
  2716. }
  2717. CPSUIDBG(DBG_UCBC, ("CallBack cUpdated=%ld", (DWORD)cUpdated));
  2718. SET_APPLY_BUTTON(pTVWnd, hDlg);
  2719. return((LONG)cUpdated);
  2720. }
  2721. LRESULT
  2722. CALLBACK
  2723. AboutPosDlgProc(
  2724. HWND hDlg,
  2725. UINT Msg,
  2726. WPARAM wParam,
  2727. LPARAM lParam
  2728. )
  2729. {
  2730. PABOUTPOS pAP;
  2731. RECT rc;
  2732. switch(Msg) {
  2733. case WM_INITDIALOG:
  2734. SetWindowLongPtr(hDlg, GWLP_USERDATA, lParam);
  2735. pAP = (PABOUTPOS)lParam;
  2736. GetWindowRect(hDlg, &rc);
  2737. rc.left = (LONG)LOWORD(pAP->Pos) - ((rc.right - rc.left) / 2);
  2738. rc.top = (LONG)HIWORD(pAP->Pos) - ((rc.bottom - rc.top) / 2);
  2739. SetWindowPos(hDlg,
  2740. NULL,
  2741. rc.left,
  2742. rc.top,
  2743. 0, 0,
  2744. SWP_NOSIZE | SWP_NOZORDER);
  2745. pAP->pCBParam->hDlg = hDlg;
  2746. pAP->pfnCallBack(pAP->pCBParam);
  2747. EndDialog(hDlg, 0);
  2748. return(TRUE);
  2749. }
  2750. return(FALSE);
  2751. }
  2752. LONG
  2753. DoCallBack(
  2754. HWND hDlg,
  2755. PTVWND pTVWnd,
  2756. POPTITEM pItem,
  2757. LPVOID pOldSel,
  2758. _CPSUICALLBACK pfnCallBack,
  2759. HANDLE hDlgTemplate,
  2760. WORD DlgTemplateID,
  2761. WORD Reason
  2762. )
  2763. /*++
  2764. Routine Description:
  2765. Arguments:
  2766. Return Value:
  2767. Author:
  2768. 25-Aug-1995 Fri 21:09:08 created -by- Daniel Chou (danielc)
  2769. Revision History:
  2770. --*/
  2771. {
  2772. PMYDLGPAGE pCurMyDP;
  2773. PPSPINFO pPSPInfo;
  2774. LONG Ret = CPSUICB_ACTION_NONE;
  2775. ULONG_PTR Result;
  2776. BOOL DoSetResult = FALSE;
  2777. if (!(pCurMyDP = GET_PMYDLGPAGE(hDlg))) {
  2778. CPSUIERR(("hDlg=%08lx, pCurMyDP=NULL", hDlg));
  2779. return(CPSUICB_ACTION_NONE);
  2780. }
  2781. if (!(pPSPInfo = pCurMyDP->pPSPInfo)) {
  2782. CPSUIERR(("hDlg=%08lx, pCurMyDP->pPSPInfo=NULL", hDlg));
  2783. return(CPSUICB_ACTION_NONE);
  2784. }
  2785. if ((!hDlgTemplate) && (!DlgTemplateID)) {
  2786. if (!pfnCallBack) {
  2787. pfnCallBack = pTVWnd->ComPropSheetUI.pfnCallBack;
  2788. }
  2789. }
  2790. if (pfnCallBack) {
  2791. HWND hFocus;
  2792. POPTTYPE pOptType;
  2793. CPSUICBPARAM CBParam;
  2794. BOOL SetNewDef;
  2795. if (Reason == CPSUICB_REASON_APPLYNOW) {
  2796. SetNewDef = (pItem) ? TRUE : FALSE;
  2797. pItem = pTVWnd->ComPropSheetUI.pOptItem;
  2798. }
  2799. CPSUIOPTITEM(DBGITEM_CB, pTVWnd, "CallBack Item", 2, pItem);
  2800. CPSUIDBG(DBG_DOCB, ("pfnCallBack=%08lx, CALLBACK READSON=%ld",
  2801. pfnCallBack, Reason));
  2802. if (Reason == CPSUICB_REASON_ABOUT) {
  2803. DlgTemplateID = DLGABOUT;
  2804. }
  2805. if (!(hFocus = GetFocus())) {
  2806. hFocus = hDlg;
  2807. }
  2808. pOptType = GET_POPTTYPE(pItem);
  2809. CBParam.cbSize = sizeof(CPSUICBPARAM);
  2810. CBParam.Reason = Reason;
  2811. CBParam.hDlg = hDlg;
  2812. CBParam.pOptItem = pTVWnd->ComPropSheetUI.pOptItem;
  2813. CBParam.cOptItem = pTVWnd->ComPropSheetUI.cOptItem;
  2814. CBParam.Flags = pTVWnd->ComPropSheetUI.Flags;
  2815. CBParam.pCurItem = pItem;
  2816. CBParam.pOldSel = pOldSel;
  2817. CBParam.UserData = pTVWnd->ComPropSheetUI.UserData;
  2818. CBParam.Result = CPSUI_OK;
  2819. if ((hDlgTemplate) ||
  2820. (DlgTemplateID)) {
  2821. if (hDlgTemplate) {
  2822. try {
  2823. DialogBoxIndirectParam(_OI_HINST(pItem),
  2824. (LPDLGTEMPLATE)hDlgTemplate,
  2825. hDlg,
  2826. (DLGPROC)pfnCallBack,
  2827. (LPARAM)&CBParam);
  2828. } except (FilterException(pPSPInfo->hComPropSheet,
  2829. GetExceptionInformation())) {
  2830. CPSUIERR(("DialogBoxIndirectParam(%08lx), Exception", pfnCallBack));
  2831. }
  2832. } else {
  2833. if (Reason == CPSUICB_REASON_ABOUT) {
  2834. ABOUTPOS AP;
  2835. AP.pfnCallBack = pfnCallBack;
  2836. AP.pCBParam = &CBParam;
  2837. AP.hFocus = hFocus;
  2838. AP.Pos = pTVWnd->MousePos;
  2839. CPSUIINT(("AboutPosDlg: Pos=(%ld, %ld), hDlg=%08lx (%ld), hFocus=%08lx (%ld)",
  2840. (LONG)LOWORD(pTVWnd->MousePos),
  2841. (LONG)HIWORD(pTVWnd->MousePos),
  2842. hDlg, GetWindowLongPtr(hDlg, GWLP_ID),
  2843. hFocus, GetWindowLongPtr(hFocus, GWLP_ID)));
  2844. try {
  2845. DialogBoxParam(hInstDLL,
  2846. MAKEINTRESOURCE(DLGABOUT),
  2847. hDlg,
  2848. (DLGPROC)AboutPosDlgProc,
  2849. (LPARAM)&AP);
  2850. } except (FilterException(pPSPInfo->hComPropSheet,
  2851. GetExceptionInformation())) {
  2852. CPSUIERR(("DialogBoxParam(ABOUTPOS: %08lx), Exception", pfnCallBack));
  2853. }
  2854. } else {
  2855. try {
  2856. DialogBoxParam(_OI_HINST(pItem),
  2857. (LPCTSTR)MAKEINTRESOURCE(DlgTemplateID),
  2858. hDlg,
  2859. (DLGPROC)pfnCallBack,
  2860. (LPARAM)&CBParam);
  2861. } except (FilterException(pPSPInfo->hComPropSheet,
  2862. GetExceptionInformation())) {
  2863. CPSUIERR(("DialogBoxParam(%08lx), Exception", pfnCallBack));
  2864. }
  2865. }
  2866. }
  2867. } else {
  2868. HCURSOR hCursor;
  2869. if (Reason == CPSUICB_REASON_APPLYNOW) {
  2870. hCursor = SetCursor(LoadCursor(NULL,
  2871. (LPCTSTR)(ULONG_PTR)IDC_WAIT));
  2872. }
  2873. try {
  2874. Ret = pfnCallBack(&CBParam);
  2875. } except (FilterException(pPSPInfo->hComPropSheet,
  2876. GetExceptionInformation())) {
  2877. CPSUIERR(("pfnCallBack 1=%08lx, Exception", pfnCallBack));
  2878. Ret = CPSUICB_ACTION_NONE;
  2879. }
  2880. if (Reason == CPSUICB_REASON_APPLYNOW) {
  2881. SetCursor(hCursor);
  2882. if (Ret != CPSUICB_ACTION_NO_APPLY_EXIT) {
  2883. DoSetResult = TRUE;
  2884. Result = CBParam.Result;
  2885. //
  2886. // Save the new setting to as current default and also call
  2887. // common UI to set the result to the original caller
  2888. //
  2889. if (SetNewDef) {
  2890. CPSUIDBG(DBG_DOCB,
  2891. ("*APPLYNOW=%ld, SET NEW DEFAULT", Ret));
  2892. SetOptItemNewDef(hDlg, pTVWnd, FALSE);
  2893. }
  2894. }
  2895. }
  2896. }
  2897. if ((pTVWnd->Flags & TWF_CAN_UPDATE) &&
  2898. ((Ret == CPSUICB_ACTION_OPTIF_CHANGED) ||
  2899. (Ret == CPSUICB_ACTION_REINIT_ITEMS))) {
  2900. CPSUIDBG(DBG_DOCB, ("CallBack()=OPTIF_CHANGED=%ld", Ret));
  2901. if (((IS_HDR_PUSH(pOptType)) ||
  2902. (Reason == CPSUICB_REASON_ITEMS_REVERTED)) &&
  2903. (pfnCallBack = pTVWnd->ComPropSheetUI.pfnCallBack)) {
  2904. CPSUIINT(("CPSUICB_REASON_ITEMS_REVERTED CallBack"));
  2905. CBParam.cbSize = sizeof(CPSUICBPARAM);
  2906. CBParam.Reason = CPSUICB_REASON_ITEMS_REVERTED;
  2907. CBParam.hDlg = hDlg;
  2908. CBParam.pOptItem = pTVWnd->ComPropSheetUI.pOptItem;
  2909. CBParam.cOptItem = pTVWnd->ComPropSheetUI.cOptItem;
  2910. CBParam.Flags = pTVWnd->ComPropSheetUI.Flags;
  2911. CBParam.pCurItem = CBParam.pOptItem;
  2912. CBParam.OldSel = pTVWnd->ComPropSheetUI.cOptItem;
  2913. CBParam.UserData = pTVWnd->ComPropSheetUI.UserData;
  2914. CBParam.Result = CPSUI_OK;
  2915. //
  2916. // This is the header push callback, so let the caller know
  2917. //
  2918. try {
  2919. pfnCallBack(&CBParam);
  2920. } except (FilterException(pPSPInfo->hComPropSheet,
  2921. GetExceptionInformation())) {
  2922. CPSUIERR(("pfnCallBack 2=%08lx, Exception", pfnCallBack));
  2923. Ret = CPSUICB_ACTION_NONE;
  2924. }
  2925. Ret = CPSUICB_ACTION_REINIT_ITEMS;
  2926. }
  2927. UpdateCallBackChanges(hDlg,
  2928. pTVWnd,
  2929. Ret == CPSUICB_ACTION_REINIT_ITEMS);
  2930. }
  2931. } else if (Reason == CPSUICB_REASON_APPLYNOW) {
  2932. //
  2933. // If the caller does not hook this, then we will call to set it
  2934. // to its owner's parent ourself
  2935. //
  2936. DoSetResult = TRUE;
  2937. Result = CPSUI_OK;
  2938. }
  2939. //
  2940. // Now propage the result to the owner
  2941. //
  2942. if (DoSetResult) {
  2943. pPSPInfo->pfnComPropSheet(pPSPInfo->hComPropSheet,
  2944. CPSFUNC_SET_RESULT,
  2945. (LPARAM)pPSPInfo->hCPSUIPage,
  2946. Result);
  2947. }
  2948. return(Ret);
  2949. }
  2950. LRESULT
  2951. CALLBACK
  2952. AboutDlgProc(
  2953. HWND hDlg,
  2954. UINT Msg,
  2955. WPARAM wParam,
  2956. LPARAM lParam
  2957. )
  2958. {
  2959. ABOUTINFO AI;
  2960. PTVWND pTVWnd;
  2961. HICON hIcon;
  2962. LPVOID pvAlloc = NULL;
  2963. LPWSTR pwsz;
  2964. VS_FIXEDFILEINFO *pvsf;
  2965. WCHAR wBuf[MAX_RES_STR_CHARS * 2];
  2966. DWORD dw;
  2967. WORD Version;
  2968. UINT cChar;
  2969. switch(Msg) {
  2970. case WM_INITDIALOG:
  2971. AI = *(PABOUTINFO)lParam;
  2972. pTVWnd = AI.pTVWnd;
  2973. hIcon = AI.hIcon;
  2974. GetModuleFileName(pTVWnd->hInstCaller, wBuf, COUNT_ARRAY(wBuf));
  2975. if ((dw = GetFileVersionInfoSize(wBuf, &dw)) &&
  2976. (pvAlloc = (LPVOID)LocalAlloc(LPTR, dw))) {
  2977. GetFileVersionInfo(wBuf, 0, dw, pvAlloc);
  2978. }
  2979. //
  2980. // Compose Caller Name / Version
  2981. //
  2982. cChar = GetWindowText(hDlg, wBuf, COUNT_ARRAY(wBuf));
  2983. wBuf[cChar++] = L' ';
  2984. cChar += GetStringBuffer(pTVWnd->hInstCaller,
  2985. (WORD)(GBF_PREFIX_OK |
  2986. GBF_INT_NO_PREFIX |
  2987. ((pTVWnd->Flags & TWF_ANSI_CALL) ?
  2988. GBF_ANSI_CALL : 0)),
  2989. L'\0',
  2990. pTVWnd->ComPropSheetUI.pCallerName,
  2991. &wBuf[cChar],
  2992. COUNT_ARRAY(wBuf) - cChar - 1);
  2993. SetWindowText(hDlg, wBuf);
  2994. Version = pTVWnd->ComPropSheetUI.CallerVersion;
  2995. cChar = ComposeStrData(pTVWnd->hInstCaller,
  2996. (WORD)(GBF_PREFIX_OK |
  2997. GBF_INT_NO_PREFIX |
  2998. ((pTVWnd->Flags & TWF_ANSI_CALL) ?
  2999. GBF_ANSI_CALL : 0)),
  3000. wBuf,
  3001. COUNT_ARRAY(wBuf),
  3002. (Version) ? IDS_INT_CPSUI_VERSION : 0,
  3003. pTVWnd->ComPropSheetUI.pCallerName,
  3004. HIBYTE(Version),
  3005. LOBYTE(Version));
  3006. SetDlgItemText(hDlg, IDS_ABOUT_CALLER, wBuf);
  3007. GetModuleFileName(pTVWnd->hInstCaller, wBuf, COUNT_ARRAY(wBuf));
  3008. if (pvAlloc) {
  3009. VerQueryValue(pvAlloc, L"\\", &pvsf, &dw);
  3010. pwsz = NULL;
  3011. VerQueryValue(pvAlloc,
  3012. L"\\StringFileInfo\\040904B0\\ProductName",
  3013. &pwsz,
  3014. &dw);
  3015. if (pwsz) {
  3016. SetDlgItemText(hDlg, IDS_ABOUT_PRODUCT, pwsz);
  3017. }
  3018. cChar = GetDlgItemText(hDlg,
  3019. IDS_ABOUT_CALLER,
  3020. wBuf,
  3021. COUNT_ARRAY(wBuf));
  3022. wsprintf(&wBuf[cChar], L" (%u.%u:%u.%u)",
  3023. HIWORD(pvsf->dwProductVersionMS),
  3024. LOWORD(pvsf->dwProductVersionMS),
  3025. HIWORD(pvsf->dwProductVersionLS),
  3026. LOWORD(pvsf->dwProductVersionLS));
  3027. SetDlgItemText(hDlg, IDS_ABOUT_CALLER, wBuf);
  3028. pwsz = NULL;
  3029. VerQueryValue(pvAlloc,
  3030. L"\\StringFileInfo\\040904B0\\LegalCopyright",
  3031. &pwsz,
  3032. &dw);
  3033. if (pwsz) {
  3034. SetDlgItemText(hDlg, IDS_ABOUT_COPYRIGHT, pwsz);
  3035. }
  3036. }
  3037. //
  3038. // OPTITEM NAME VERSION
  3039. //
  3040. Version = pTVWnd->ComPropSheetUI.OptItemVersion;
  3041. ComposeStrData(pTVWnd->hInstCaller,
  3042. (WORD)(GBF_PREFIX_OK |
  3043. GBF_INT_NO_PREFIX |
  3044. ((pTVWnd->Flags & TWF_ANSI_CALL) ?
  3045. GBF_ANSI_CALL : 0)),
  3046. wBuf,
  3047. COUNT_ARRAY(wBuf),
  3048. (Version) ? IDS_INT_CPSUI_VERSION : 0,
  3049. pTVWnd->ComPropSheetUI.pOptItemName,
  3050. HIBYTE(Version),
  3051. LOBYTE(Version));
  3052. SetDlgItemText(hDlg, IDS_ABOUT_OPTITEM, wBuf);
  3053. SendMessage(GetDlgItem(hDlg, IDI_ABOUT_ICON),
  3054. STM_SETIMAGE,
  3055. (WPARAM)IMAGE_ICON,
  3056. (LPARAM)hIcon);
  3057. if (pvAlloc) {
  3058. LocalFree(pvAlloc);
  3059. }
  3060. if (AI.Pos) {
  3061. RECT rc;
  3062. GetWindowRect(hDlg, &rc);
  3063. rc.left = (LONG)LOWORD(AI.Pos) - ((rc.right - rc.left) / 2);
  3064. rc.top = (LONG)HIWORD(AI.Pos) - ((rc.bottom - rc.top) / 2);
  3065. SetWindowPos(hDlg,
  3066. NULL,
  3067. rc.left,
  3068. rc.top,
  3069. 0, 0,
  3070. SWP_NOSIZE | SWP_NOZORDER);
  3071. }
  3072. return(TRUE);
  3073. case WM_COMMAND:
  3074. switch (LOWORD(wParam)) {
  3075. case IDOK:
  3076. case IDCANCEL:
  3077. EndDialog(hDlg, 0);
  3078. return(TRUE);
  3079. }
  3080. break;
  3081. }
  3082. return(FALSE);
  3083. }
  3084. BOOL
  3085. DoAbout(
  3086. HWND hDlg,
  3087. PTVWND pTVWnd,
  3088. POPTITEM pItemRoot
  3089. )
  3090. /*++
  3091. Routine Description:
  3092. This function pop up the about dialog box
  3093. Arguments:
  3094. Return Value:
  3095. Author:
  3096. 09-Oct-1995 Mon 13:10:41 created -by- Daniel Chou (danielc)
  3097. Revision History:
  3098. --*/
  3099. {
  3100. HICON hIcon;
  3101. HICON hIconLoad = NULL;
  3102. ABOUTINFO AI;
  3103. ULONG_PTR IconID;
  3104. BOOL bRet;
  3105. if (pTVWnd->ComPropSheetUI.Flags & CPSUIF_ABOUT_CALLBACK) {
  3106. DoCallBack(hDlg,
  3107. pTVWnd,
  3108. pTVWnd->ComPropSheetUI.pOptItem,
  3109. (LPVOID)pTVWnd->pCPSUI,
  3110. NULL,
  3111. NULL,
  3112. 0,
  3113. CPSUICB_REASON_ABOUT);
  3114. return(TRUE);
  3115. }
  3116. IconID = GETSELICONID(pItemRoot);
  3117. if (VALID_PTR(IconID)) {
  3118. hIcon = GET_HICON(IconID);
  3119. } else {
  3120. hIconLoad =
  3121. hIcon = GETICON(_OI_HINST(pItemRoot), LODWORD(IconID));
  3122. }
  3123. AI.pTVWnd = pTVWnd;
  3124. AI.hIcon = hIcon;
  3125. AI.Pos = pTVWnd->MousePos;
  3126. bRet = DialogBoxParam(hInstDLL,
  3127. MAKEINTRESOURCE(DLGABOUT),
  3128. hDlg,
  3129. (DLGPROC)AboutDlgProc,
  3130. (LPARAM)&AI) ? TRUE : FALSE;
  3131. if (hIconLoad) {
  3132. DestroyIcon(hIconLoad);
  3133. }
  3134. return(bRet);
  3135. }
  3136. LONG
  3137. DoPushButton(
  3138. HWND hDlg,
  3139. PTVWND pTVWnd,
  3140. POPTITEM pItem
  3141. )
  3142. /*++
  3143. Routine Description:
  3144. Arguments:
  3145. Return Value:
  3146. Author:
  3147. 25-Aug-1995 Fri 20:57:42 created -by- Daniel Chou (danielc)
  3148. Revision History:
  3149. --*/
  3150. {
  3151. ULONG_PTR ulCookie = 0;
  3152. PMYDLGPAGE pCurMyDP;
  3153. PPSPINFO pPSPInfo;
  3154. HINSTANCE hInst = NULL;
  3155. FARPROC farproc;
  3156. POPTTYPE pOptType;
  3157. POPTPARAM pOptParam;
  3158. DEVHTADJDATA DevHTAdjData;
  3159. LONG Ret;
  3160. UINT Idx;
  3161. BOOL IsColor;
  3162. GSBUF_DEF(pItem, MAX_RES_STR_CHARS);
  3163. if (!(pCurMyDP = GET_PMYDLGPAGE(hDlg))) {
  3164. CPSUIERR(("hDlg=%08lx, pCurMyDP=NULL", hDlg));
  3165. return(0);
  3166. }
  3167. if (!(pPSPInfo = pCurMyDP->pPSPInfo)) {
  3168. CPSUIERR(("hDlg=%08lx, pCurMyDP->pPSPInfo=NULL", hDlg));
  3169. return(0);
  3170. }
  3171. pOptType = GET_POPTTYPE(pItem);
  3172. pOptParam = pOptType->pOptParam;
  3173. Ret = pItem->Sel;
  3174. switch(pOptParam[0].Style) {
  3175. case PUSHBUTTON_TYPE_DLGPROC:
  3176. if (pOptParam[0].pData) {
  3177. Ret = DoCallBack(hDlg,
  3178. pTVWnd,
  3179. pItem,
  3180. pItem->pSel,
  3181. (_CPSUICALLBACK)pOptParam[0].pData,
  3182. (pOptParam[0].Flags & OPTPF_USE_HDLGTEMPLATE) ?
  3183. (HANDLE)pOptParam[0].lParam : NULL,
  3184. (WORD)pOptParam[0].lParam,
  3185. CPSUICB_REASON_DLGPROC);
  3186. }
  3187. break;
  3188. case PUSHBUTTON_TYPE_CALLBACK:
  3189. DoCallBack(hDlg,
  3190. pTVWnd,
  3191. pItem,
  3192. pItem->pSel,
  3193. (_CPSUICALLBACK)pOptParam[0].pData,
  3194. NULL,
  3195. 0,
  3196. CPSUICB_REASON_PUSHBUTTON);
  3197. break;
  3198. case PUSHBUTTON_TYPE_HTCLRADJ:
  3199. //
  3200. // HTUI.DLL is part of the OS, so we need to make sure
  3201. // it always gets loaded into V6 context.
  3202. //
  3203. ulCookie = 0;
  3204. if (SHActivateContext(&ulCookie)) {
  3205. __try {
  3206. IsColor = (BOOL)((pItem = GET_PITEMDMPUB(pTVWnd, DMPUB_COLOR, Idx)) &&
  3207. (pItem->Sel >= 1));
  3208. CPSUIDBG(DBG_DOPB, ("ColorAdj: IsColor=%ld, Update=%ld",
  3209. (DWORD)IsColor, (DWORD)pTVWnd->Flags & TWF_CAN_UPDATE));
  3210. GSBUF_RESET;
  3211. GSBUF_FLAGS |= GBF_PREFIX_OK;
  3212. GSBUF_GETSTR(pTVWnd->ComPropSheetUI.pOptItemName);
  3213. if ((hInst = LoadLibrary(TEXT("htui"))) &&
  3214. (farproc = GetProcAddress(hInst, (LPCSTR)szHTUIClrAdj))) {
  3215. try {
  3216. Ret = (LONG)(*farproc)((LPWSTR)GSBUF_BUF,
  3217. NULL,
  3218. NULL,
  3219. (PCOLORADJUSTMENT)pOptParam[0].pData,
  3220. !IsColor,
  3221. pTVWnd->Flags & TWF_CAN_UPDATE);
  3222. } except (FilterException(pPSPInfo->hComPropSheet,
  3223. GetExceptionInformation())) {
  3224. CPSUIERR(("Halftone Proc=%hs, Exception", szHTUIClrAdj));
  3225. Ret = 0;
  3226. }
  3227. }
  3228. }
  3229. __finally {
  3230. //
  3231. // we need to deactivate the context, no matter what!
  3232. //
  3233. SHDeactivateContext(ulCookie);
  3234. }
  3235. }
  3236. break;
  3237. case PUSHBUTTON_TYPE_HTSETUP:
  3238. //
  3239. // HTUI.DLL is part of the OS, so we need to make sure
  3240. // it always gets loaded into V6 context.
  3241. //
  3242. ulCookie = 0;
  3243. if (SHActivateContext(&ulCookie)) {
  3244. __try {
  3245. DevHTAdjData = *(PDEVHTADJDATA)(pOptParam[0].pData);
  3246. if (!(pTVWnd->Flags & TWF_CAN_UPDATE)) {
  3247. DevHTAdjData.pDefHTInfo = DevHTAdjData.pAdjHTInfo;
  3248. }
  3249. GSBUF_RESET;
  3250. GSBUF_FLAGS |= GBF_PREFIX_OK;
  3251. GSBUF_GETSTR(pTVWnd->ComPropSheetUI.pOptItemName);
  3252. if ((hInst = LoadLibrary(TEXT("htui"))) &&
  3253. (farproc = GetProcAddress(hInst, (LPCSTR)szHTUIDevClrAdj))) {
  3254. try {
  3255. Ret = (LONG)(*farproc)((LPWSTR)GSBUF_BUF, &DevHTAdjData);
  3256. } except (FilterException(pPSPInfo->hComPropSheet,
  3257. GetExceptionInformation())) {
  3258. CPSUIERR(("Halftone Proc=%hs, Exception", szHTUIDevClrAdj));
  3259. Ret = 0;
  3260. }
  3261. }
  3262. }
  3263. __finally {
  3264. //
  3265. // we need to deactivate the context, no matter what!
  3266. //
  3267. SHDeactivateContext(ulCookie);
  3268. }
  3269. }
  3270. break;
  3271. }
  3272. if (hInst) {
  3273. FreeLibrary(hInst);
  3274. }
  3275. CPSUIOPTITEM(DBGITEM_PUSH, pTVWnd, "PUSHBUTTON:", 0, pItem);
  3276. return(Ret);
  3277. }
  3278. POPTITEM
  3279. pItemFromhWnd(
  3280. HWND hDlg,
  3281. PTVWND pTVWnd,
  3282. HWND hCtrl,
  3283. LONG MousePos
  3284. )
  3285. /*++
  3286. Routine Description:
  3287. This function take a hWnd and return a pItem associate with it
  3288. Arguments:
  3289. hDlg - Handle to the dialog box page
  3290. pTVWnd - Our instance handle
  3291. hCtrl - the handle to the focus window
  3292. MousePos - MAKELONG(x, y) of current mouse position
  3293. Return Value:
  3294. POPTITEM, null if failed
  3295. Author:
  3296. 26-Sep-1995 Tue 12:24:36 created -by- Daniel Chou (danielc)
  3297. Revision History:
  3298. --*/
  3299. {
  3300. DWORD dw;
  3301. if ((!hCtrl) || (hCtrl == hDlg)) {
  3302. POINT pt;
  3303. pt.x = LOWORD(MousePos);
  3304. pt.y = HIWORD(MousePos);
  3305. ScreenToClient(hDlg, (LPPOINT)&pt);
  3306. if ((MousePos == -1) ||
  3307. (!(hCtrl = ChildWindowFromPointEx(hDlg, pt, CWP_SKIPINVISIBLE))) ||
  3308. (hCtrl == hDlg)) {
  3309. CPSUIDBG(DBG_IFW, ("hDlg=%08lx, No hWnd From from Mouse Pos=(%ld, %ld)",
  3310. hDlg, pt.x, pt.y));
  3311. return(NULL);
  3312. }
  3313. }
  3314. CPSUIDBG(DBG_IFW, ("!! Find The hCtrl=%08lx", hCtrl));
  3315. if (dw = (DWORD)GetWindowLongPtr(hCtrl, GWLP_USERDATA)) {
  3316. WORD ItemIdx;
  3317. if (pTVWnd->Flags & TWF_IN_TVPAGE) {
  3318. return(pTVWnd->pCurTVItem);
  3319. }
  3320. ItemIdx = (WORD)GETCTRLITEMIDX(dw);
  3321. CPSUIDBG(DBG_IFW, ("ID=%ld, Idx=%ld, dw=%08lx",
  3322. (DWORD)GetDlgCtrlID(hCtrl), (DWORD)ItemIdx, dw));
  3323. //
  3324. // Validate what we got
  3325. //
  3326. if (ItemIdx >= INTIDX_FIRST) {
  3327. return(PIDX_INTOPTITEM(pTVWnd, ItemIdx));
  3328. } else if (ItemIdx < pTVWnd->ComPropSheetUI.cOptItem) {
  3329. return(pTVWnd->ComPropSheetUI.pOptItem + ItemIdx);
  3330. }
  3331. } else {
  3332. CPSUIINT(("pItemFromhWnd: hCtrl=%08lx, GWLP_USERDATA=%08lx", hCtrl, dw));
  3333. }
  3334. CPSUIINT(("pItemFromhWnd: NONE"));
  3335. return(NULL);
  3336. }
  3337. VOID
  3338. DoContextMenu(
  3339. PTVWND pTVWnd,
  3340. HWND hDlg,
  3341. POPTITEM pItem,
  3342. LPARAM Pos
  3343. )
  3344. /*++
  3345. Routine Description:
  3346. Arguments:
  3347. Return Value:
  3348. Author:
  3349. 17-Feb-1998 Tue 17:59:20 created -by- Daniel Chou (danielc)
  3350. Revision History:
  3351. --*/
  3352. {
  3353. HMENU hMenu;
  3354. UINT cMenu = 0;
  3355. UINT cChar;
  3356. WCHAR wBuf[MAX_RES_STR_CHARS + 40];
  3357. if (hMenu = CreatePopupMenu()) {
  3358. pTVWnd->pMouseItem = pItem;
  3359. pTVWnd->MousePos = Pos;
  3360. CPSUIINT(("Create PopUpMenu=%08lx, pItem=%08lx, hFocus=%08lx (%ld)",
  3361. hMenu, pItem, GetFocus(), GetWindowLongPtr(GetFocus(), GWLP_ID)));
  3362. if ((pItem) &&
  3363. (cChar = CountRevertOptItem(pTVWnd, pItem, _OI_HITEM(pItem), 0))) {
  3364. if (cMenu++) {
  3365. AppendMenu(hMenu,
  3366. MF_SEPARATOR,
  3367. 0,
  3368. NULL);
  3369. }
  3370. ComposeStrData(pTVWnd->hInstCaller,
  3371. (WORD)(GBF_PREFIX_OK |
  3372. ((pTVWnd->Flags & TWF_ANSI_CALL) ?
  3373. GBF_ANSI_CALL : 0)),
  3374. wBuf,
  3375. COUNT_ARRAY(wBuf),
  3376. (UINT)(cChar > 1) ? IDS_INT_CPSUI_UNDO_OPTS :
  3377. IDS_INT_CPSUI_UNDO_OPT,
  3378. pItem->pName,
  3379. cChar,
  3380. 0);
  3381. AppendMenu(hMenu,
  3382. MF_ENABLED | MF_STRING,
  3383. ID_CMD_UNDO,
  3384. wBuf);
  3385. }
  3386. if (pItem) {
  3387. if (cMenu++) {
  3388. AppendMenu(hMenu,
  3389. MF_SEPARATOR,
  3390. 0,
  3391. NULL);
  3392. }
  3393. GetStringBuffer(pTVWnd->hInstCaller,
  3394. (WORD)(GBF_PREFIX_OK |
  3395. GBF_IDS_INT_CPSUI |
  3396. ((pTVWnd->Flags & TWF_ANSI_CALL) ?
  3397. GBF_ANSI_CALL : 0)),
  3398. L'\0',
  3399. (LPTSTR)IDS_INT_CPSUI_WHATISTHIS,
  3400. wBuf,
  3401. COUNT_ARRAY(wBuf) - 1);
  3402. AppendMenu(hMenu,
  3403. MF_ENABLED | MF_STRING,
  3404. ID_CMD_HELP,
  3405. wBuf);
  3406. }
  3407. if (cMenu++) {
  3408. AppendMenu(hMenu,
  3409. MF_SEPARATOR,
  3410. 0,
  3411. NULL);
  3412. }
  3413. cChar = ComposeStrData(pTVWnd->hInstCaller,
  3414. (WORD)(GBF_PREFIX_OK |
  3415. ((pTVWnd->Flags & TWF_ANSI_CALL) ?
  3416. GBF_ANSI_CALL : 0)),
  3417. wBuf,
  3418. COUNT_ARRAY(wBuf),
  3419. (UINT)IDS_INT_CPSUI_ABOUT,
  3420. pTVWnd->ComPropSheetUI.pCallerName,
  3421. 0,
  3422. 0);
  3423. GetStringBuffer(pTVWnd->hInstCaller,
  3424. (WORD)(GBF_PREFIX_OK |
  3425. ((pTVWnd->Flags & TWF_ANSI_CALL) ?
  3426. GBF_ANSI_CALL : 0)),
  3427. L'\0',
  3428. (LPTSTR)IDS_CPSUI_MORE,
  3429. &wBuf[cChar],
  3430. COUNT_ARRAY(wBuf) - cChar - 1);
  3431. AppendMenu(hMenu,
  3432. MF_ENABLED | MF_STRING,
  3433. ID_CMD_ABOUT,
  3434. wBuf);
  3435. if (!pItem) {
  3436. pTVWnd->pMouseItem = PIDX_INTOPTITEM(pTVWnd, INTIDX_TVROOT);
  3437. }
  3438. TrackPopupMenu(hMenu,
  3439. TPM_LEFTALIGN | TPM_LEFTBUTTON,
  3440. LOWORD(Pos),
  3441. HIWORD(Pos),
  3442. 0,
  3443. hDlg,
  3444. NULL);
  3445. CPSUIINT(("DESTROY PopUpMenu=%08lx, cMenu=%08lx", hMenu, cMenu));
  3446. DestroyMenu(hMenu);
  3447. }
  3448. }
  3449. LONG
  3450. FindNextLBCBSel(
  3451. HWND hLBCB,
  3452. LONG SelLast,
  3453. LONG SelNow,
  3454. UINT IDGetItemData,
  3455. LPDWORD pItemData
  3456. )
  3457. /*++
  3458. Routine Description:
  3459. Arguments:
  3460. Return Value:
  3461. Author:
  3462. 10-Sep-1995 Sun 23:58:44 created -by- Daniel Chou (danielc)
  3463. Revision History:
  3464. --*/
  3465. {
  3466. LONG Count;
  3467. LONG SelAdd;
  3468. DWORD ItemData;
  3469. Count = (LONG)SendMessage(hLBCB,
  3470. (IDGetItemData == LB_GETITEMDATA) ?
  3471. LB_GETCOUNT : CB_GETCOUNT,
  3472. 0,
  3473. 0L);
  3474. SelAdd = (SelNow >= SelLast) ? 1 : -1;
  3475. while (((SelNow += SelAdd) >= 0) && (SelNow < Count)) {
  3476. ItemData = (DWORD)SendMessage(hLBCB, IDGetItemData, SelNow, 0L);
  3477. if (!(ItemData & LBCBID_DISABLED)) {
  3478. *pItemData = ItemData;
  3479. return(SelNow);
  3480. }
  3481. }
  3482. //
  3483. // We could not find the one which is enabled, so go back to the old one
  3484. //
  3485. *pItemData = (DWORD)SendMessage(hLBCB, IDGetItemData, SelLast, 0L);
  3486. return(SelLast);
  3487. }
  3488. BOOL
  3489. DrawLBCBItem(
  3490. PTVWND pTVWnd,
  3491. LPDRAWITEMSTRUCT pdis
  3492. )
  3493. /*++
  3494. Routine Description:
  3495. Arguments:
  3496. Return Value:
  3497. Author:
  3498. 11-Sep-1995 Mon 18:44:05 created -by- Daniel Chou (danielc)
  3499. Revision History:
  3500. --*/
  3501. {
  3502. HDC hDC;
  3503. PLAYOUTBMP pData;
  3504. POPTITEM pItem;
  3505. POPTTYPE pOptType;
  3506. WORD OPIdx;
  3507. INT y;
  3508. UINT ItemState;
  3509. BYTE CtrlStyle;
  3510. BYTE CtrlData;
  3511. WORD ItemIdx;
  3512. WORD Count;
  3513. WORD OTFlags;
  3514. DWORD dw;
  3515. ULONG_PTR ItemData;
  3516. RECT rc;
  3517. POINT TextOff;
  3518. DWORD OldBkMode;
  3519. COLORREF OldClr;
  3520. COLORREF OldBkClr;
  3521. INT FillIdx;
  3522. INT TextIdx;
  3523. HBRUSH hbr;
  3524. BOOL IsLB = TRUE;
  3525. TEXTMETRIC tm;
  3526. LRESULT uLen;
  3527. LPTSTR pszItem = NULL;
  3528. if (pdis->itemID == -1) {
  3529. return(FALSE);
  3530. }
  3531. switch (pdis->CtlType) {
  3532. case ODT_COMBOBOX:
  3533. IsLB = FALSE;
  3534. case ODT_LISTBOX:
  3535. break;
  3536. case ODT_BUTTON:
  3537. if ((pdis->CtlID == IDD_LAYOUT_PICTURE) &&
  3538. (pdis->itemAction & (ODA_DRAWENTIRE )) &&
  3539. (pData = (PLAYOUTBMP)GetProp(pdis->hwndItem,
  3540. CPSUIPROP_LAYOUTPUSH))) {
  3541. UpdateLayoutBmp(pdis->hDC, pData);
  3542. }
  3543. return TRUE;
  3544. default:
  3545. return(FALSE);
  3546. }
  3547. if (!(dw = (DWORD)GetWindowLongPtr(pdis->hwndItem, GWLP_USERDATA))) {
  3548. CPSUIDBG(DBG_CS, ("DrawLBCBItem: dw=0, hCtrl=%08lx, CtlID=%08lx",
  3549. pdis->hwndItem, pdis->CtlID));
  3550. return(FALSE);
  3551. }
  3552. GETCTRLDATA(dw, ItemIdx, CtrlStyle, CtrlData);
  3553. if ((!(pItem = GetOptions(pTVWnd, MAKELPARAM(ItemIdx, 0)))) ||
  3554. (!(pOptType = GET_POPTTYPE(pItem))) ||
  3555. (pItem->Flags & OPTIF_ITEM_HIDE)) {
  3556. CPSUIERR(("DrawLBCB: Invalid Ctrl or ItemIdx=%ld", ItemIdx));
  3557. return(FALSE);
  3558. }
  3559. #if (DO_IN_PLACE == 0)
  3560. CPSUIASSERT(0, "DrawLBCB: The type is not LB or CB but [%u]",
  3561. (pOptType->Type == TVOT_LISTBOX) ||
  3562. (pOptType->Type == TVOT_COMBOBOX), (UINT)pOptType->Type);
  3563. #endif
  3564. OTFlags = _OT_FLAGS(pOptType);
  3565. hDC = pdis->hDC;
  3566. rc = pdis->rcItem;
  3567. ItemData = pdis->itemData;
  3568. //
  3569. // Get the length of this item's text
  3570. //
  3571. uLen = (IsLB) ? LB_ERR : CB_ERR;
  3572. uLen = SendMessage(pdis->hwndItem,
  3573. (IsLB) ? LB_GETTEXTLEN : CB_GETLBTEXTLEN,
  3574. (WPARAM)pdis->itemID,
  3575. (LPARAM)0);
  3576. if (uLen > 0)
  3577. {
  3578. //
  3579. // Allocate a buffer for the string
  3580. //
  3581. pszItem = (LPTSTR)LocalAlloc( LPTR,(uLen + 1) * sizeof(TCHAR));
  3582. if (pszItem)
  3583. {
  3584. //
  3585. // Get the string
  3586. //
  3587. SendMessage(pdis->hwndItem,
  3588. (IsLB) ? LB_GETTEXT : CB_GETLBTEXT,
  3589. (WPARAM)pdis->itemID,
  3590. (LPARAM)pszItem);
  3591. }
  3592. }
  3593. switch (pdis->itemAction) {
  3594. case ODA_SELECT:
  3595. case ODA_DRAWENTIRE:
  3596. GetTextMetrics(hDC, &tm);
  3597. ItemState = pdis->itemState;
  3598. #if DO_IN_PLACE
  3599. CPSUIINT(("hwndItem=%08lx", pdis->hwndItem));
  3600. if ((ItemState & ODS_COMBOBOXEDIT) &&
  3601. (pTVWnd->Flags & TWF_IN_TVPAGE)) {
  3602. OTFlags &= ~OTINTF_ITEM_HAS_ICON16;
  3603. }
  3604. #endif
  3605. TextOff.x = (OTFlags & OTINTF_ITEM_HAS_ICON16) ?
  3606. (LBCB_ICON_X_OFF + CXIMAGE + LBCB_ICON_TEXT_X_SEP) :
  3607. (LBCB_ICON_X_OFF);
  3608. TextOff.y = (rc.bottom + rc.top - tm.tmHeight) / 2;
  3609. //
  3610. // Fill the selection rectangle from the location, this is only
  3611. // happpened if we wre not disabled
  3612. //
  3613. if (ItemState & ODS_DISABLED) {
  3614. if ((ItemState & ODS_SELECTED) && (IsLB)) {
  3615. FillIdx = COLOR_3DSHADOW;
  3616. TextIdx = COLOR_3DFACE;
  3617. } else {
  3618. FillIdx = COLOR_3DFACE;
  3619. TextIdx = COLOR_GRAYTEXT;
  3620. }
  3621. } else {
  3622. if (ItemState & ODS_SELECTED) {
  3623. FillIdx = COLOR_HIGHLIGHT;
  3624. dw = COLOR_HIGHLIGHTTEXT;
  3625. } else {
  3626. FillIdx = COLOR_WINDOW;
  3627. dw = COLOR_WINDOWTEXT;
  3628. }
  3629. if (ItemData & LBCBID_DISABLED) {
  3630. TextIdx = COLOR_GRAYTEXT;
  3631. } else {
  3632. TextIdx = (INT)dw;
  3633. }
  3634. }
  3635. //
  3636. // Fill the background frist
  3637. //
  3638. hbr = CreateSolidBrush(GetSysColor(FillIdx));
  3639. if (hbr) {
  3640. FillRect(hDC, &rc, hbr);
  3641. DeleteObject(hbr);
  3642. }
  3643. if (ItemData & LBCBID_FILL) {
  3644. break;
  3645. }
  3646. //
  3647. // Draw the text using transparent mode
  3648. //
  3649. OldClr = SetTextColor(hDC, GetSysColor(TextIdx));
  3650. OldBkMode = SetBkMode(hDC, TRANSPARENT);
  3651. TextOut(hDC,
  3652. rc.left + TextOff.x,
  3653. TextOff.y,
  3654. pszItem,
  3655. lstrlen(pszItem));
  3656. SetTextColor(hDC, OldClr);
  3657. SetBkMode(hDC, OldBkMode);
  3658. //
  3659. // Setting any icon if available
  3660. //
  3661. if (OTFlags & OTINTF_ITEM_HAS_ICON16) {
  3662. LPWORD *pIcon16Idx;
  3663. POPTPARAM pOptParam;
  3664. HINSTANCE hInst;
  3665. pOptParam = (ItemData & LBCBID_NONE) ? &pTVWnd->OptParamNone :
  3666. pOptType->pOptParam +
  3667. LOWORD(ItemData);
  3668. hInst = _OI_HINST(pItem);
  3669. #if DO_IN_PLACE
  3670. if (dw = GetIcon16Idx(pTVWnd,
  3671. hInst,
  3672. GET_ICONID(pOptParam,
  3673. OPTPF_ICONID_AS_HICON),
  3674. IDI_CPSUI_GENERIC_ITEM)) {
  3675. ImageList_Draw(pTVWnd->himi,
  3676. dw,
  3677. hDC,
  3678. rc.left + LBCB_ICON_X_OFF,
  3679. rc.top,
  3680. ILD_TRANSPARENT);
  3681. }
  3682. #else
  3683. ImageList_Draw(pTVWnd->himi,
  3684. GetIcon16Idx(pTVWnd,
  3685. hInst,
  3686. GET_ICONID(pOptParam,
  3687. OPTPF_ICONID_AS_HICON),
  3688. IDI_CPSUI_GENERIC_ITEM),
  3689. hDC,
  3690. rc.left + LBCB_ICON_X_OFF,
  3691. rc.top,
  3692. ILD_TRANSPARENT);
  3693. #endif
  3694. //
  3695. // Draw The No/Stop/Warning icon on to it
  3696. //
  3697. if (pOptParam->Flags & OPTPF_OVERLAY_STOP_ICON) {
  3698. ImageList_Draw(pTVWnd->himi,
  3699. GetIcon16Idx(pTVWnd,
  3700. hInst,
  3701. 0,
  3702. IDI_CPSUI_STOP),
  3703. hDC,
  3704. rc.left + LBCB_ICON_X_OFF,
  3705. rc.top,
  3706. ILD_TRANSPARENT);
  3707. }
  3708. if (pOptParam->Flags & OPTPF_OVERLAY_NO_ICON) {
  3709. ImageList_Draw(pTVWnd->himi,
  3710. GetIcon16Idx(pTVWnd,
  3711. hInst,
  3712. 0,
  3713. IDI_CPSUI_NO),
  3714. hDC,
  3715. rc.left + LBCB_ICON_X_OFF,
  3716. rc.top,
  3717. ILD_TRANSPARENT);
  3718. }
  3719. if (pOptParam->Flags & OPTPF_OVERLAY_WARNING_ICON) {
  3720. ImageList_Draw(pTVWnd->himi,
  3721. GetIcon16Idx(pTVWnd,
  3722. hInst,
  3723. 0,
  3724. IDI_CPSUI_WARNING_OVERLAY),
  3725. hDC,
  3726. rc.left + LBCB_ICON_X_OFF,
  3727. rc.top,
  3728. ILD_TRANSPARENT);
  3729. }
  3730. }
  3731. if ((ItemState & (ODS_COMBOBOXEDIT | ODS_SELECTED | ODS_FOCUS))
  3732. == (ODS_COMBOBOXEDIT | ODS_SELECTED | ODS_FOCUS)) {
  3733. DrawFocusRect(hDC, &pdis->rcItem);
  3734. }
  3735. break;
  3736. case ODA_FOCUS:
  3737. if (!IsLB) {
  3738. DrawFocusRect(hDC, &pdis->rcItem);
  3739. break;
  3740. }
  3741. return(FALSE);
  3742. }
  3743. LocalFree(pszItem);
  3744. return(TRUE);
  3745. }
  3746. BOOL
  3747. ValidateUDArrow(
  3748. HWND hDlg,
  3749. HWND hEdit,
  3750. BYTE CtrlData,
  3751. LONG *pSel,
  3752. LONG Min,
  3753. LONG Max
  3754. )
  3755. /*++
  3756. Routine Description:
  3757. This function validate current updown arrow edit box selection (numerical)
  3758. and reset the text if invalid, it also has handy cursor selection scheme.
  3759. Arguments:
  3760. hDlg - Handle to the property sheet dialog box
  3761. hEdit - Handle to the edit control (the NEXTCTRL should be UPDOWN
  3762. ARROW)
  3763. CtrlData - CtrlData for the Edit Control, it has EDF_xxxx flags
  3764. pSel - Pointer to a LONG for the previous selected number
  3765. Min - Min number for this edit control
  3766. Max - max number for this edit control
  3767. Return Value:
  3768. BOOL - TRUE if selection number changed, FALSE otherwise
  3769. Author:
  3770. 19-Sep-1995 Tue 12:35:33 created -by- Daniel Chou (danielc)
  3771. Revision History:
  3772. --*/
  3773. {
  3774. LPWSTR pSelBuf;
  3775. LONG OldSel;
  3776. LONG Sel;
  3777. LONG SelBegIdx;
  3778. LONG SelEndIdx;
  3779. BOOL ResetText;
  3780. BOOL bSign;
  3781. BOOL bDifSel;
  3782. UINT Len;
  3783. UINT cDigit;
  3784. WCHAR SelBuf[MAX_UDARROW_TEXT_LEN+1];
  3785. WCHAR ch;
  3786. SelBuf[0] = 0;
  3787. cDigit = 0;
  3788. bSign = FALSE;
  3789. Sel = 0;
  3790. SelBegIdx =
  3791. SelEndIdx = 9999;
  3792. pSelBuf = SelBuf;
  3793. OldSel = *pSel;
  3794. if (!(Len = (UINT)GetWindowText(hEdit, pSelBuf, ARRAYSIZE(SelBuf)))) {
  3795. SelBegIdx = 0;
  3796. ResetText = TRUE;
  3797. } else {
  3798. ResetText = FALSE;
  3799. }
  3800. CPSUIDBG(DBG_VALIDATE_UD, ("---------- Validate UDArrow -----------"));
  3801. CPSUIDBG(DBG_VALIDATE_UD, ("UDArrow: CUR Text='%ws' (%ld), OldSel=%ld",
  3802. SelBuf, Len, OldSel));
  3803. while (ch = *pSelBuf++) {
  3804. switch (ch) {
  3805. case L'-':
  3806. if ((bSign) ||
  3807. (cDigit) ||
  3808. ((Min >= 0) && (Max >= 0))) {
  3809. ResetText = TRUE;
  3810. } else {
  3811. bSign = TRUE;
  3812. }
  3813. break;
  3814. default:
  3815. if ((ch >= L'0') && (ch <= L'9')) {
  3816. cDigit++;
  3817. Sel = (Sel * 10) + (LONG)(ch - L'0');
  3818. } else {
  3819. ResetText = TRUE;
  3820. }
  3821. break;
  3822. }
  3823. }
  3824. if (bSign) {
  3825. //
  3826. // If we got '-' or '-0' then make it to Min, and not selecting the
  3827. // minus sign
  3828. //
  3829. if (!(Sel = -Sel)) {
  3830. Sel = Min;
  3831. SelBegIdx = 1;
  3832. ResetText = TRUE;
  3833. }
  3834. } else if (!Sel) {
  3835. SelBegIdx = 0;
  3836. }
  3837. cDigit = wsprintf(SelBuf, L"%ld", Sel);
  3838. if (Sel < Min) {
  3839. ResetText = TRUE;
  3840. if (Sel) {
  3841. SelBegIdx = cDigit;
  3842. if ((SelBegIdx) &&
  3843. (CtrlData & EDF_BACKSPACE) &&
  3844. ((CtrlData & EDF_BEGIDXMASK) <= SelBegIdx)) {
  3845. SelBegIdx--;
  3846. }
  3847. while (Sel < Min) {
  3848. Sel *= 10;
  3849. }
  3850. if (Sel > Max) {
  3851. Sel = 0;
  3852. }
  3853. }
  3854. if (!Sel) {
  3855. Sel = Min;
  3856. SelBegIdx = 0;
  3857. }
  3858. } else if (Sel > Max) {
  3859. ResetText = TRUE;
  3860. Sel = Max;
  3861. SelBegIdx = 0;
  3862. }
  3863. *pSel = Sel;
  3864. if ((cDigit = wsprintf(SelBuf, L"%ld", Sel)) != Len) {
  3865. ResetText = TRUE;
  3866. if (SelBegIdx == 9999) {
  3867. SelBegIdx =
  3868. SelEndIdx = (LONG)(CtrlData & EDF_BEGIDXMASK);
  3869. }
  3870. }
  3871. if (ResetText) {
  3872. CPSUIDBG(DBG_VALIDATE_UD,
  3873. ("UDArrow: NEW Text='%ws' (%ld)", SelBuf, cDigit));
  3874. SendMessage(hEdit, WM_SETTEXT, (WPARAM)0, (LPARAM)SelBuf);
  3875. // SetDlgItemInt(hDlg, GetDlgCtrlID(hEdit), Sel, TRUE);
  3876. }
  3877. if (SelBegIdx != 9999) {
  3878. CPSUIDBG(DBG_VALIDATE_UD, ("UDArrow: NEW SelIdx=(%ld, %ld)",
  3879. SelBegIdx, SelEndIdx));
  3880. SendMessage(hEdit, EM_SETSEL, SelBegIdx, SelEndIdx);
  3881. }
  3882. CPSUIDBG(DBG_VALIDATE_UD, ("UDArrow: Sel=%ld -> %ld, Change=%hs\n",
  3883. OldSel, Sel, (OldSel == Sel) ? "FALSE" : "TRUE"));
  3884. return(OldSel != Sel);
  3885. }
  3886. HWND
  3887. FindItemFirstFocus(
  3888. HWND hDlg,
  3889. PTVWND pTVWnd,
  3890. POPTITEM pItem
  3891. )
  3892. /*++
  3893. Routine Description:
  3894. Arguments:
  3895. Return Value:
  3896. Author:
  3897. 05-Mar-1998 Thu 14:39:17 created -by- Daniel Chou (danielc)
  3898. Revision History:
  3899. --*/
  3900. {
  3901. HWND hFocus;
  3902. POPTITEM pItemBeg;
  3903. POPTITEM pItemEnd;
  3904. BYTE PageIdx;
  3905. BOOL HasFocus = FALSE;
  3906. PageIdx = (BYTE)(GET_PMYDLGPAGE(hDlg))->PageIdx;
  3907. pItemBeg = pItem;
  3908. pItemEnd = pTVWnd->pLastItem + 1;
  3909. while ((pItem) && (!HasFocus)) {
  3910. if (pItem->DlgPageIdx == PageIdx) {
  3911. POPTTYPE pOptType;
  3912. UINT CtrlID;
  3913. UINT cCtrls;
  3914. if (pOptType = pItem->pOptType) {
  3915. CtrlID = (UINT)pOptType->BegCtrlID;
  3916. cCtrls = (UINT)cTVOTCtrls[pOptType->Type];
  3917. CPSUIOPTITEM(DBG_FOCUS, pTVWnd, "Find Focus", 1, pItem);
  3918. while ((!HasFocus) && (cCtrls--)) {
  3919. if ((hFocus = GetDlgItem(hDlg, CtrlID++)) &&
  3920. ((GetWindowLongPtr(hFocus, GWL_STYLE) &
  3921. (WS_VISIBLE | WS_DISABLED | WS_TABSTOP)) ==
  3922. (WS_VISIBLE | WS_TABSTOP))) {
  3923. SetFocus(hFocus);
  3924. if (GetFocus() == hFocus) {
  3925. CPSUIDBG(DBG_FOCUS,
  3926. ("pItem=%08lx (Page=%ld) has Focus=%08lx (%ld), Style=%08lx",
  3927. pItem, PageIdx, hFocus,
  3928. GetWindowLongPtr(hFocus, GWLP_ID),
  3929. GetWindowLongPtr(hFocus, GWL_STYLE)));
  3930. HasFocus = TRUE;
  3931. }
  3932. }
  3933. }
  3934. }
  3935. }
  3936. if (++pItem >= pItemEnd) {
  3937. if (pItemEnd == pItemBeg) {
  3938. pItem = NULL;
  3939. } else {
  3940. pItem = pTVWnd->ComPropSheetUI.pOptItem;
  3941. pItemEnd = pItemBeg;
  3942. }
  3943. }
  3944. }
  3945. if ((HasFocus) && (hFocus)) {
  3946. return(hFocus);
  3947. } else {
  3948. return(NULL);
  3949. }
  3950. }
  3951. POPTITEM
  3952. DlgHScrollCommand(
  3953. HWND hDlg,
  3954. PTVWND pTVWnd,
  3955. HWND hCtrl,
  3956. WPARAM wParam
  3957. )
  3958. /*++
  3959. Routine Description:
  3960. This is a general function to process all WM_COMMAND and WM_HSCROLL
  3961. for the common UI
  3962. Arguments:
  3963. hDlg - Handle to the dialog box
  3964. pTVWnd - Our instance data
  3965. hCtrl - The handle to the control
  3966. wParam - message/data insterested
  3967. Return Value:
  3968. POPTITEM NULL if nothing changed
  3969. Author:
  3970. 01-Sep-1995 Fri 02:25:18 updated -by- Daniel Chou (danielc)
  3971. Revision History:
  3972. --*/
  3973. {
  3974. HWND hFocus;
  3975. POPTTYPE pOptType;
  3976. POPTPARAM pOptParam;
  3977. POPTITEM pItem;
  3978. LPTSTR pSel;
  3979. DWORD dw;
  3980. BOOL HasSel = FALSE;
  3981. BYTE CtrlStyle;
  3982. BYTE CtrlData;
  3983. BYTE Type;
  3984. WORD ItemIdx;
  3985. LONG NewSel;
  3986. INT_PTR SelIdx;
  3987. INT Count;
  3988. UINT Len;
  3989. WORD LoW;
  3990. WORD HiW;
  3991. INT SelAdd;
  3992. INT CurSel;
  3993. UINT IDGetItemData;
  3994. BOOL IsLB;
  3995. DWORD BegSel;
  3996. DWORD EndSel;
  3997. HiW = HIWORD(wParam);
  3998. LoW = LOWORD(wParam);
  3999. if (pItem = pTVWnd->pMouseItem) {
  4000. pTVWnd->pMouseItem = NULL;
  4001. switch (LoW) {
  4002. case ID_CMD_HELP:
  4003. CPSUIINT(("=== GET MENU message = HELP, hFocus=%08lx, hWndTV=%08lx ====",
  4004. (hDlg == pTVWnd->hDlgTV) ? pTVWnd->hWndTV : GetFocus(),
  4005. pTVWnd->hWndTV));
  4006. CommonPropSheetUIHelp(hDlg,
  4007. pTVWnd,
  4008. (hDlg == pTVWnd->hDlgTV) ?
  4009. pTVWnd->hWndTV : GetFocus(),
  4010. (DWORD)pTVWnd->MousePos,
  4011. pItem,
  4012. HELP_WM_HELP);
  4013. pTVWnd->MousePos = 0;
  4014. return(NULL);
  4015. case ID_CMD_UNDO:
  4016. hFocus = GetFocus();
  4017. //
  4018. // Revert
  4019. //
  4020. DoCallBack(hDlg,
  4021. pTVWnd,
  4022. pItem,
  4023. pItem->pSel,
  4024. (_CPSUICALLBACK)InternalRevertOptItem,
  4025. NULL,
  4026. 0,
  4027. CPSUICB_REASON_ITEMS_REVERTED);
  4028. if ((hFocus) && (!GetFocus())) {
  4029. dw = (DWORD)GetWindowLongPtr(hFocus, GWL_STYLE);
  4030. CPSUIDBG(DBG_FOCUS,
  4031. ("\n!!! Original hFocus=%08lx (%ld), Style=%08lx",
  4032. hFocus, GetWindowLongPtr(hFocus, GWLP_ID), dw));
  4033. //
  4034. // We has a focus, and lost the keyboard focus now
  4035. //
  4036. if ((dw & (WS_VISIBLE | WS_DISABLED)) == WS_VISIBLE) {
  4037. //
  4038. // If this window still enable/visble then set to it
  4039. //
  4040. CPSUIDBG(DBG_FOCUS,
  4041. (" Focus=%08lx (%ld) still ok, set to it",
  4042. hFocus, GetWindowLongPtr(hFocus, GWLP_ID)));
  4043. SetFocus(hFocus);
  4044. } else if (hDlg != pTVWnd->hDlgTV) {
  4045. if (!(hFocus = FindItemFirstFocus(hDlg, pTVWnd, pItem))) {
  4046. CPSUIDBG(DBG_FOCUS,
  4047. ("=== Cannot find any more focus goto WM_NEXTDLGCTL ==="));
  4048. SendMessage(hDlg, WM_NEXTDLGCTL, 1, (LPARAM)FALSE);
  4049. }
  4050. }
  4051. }
  4052. pTVWnd->MousePos = 0;
  4053. return(pItem);
  4054. case ID_CMD_ABOUT:
  4055. CPSUIINT(("=== GET MENU message = ABOUT ======"));
  4056. if (pItem = PIDX_INTOPTITEM(pTVWnd, INTIDX_TVROOT)) {
  4057. DoAbout(hDlg, pTVWnd, pItem);
  4058. }
  4059. pTVWnd->MousePos = 0;
  4060. return(NULL);
  4061. default:
  4062. break;
  4063. }
  4064. }
  4065. if (!(dw = (DWORD)GetWindowLongPtr(hCtrl, GWLP_USERDATA))) {
  4066. CPSUIDBG(DBG_CS,
  4067. ("DoDlgCmd: dw=0, wParam=%08lx, lParam=%08lx", wParam, hCtrl));
  4068. return(NULL);
  4069. }
  4070. GETCTRLDATA(dw, ItemIdx, CtrlStyle, CtrlData);
  4071. CPSUIDBG(DBG_CS, ("ID=%ld, LoW=%ld, HiW=%ld, Idx=%ld, Style=0x%02lx, Data=%ld",
  4072. (DWORD)GetDlgCtrlID(hCtrl), (LONG)((SHORT)LoW),
  4073. (LONG)((SHORT)HiW), (DWORD)ItemIdx, (DWORD)CtrlStyle, (DWORD)CtrlData));
  4074. //
  4075. // Validate what we got
  4076. //
  4077. if ((!(pItem = GetOptions(pTVWnd, MAKELPARAM(ItemIdx, 0)))) ||
  4078. (!(pOptType = GET_POPTTYPE(pItem))) ||
  4079. ((Type = pOptType->Type) > TVOT_LAST) ||
  4080. (pItem->Flags & (OPTIF_DISABLED | OPTIF_ITEM_HIDE))) {
  4081. CPSUIINT(("COMMAND: Invalid hCtrl or disable/hide Idx=%ld", ItemIdx));
  4082. CPSUIINT(("ID=%ld, LoW=%ld, HiW=%ld, CtrlStyle=0x%02lx, CtrlData=%ld",
  4083. (DWORD)GetDlgCtrlID(hCtrl), (LONG)((SHORT)LoW),
  4084. (LONG)((SHORT)HiW), (DWORD)CtrlStyle, (DWORD)CtrlData));
  4085. return(NULL);
  4086. }
  4087. if (!(pTVWnd->Flags & TWF_CAN_UPDATE)) {
  4088. if ((pItem == PIDX_INTOPTITEM(pTVWnd, INTIDX_TVROOT)) ||
  4089. ((CtrlStyle == CTRLS_PUSHBUTTON) &&
  4090. (pOptType->Flags & OTS_PUSH_ENABLE_ALWAYS))) {
  4091. NULL;
  4092. } else {
  4093. CPSUIINT(("ID=%ld, CtrlStyle=0x%02lx, ENABLE_EVEN_NO_UPDATE=0",
  4094. (DWORD)GetDlgCtrlID(hCtrl), (DWORD)CtrlStyle));
  4095. return(NULL);
  4096. }
  4097. }
  4098. pOptParam = pOptType->pOptParam;
  4099. pSel = pItem->pSel;
  4100. Type = pOptType->Type;
  4101. IsLB = TRUE;
  4102. IDGetItemData = LB_GETITEMDATA;
  4103. switch (CtrlStyle) {
  4104. case CTRLS_PROPPAGE_ICON:
  4105. switch (HiW) {
  4106. case STN_CLICKED:
  4107. case STN_DBLCLK:
  4108. CPSUIASSERT(0, "CTRLS_PROPAGE_ICON but TVOT=%ld",
  4109. (Type == TVOT_2STATES) ||
  4110. (Type == TVOT_3STATES) ||
  4111. (Type == TVOT_CHKBOX), Type);
  4112. SetFocus(GetDlgItem(hDlg, LoW - 1));
  4113. if (Type == TVOT_CHKBOX) {
  4114. CtrlStyle = CTRLS_CHKBOX;
  4115. NewSel = (pItem->Sel) ? 0 : 1;
  4116. CheckDlgButton(hDlg,
  4117. LoW - 1,
  4118. (NewSel) ? BST_CHECKED : BST_UNCHECKED);
  4119. } else {
  4120. BegSel = (DWORD)(pOptType->BegCtrlID + 2);
  4121. EndSel = BegSel + (DWORD)(((Type - TVOT_2STATES) + 1) << 1);
  4122. CtrlStyle = CTRLS_RADIO;
  4123. NewSel = (LONG)CtrlData;
  4124. CheckRadioButton(hDlg, BegSel, EndSel, LoW - 1);
  4125. }
  4126. HasSel = TRUE;
  4127. }
  4128. break;
  4129. case CTRLS_ECBICON:
  4130. switch (HiW) {
  4131. case STN_CLICKED:
  4132. case STN_DBLCLK:
  4133. CPSUIASSERT(0, "CTRLS_ECBICON but NO pExtChkBox",
  4134. pItem->pExtChkBox, 0);
  4135. //
  4136. // Flip the selection
  4137. //
  4138. NewSel = (pItem->Flags & OPTIF_ECB_CHECKED) ? 0 : 1;
  4139. SetFocus(GetDlgItem(hDlg, LoW - 1));
  4140. CheckDlgButton(hDlg,
  4141. LoW - 1,
  4142. (NewSel) ? BST_CHECKED : BST_UNCHECKED);
  4143. CtrlStyle = CTRLS_EXTCHKBOX;
  4144. HasSel = TRUE;
  4145. }
  4146. break;
  4147. case CTRLS_RADIO:
  4148. CPSUIASSERT(0, "CTRLS_RADIO but TVOT=%ld",
  4149. (Type == TVOT_2STATES) || (Type == TVOT_3STATES), Type);
  4150. if (HiW == BN_CLICKED) {
  4151. HasSel = TRUE;
  4152. NewSel = CtrlData;
  4153. }
  4154. break;
  4155. case CTRLS_UDARROW_EDIT:
  4156. #if (DO_IN_PLACE == 0)
  4157. CPSUIASSERT(0, "CTRLS_UDARROW_EDIT but TVOT=%ld",
  4158. (Type == TVOT_UDARROW), Type);
  4159. #endif
  4160. CPSUIDBG(DBG_UDARROW, ("UDArrow, hEdit=%08lx (%ld), hUDArrow=%08lx (%ld), CtrlData=0x%02lx",
  4161. hCtrl, GetDlgCtrlID(hCtrl), GetWindow(hCtrl, GW_HWNDNEXT),
  4162. GetDlgCtrlID(GetWindow(hCtrl, GW_HWNDNEXT)), CtrlData));
  4163. switch (HiW) {
  4164. case EN_UPDATE:
  4165. if (_OI_INTFLAGS(pItem) & OIDF_IN_EN_UPDATE) {
  4166. return(NULL);
  4167. } else {
  4168. _OI_INTFLAGS(pItem) |= OIDF_IN_EN_UPDATE;
  4169. NewSel = pItem->Sel;
  4170. if (HasSel = ValidateUDArrow(hDlg,
  4171. hCtrl,
  4172. CtrlData,
  4173. &(pItem->Sel),
  4174. (LONG)pOptParam[1].IconID,
  4175. (LONG)pOptParam[1].lParam)) {
  4176. CPSUIINT(("UDARROW: EN_UPDATE: OldSel=%ld, NewSel=%ld",
  4177. NewSel, pItem->Sel));
  4178. NewSel = pItem->Sel;
  4179. pItem->Sel = ~(DWORD)NewSel;
  4180. }
  4181. _OI_INTFLAGS(pItem) &= ~OIDF_IN_EN_UPDATE;
  4182. }
  4183. break;
  4184. case EN_SETFOCUS:
  4185. PostMessage(hCtrl, EM_SETSEL, 0, -1L);
  4186. break;
  4187. }
  4188. break;
  4189. case CTRLS_TRACKBAR:
  4190. CPSUIASSERT(0, "CTRLS_TRACKBAR but TVOT=%ld",
  4191. (Type == TVOT_TRACKBAR), Type);
  4192. switch (LoW) {
  4193. case TB_TOP:
  4194. case TB_BOTTOM:
  4195. case TB_ENDTRACK:
  4196. case TB_LINEDOWN:
  4197. case TB_LINEUP:
  4198. case TB_PAGEDOWN:
  4199. case TB_PAGEUP:
  4200. NewSel = (DWORD)SendMessage(hCtrl, TBM_GETPOS, 0, 0L);
  4201. break;
  4202. case TB_THUMBPOSITION:
  4203. case TB_THUMBTRACK:
  4204. NewSel = (LONG)((SHORT)HiW);
  4205. break;
  4206. default:
  4207. return(NULL);
  4208. }
  4209. HasSel = TRUE;
  4210. break;
  4211. case CTRLS_HSCROLL:
  4212. CPSUIASSERT(0, "CTRLS_HSCROLL but TVOT=%ld",
  4213. (Type == TVOT_SCROLLBAR), Type);
  4214. NewSel = (LONG)LODWORD(pSel);
  4215. switch (LoW) {
  4216. case SB_PAGEUP:
  4217. NewSel -= (LONG)(SHORT)pOptParam[2].lParam;
  4218. break;
  4219. case SB_PAGEDOWN:
  4220. NewSel += (LONG)(SHORT)pOptParam[2].lParam;
  4221. break;
  4222. case SB_LINEUP:
  4223. --NewSel;
  4224. break;
  4225. case SB_LINEDOWN:
  4226. ++NewSel;
  4227. break;
  4228. case SB_TOP:
  4229. NewSel = (LONG)pOptParam[1].IconID;
  4230. break;
  4231. case SB_BOTTOM:
  4232. NewSel = (LONG)pOptParam[1].lParam;
  4233. break;
  4234. case SB_THUMBPOSITION:
  4235. case SB_THUMBTRACK:
  4236. NewSel = (LONG)((SHORT)HiW);
  4237. break;
  4238. default:
  4239. return(NULL);
  4240. }
  4241. if (NewSel < (LONG)pOptParam[1].IconID) {
  4242. NewSel = (LONG)pOptParam[1].IconID;
  4243. } else if (NewSel > (LONG)pOptParam[1].lParam) {
  4244. NewSel = (LONG)pOptParam[1].lParam;
  4245. }
  4246. SendMessage(hCtrl, SBM_SETPOS, (WPARAM)NewSel, (LPARAM)TRUE);
  4247. HasSel = TRUE;
  4248. break;
  4249. case CTRLS_COMBOBOX:
  4250. IsLB = FALSE;
  4251. if (HiW == CBN_SELCHANGE) {
  4252. //
  4253. // make CBN_SELCHANGE to LBN_SELCHANGE
  4254. //
  4255. IDGetItemData = CB_GETITEMDATA;
  4256. HiW = LBN_SELCHANGE;
  4257. } else {
  4258. switch (HiW) {
  4259. case CBN_CLOSEUP:
  4260. //
  4261. // When close up the drop down box, we post another selection
  4262. // message if selection really changed, and then process the
  4263. // CBN_SELCHANGE because the drop down box is closed
  4264. //
  4265. CurSel = (INT)SendMessage(hCtrl, CB_GETCURSEL, 0, 0);
  4266. SelIdx = (INT_PTR)GetProp(hCtrl, CPSUIPROP_CBPRESEL) - 1;
  4267. if (CurSel != SelIdx) {
  4268. PostMessage(hDlg,
  4269. WM_COMMAND,
  4270. MAKEWPARAM(GetDlgCtrlID(hCtrl), CBN_SELCHANGE),
  4271. (LPARAM)hCtrl);
  4272. }
  4273. break;
  4274. case CBN_DROPDOWN:
  4275. //
  4276. // When combo box is selected, remember what selection we
  4277. // start with
  4278. //
  4279. SelIdx = (INT)SendMessage(hCtrl, CB_GETCURSEL, 0, 0);
  4280. SetProp(hCtrl, CPSUIPROP_CBPRESEL, (HANDLE)(SelIdx + 1));
  4281. CPSUIDBG(DBG_CBWNDPROC, ("CBN_DROPDOWN: SelIdx=%ld", SelIdx));
  4282. break;
  4283. }
  4284. break;
  4285. }
  4286. //
  4287. // Fall through
  4288. //
  4289. case CTRLS_LISTBOX:
  4290. #if (DO_IN_PLACE == 0)
  4291. CPSUIASSERT(0, "CTRLS_LISTBOX/CTRLS_COMBOBOX but TVOT=%ld",
  4292. (Type == TVOT_COMBOBOX) ||
  4293. (Type == TVOT_LISTBOX) || (Type == CtrlData), Type);
  4294. #endif
  4295. switch (HiW) {
  4296. case LBN_SELCHANGE:
  4297. SelIdx = (INT)SendMessage(hCtrl,
  4298. (IsLB) ? LB_GETCURSEL : CB_GETCURSEL,
  4299. 0,
  4300. 0);
  4301. dw = (DWORD)SendMessage(hCtrl, IDGetItemData, SelIdx, 0L);
  4302. if (dw & LBCBID_DISABLED) {
  4303. SelIdx = (INT)FindNextLBCBSel(hCtrl,
  4304. (LONG)_OI_LBCBSELIDX(pItem),
  4305. (LONG)SelIdx,
  4306. IDGetItemData,
  4307. &dw);
  4308. PostMessage(hCtrl,
  4309. (IsLB) ? LB_SETCURSEL : CB_SETCURSEL,
  4310. (WPARAM)SelIdx,
  4311. 0L);
  4312. }
  4313. if (dw & (LBCBID_NONE | LBCBID_FILL)) {
  4314. NewSel = -1;
  4315. } else if (dw & LBCBID_DISABLED) {
  4316. CPSUIERR(("LBCB: Could not find not disable item"));
  4317. } else {
  4318. NewSel = (LONG)LOWORD(dw);
  4319. }
  4320. _OI_LBCBSELIDX(pItem) = (WORD)SelIdx;
  4321. if (!(HasSel = IsLB)) {
  4322. //
  4323. // If it is a CBN_SELCHANGE then we only really do SELCHAGE
  4324. // when the drop down box is closed, noticed, in compstui when
  4325. // a combobox is selected we always open the drop down box
  4326. //
  4327. if (!SendMessage(hCtrl, CB_GETDROPPEDSTATE, 0, 0)) {
  4328. HasSel = TRUE;
  4329. CPSUIDBG(DBG_CBWNDPROC, ("CBN_SELCHANGE: The DropDown Closed, SelIdx=%ld",
  4330. SelIdx));
  4331. }
  4332. }
  4333. CPSUIDBG(DBG_CS, ("LBCB Select Changed: SelIdx=%ld, NewSel=%ld",
  4334. SelIdx, NewSel));
  4335. break;
  4336. default:
  4337. return(NULL);
  4338. }
  4339. break;
  4340. case CTRLS_EDITBOX:
  4341. CPSUIASSERT(0, "CTRLS_EDITBOX but TVOT=%ld",
  4342. (Type == TVOT_EDITBOX), Type);
  4343. switch (HiW) {
  4344. case EN_CHANGE:
  4345. Len = (UINT)pOptParam[1].IconID;
  4346. if (pTVWnd->Flags & TWF_ANSI_CALL) {
  4347. GetWindowTextA(hCtrl, (LPSTR)pSel, Len);
  4348. } else {
  4349. GetWindowText(hCtrl, (LPTSTR)pSel, Len);
  4350. }
  4351. HasSel = TRUE;
  4352. NewSel = 0;
  4353. break;
  4354. case EN_SETFOCUS:
  4355. PostMessage(hCtrl, EM_SETSEL, 0, -1L);
  4356. break;
  4357. }
  4358. break;
  4359. case CTRLS_EXTPUSH:
  4360. CPSUIASSERT(0, "CTRLS_EXTPUSH but is not OPTIF_EXT_IS_EXTPUSH = %ld",
  4361. pItem->Flags & OPTIF_EXT_IS_EXTPUSH, ULongToPtr(pItem->Flags));
  4362. if (HiW == BN_CLICKED) {
  4363. PEXTPUSH pEP = pItem->pExtPush;
  4364. if (pItem == PIDX_INTOPTITEM(pTVWnd, INTIDX_TVROOT)) {
  4365. DoAbout(hDlg, pTVWnd, pItem);
  4366. } else {
  4367. HANDLE hDlgTemplate = NULL;
  4368. WORD DlgTemplateID = 0;
  4369. if (pEP->Flags & EPF_PUSH_TYPE_DLGPROC) {
  4370. if (pEP->Flags & EPF_USE_HDLGTEMPLATE) {
  4371. hDlgTemplate = pEP->hDlgTemplate;
  4372. } else {
  4373. DlgTemplateID = pEP->DlgTemplateID;
  4374. }
  4375. }
  4376. DoCallBack(hDlg,
  4377. pTVWnd,
  4378. pItem,
  4379. pItem->pSel,
  4380. (_CPSUICALLBACK)pEP->pfnCallBack,
  4381. hDlgTemplate,
  4382. DlgTemplateID,
  4383. CPSUICB_REASON_EXTPUSH);
  4384. }
  4385. }
  4386. break;
  4387. case CTRLS_PUSHBUTTON:
  4388. CPSUIASSERT(0, "CTRLS_PUSHBUTTON but TVOT=%ld",
  4389. (Type == TVOT_PUSHBUTTON), Type);
  4390. if (HiW == BN_CLICKED) {
  4391. NewSel = DoPushButton(hDlg, pTVWnd, pItem);
  4392. if ((pOptParam[0].Style != PUSHBUTTON_TYPE_CALLBACK) &&
  4393. (pTVWnd->Flags & TWF_CAN_UPDATE)) {
  4394. HasSel = TRUE;
  4395. pItem->Sel = (DWORD)~(DWORD)NewSel;
  4396. }
  4397. }
  4398. break;
  4399. case CTRLS_CHKBOX:
  4400. case CTRLS_EXTCHKBOX:
  4401. if (CtrlStyle == CTRLS_CHKBOX) {
  4402. CPSUIASSERT(0, "CTRLS_CHKBOX but TVOT=%ld",
  4403. (Type == TVOT_CHKBOX), Type);
  4404. } else {
  4405. CPSUIASSERT(0, "CTRLS_EXTCHKBOX but pExtChkBox=%ld",
  4406. (pItem->pExtChkBox != NULL), pItem->pExtChkBox);
  4407. }
  4408. if (HiW == BN_CLICKED) {
  4409. HasSel = TRUE;
  4410. NewSel = (LONG)SendMessage(hCtrl, BM_GETCHECK, 0, 0L);
  4411. }
  4412. break;
  4413. case CTRLS_UDARROW:
  4414. case CTRLS_TV_WND:
  4415. case CTRLS_TV_STATIC:
  4416. case CTRLS_PROPPAGE_STATIC:
  4417. case CTRLS_NOINPUT:
  4418. CPSUIINT(("Static CTRLS_xxx = %ld", CtrlStyle));
  4419. return(NULL);
  4420. default:
  4421. CPSUIERR(("\nInternal ERROR: Invalid CTRLS_xxx=%02lx\n", CtrlStyle));
  4422. return(NULL);
  4423. }
  4424. if (HasSel) {
  4425. if (CtrlStyle == CTRLS_EXTCHKBOX) {
  4426. HasSel = (BOOL)((DWORD)(pItem->Flags & OPTIF_ECB_CHECKED) !=
  4427. (DWORD)((NewSel) ? OPTIF_ECB_CHECKED : 0));
  4428. } else {
  4429. HasSel = (BOOL)(pItem->Sel != NewSel);
  4430. }
  4431. if (HasSel) {
  4432. PMYDLGPAGE pCurMyDP;
  4433. PMYDLGPAGE pMyDP;
  4434. BYTE CurPageIdx;
  4435. BYTE DlgPageIdx;
  4436. BYTE TVPageIdx;
  4437. WORD Reason;
  4438. pCurMyDP = GET_PMYDLGPAGE(hDlg);
  4439. pMyDP = pTVWnd->pMyDlgPage;
  4440. CurPageIdx = pCurMyDP->PageIdx;
  4441. DlgPageIdx = pItem->DlgPageIdx;
  4442. TVPageIdx = pTVWnd->TVPageIdx;
  4443. CPSUIDBG(DBG_CS, ("Item Changed: CurPage=%ld, DlgPage=%ld, TVPageIdx=%ld",
  4444. (DWORD)CurPageIdx, (DWORD)DlgPageIdx, (DWORD)TVPageIdx));
  4445. //
  4446. // firstable mark current page to changed once.
  4447. //
  4448. pCurMyDP->Flags |= MYDPF_CHANGEONCE;
  4449. //
  4450. // If we are in the treeview page, then set the dirty flag if it
  4451. // belong to the other page
  4452. //
  4453. if (CurPageIdx == TVPageIdx) {
  4454. if (DlgPageIdx != CurPageIdx) {
  4455. pMyDP[DlgPageIdx].Flags |= (MYDPF_CHANGED |
  4456. MYDPF_CHANGEONCE);
  4457. pItem->Flags |= OPTIF_INT_CHANGED;
  4458. }
  4459. } else if (TVPageIdx != PAGEIDX_NONE) {
  4460. //
  4461. // Not in treeview page, so set the dirty bit for treeview
  4462. //
  4463. pMyDP[TVPageIdx].Flags |= (MYDPF_CHANGED | MYDPF_CHANGEONCE);
  4464. pItem->Flags |= OPTIF_INT_TV_CHANGED;
  4465. }
  4466. if (CtrlStyle == CTRLS_EXTCHKBOX) {
  4467. Reason = CPSUICB_REASON_ECB_CHANGED;
  4468. pItem->Flags ^= OPTIF_ECB_CHECKED;
  4469. } else {
  4470. Reason = CPSUICB_REASON_SEL_CHANGED;
  4471. if (CtrlStyle != CTRLS_EDITBOX) {
  4472. //
  4473. // In the case of CTRLS_EDITBOX, pItem->pSel is already the new value
  4474. //
  4475. pItem->Sel = NewSel;
  4476. }
  4477. }
  4478. pItem->Flags |= OPTIF_CHANGEONCE;
  4479. //
  4480. // Doing the internal DMPub first,
  4481. //
  4482. if (Len = UpdateInternalDMPUB(hDlg, pTVWnd, pItem)) {
  4483. UpdateCallBackChanges(hDlg, pTVWnd, Len & INTDMPUB_REINIT);
  4484. }
  4485. if ((pItem->Flags & OPTIF_CALLBACK) &&
  4486. (ItemIdx < pTVWnd->ComPropSheetUI.cOptItem)) {
  4487. DoCallBack(hDlg, pTVWnd, pItem, pSel, NULL, NULL, 0, Reason);
  4488. }
  4489. CPSUIOPTITEM(DBGITEM_CS, pTVWnd, "!! ChangeSelection !!", 1, pItem);
  4490. IsItemChangeOnce(pTVWnd, pItem);
  4491. SET_APPLY_BUTTON(pTVWnd, hDlg);
  4492. return(pItem);
  4493. }
  4494. }
  4495. return(NULL);
  4496. }