Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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