Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

982 lines
27 KiB

  1. /*
  2. * explorer - Dialog box property sheet for "explorer ui tweaks"
  3. */
  4. #include "tweakui.h"
  5. #pragma BEGIN_CONST_DATA
  6. typedef struct SCEI { /* Shortcut effect info */
  7. PCTSTR ptszDll;
  8. int iIcon;
  9. } SCEI;
  10. const SCEI CODESEG rgscei[] = {
  11. { g_tszPathShell32, 29 },
  12. { g_tszPathMe, IDI_ALTLINK - 1 },
  13. { g_tszPathMe, IDI_BLANK - 1 },
  14. };
  15. KL const c_klHackPtui = { &g_hkLMSMWCV, c_tszAppletTweakUI, c_tszHackPtui };
  16. KL const c_klLinkOvl = { &pcdii->hkLMExplorer, c_tszShellIcons, c_tszLinkOvl };
  17. KL const c_klWelcome = { &pcdii->hkCUExplorer, c_tszTips, c_tszShow };
  18. KL const c_klAltColor = { &pcdii->hkCUExplorer, 0, c_tszAltColor };
  19. KL const c_klHotlight = { &c_hkCU, c_tszCplColors, c_tszHotTrackColor };
  20. KL const c_klNoConnection = { &pcdii->hkCUExplorer, 0, TEXT("NoFileFolderConnection") };
  21. #define clrDefAlt RGB(0x00, 0x00, 0xFF)
  22. #define clrDefHot RGB(0x00, 0x00, 0xFF)
  23. const static DWORD CODESEG rgdwHelp[] = {
  24. IDC_LINKGROUP, IDH_LINKEFFECT,
  25. IDC_LINKARROW, IDH_LINKEFFECT,
  26. IDC_LIGHTARROW, IDH_LINKEFFECT,
  27. IDC_NOARROW, IDH_LINKEFFECT,
  28. IDC_CUSTOMARROW, IDH_LINKEFFECT,
  29. IDC_CUSTOMCHANGE, IDH_LINKEFFECT,
  30. IDC_LINKBEFORETEXT, IDH_LINKEFFECT,
  31. IDC_LINKBEFORE, IDH_LINKEFFECT,
  32. IDC_LINKAFTERTEXT, IDH_LINKEFFECT,
  33. IDC_LINKAFTER, IDH_LINKEFFECT,
  34. IDC_LINKHELP, IDH_LINKEFFECT,
  35. IDC_SETGROUP, IDH_GROUP,
  36. IDC_CLRGROUP, IDH_GROUP,
  37. IDC_COMPRESSTXT, IDH_COMPRESSCLR,
  38. IDC_COMPRESSCLR, IDH_COMPRESSCLR,
  39. IDC_COMPRESSBTN, IDH_COMPRESSCLR,
  40. IDC_HOTTRACKTXT, IDH_HOTTRACKCLR,
  41. IDC_HOTTRACKCLR, IDH_HOTTRACKCLR,
  42. IDC_HOTTRACKBTN, IDH_HOTTRACKCLR,
  43. IDC_RESET, IDH_RESET,
  44. 0, 0,
  45. };
  46. #pragma END_CONST_DATA
  47. /*****************************************************************************
  48. *
  49. * CustomColor
  50. *
  51. * A little class the manages the little custom color buttons.
  52. *
  53. *****************************************************************************/
  54. class CustomColor {
  55. public:
  56. void Init(HWND hwnd);
  57. void Destroy();
  58. void SetColor(COLORREF clr);
  59. COLORREF GetColor();
  60. private:
  61. COLORREF _clr; /* The color */
  62. HWND _hwnd; /* Button control we party on */
  63. HBITMAP _hbm; /* Solid bitmap for button */
  64. RECT _rc; /* Rectangle dimensions of bitmap */
  65. };
  66. /*****************************************************************************
  67. *
  68. * CustomColor::Init
  69. *
  70. * Say which control is in charge.
  71. *
  72. *****************************************************************************/
  73. void CustomColor::Init(HWND hwnd)
  74. {
  75. HDC hdc;
  76. _hwnd = hwnd;
  77. GetClientRect(_hwnd, &_rc);
  78. hdc = GetDC(hwnd);
  79. if (hdc) {
  80. _hbm = CreateCompatibleBitmap(hdc, _rc.right, _rc.bottom);
  81. ReleaseDC(hwnd, hdc);
  82. } else {
  83. _hbm = NULL;
  84. }
  85. SendMessage(_hwnd, BM_SETIMAGE, IMAGE_BITMAP, (LPARAM)_hbm);
  86. }
  87. /*****************************************************************************
  88. *
  89. * CustomColor::Destroy
  90. *
  91. * Clean up the custom color stuff.
  92. *
  93. *****************************************************************************/
  94. void
  95. CustomColor::Destroy()
  96. {
  97. if (_hwnd) {
  98. SendMessage(_hwnd, BM_SETIMAGE, IMAGE_BITMAP, (LPARAM)NULL);
  99. }
  100. if (_hbm) {
  101. DeleteObject(_hbm);
  102. }
  103. }
  104. /*****************************************************************************
  105. *
  106. * CustomColor::SetColor
  107. *
  108. * Set the custom color.
  109. *
  110. *****************************************************************************/
  111. void
  112. CustomColor::SetColor(COLORREF clr)
  113. {
  114. /*
  115. * Fill the bitmap with the new color.
  116. */
  117. _clr = clr;
  118. HDC hdc = CreateCompatibleDC(NULL);
  119. if (hdc) {
  120. HBITMAP hbmPrev = SelectBitmap(hdc, _hbm);
  121. SetBkColor(hdc, _clr);
  122. ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &_rc, NULL, 0, NULL);
  123. SelectObject(hdc, hbmPrev);
  124. DeleteDC(hdc);
  125. }
  126. /*
  127. * Okay, repaint with the new bitmap.
  128. */
  129. InvalidateRect(_hwnd, NULL, TRUE);
  130. }
  131. /*****************************************************************************
  132. *
  133. * CustomColor::GetColor
  134. *
  135. * Get the custom color.
  136. *
  137. *****************************************************************************/
  138. COLORREF __inline
  139. CustomColor::GetColor()
  140. {
  141. return _clr;
  142. }
  143. /*****************************************************************************
  144. *
  145. * EDII
  146. *
  147. *****************************************************************************/
  148. typedef struct EDII {
  149. HIMAGELIST himl; /* Private image list */
  150. WNDPROC wpAfter; /* Subclass procedure */
  151. UINT idcCurEffect; /* currently selected effect */
  152. BOOL fIconDirty; /* if the shortcut icon is dirty */
  153. int iIcon; /* Custom shortcut effect icon */
  154. CustomColor ccComp; /* Compressed files */
  155. CustomColor ccHot; /* Hot-track */
  156. TCH tszPathDll[MAX_PATH]; /* Custom shortcut effect dll */
  157. } EDII, *PEDII;
  158. EDII edii;
  159. #define pedii (&edii)
  160. /*****************************************************************************
  161. *
  162. * GetRestriction
  163. *
  164. * Determine whether a restriction is set. Restrictions are reverse-sense,
  165. * so we un-reverse them here, so that this returns 1 if the feature is
  166. * enabled.
  167. *
  168. *****************************************************************************/
  169. BOOL PASCAL
  170. GetRestriction(LPCTSTR ptszKey)
  171. {
  172. return GetRegDword(g_hkCUSMWCV, c_tszRestrictions, ptszKey, 0) == 0;
  173. }
  174. /*****************************************************************************
  175. *
  176. * SetRestriction
  177. *
  178. * Set a restriction. Again, since restrictions are reverse-sense, we
  179. * un-reverse them here, so that passing 1 enables the feature.
  180. *
  181. *****************************************************************************/
  182. BOOL PASCAL
  183. SetRestriction(LPCTSTR ptszKey, BOOL f)
  184. {
  185. return SetRegDword(g_hkCUSMWCV, c_tszRestrictions, ptszKey, !f);
  186. }
  187. /*****************************************************************************
  188. *
  189. * Explorer_HackPtui
  190. *
  191. * Patch up a bug in comctl32, where a blank overlay image gets
  192. * the wrong rectangle set into it because comctl32 gets confused
  193. * when all the pixels are transparent. As a result, the link
  194. * overlay becomes THE ENTIRE IMAGELIST instead of nothing.
  195. *
  196. * We do this by (hack!) swiping himlIcons and himlIconsSmall
  197. * from SHELL32, and then (ptui!) partying DIRECTLY INTO THEM
  198. * and fixing up the rectangle coordinates.
  199. *
  200. * I'm really sorry I have to do this, but if I don't, people will
  201. * just keep complaining.
  202. *
  203. * Helper procedures:
  204. *
  205. * Explorer_HackPtuiCough - fixes one himl COMCTL32's data structures.
  206. *
  207. *****************************************************************************/
  208. /*
  209. * On entry to Explorer_HackPtuiCough, the pointer has already been
  210. * validated.
  211. */
  212. BOOL PASCAL
  213. Explorer_HackPtuiCough(LPBYTE lpb, LPVOID pvRef)
  214. {
  215. #if 0
  216. if (*(LPWORD)lpb == 0x4C49 &&
  217. *(LPDWORD)(lpb + 0x78) == 0 && *(LPDWORD)(lpb + 0x88) == 0) {
  218. #else
  219. if (*(LPWORD)lpb == 0x4C49) {
  220. #endif
  221. *(LPDWORD)(lpb + 0x78) = 1;
  222. *(LPDWORD)(lpb + 0x88) = 1;
  223. return 1;
  224. } else {
  225. return 0;
  226. }
  227. }
  228. void PASCAL
  229. Explorer_HackPtui(void)
  230. {
  231. if (g_fBuggyComCtl32 && GetIntPkl(0, &c_klHackPtui)) {
  232. if (WithSelector((DWORD_PTR)GetSystemImageList(0),
  233. 0x8C, (WITHPROC)Explorer_HackPtuiCough, 0, 1) &&
  234. WithSelector((DWORD_PTR)GetSystemImageList(SHGFI_SMALLICON),
  235. 0x8C, (WITHPROC)Explorer_HackPtuiCough, 0, 1)) {
  236. RedrawWindow(0, 0, 0, RDW_INVALIDATE | RDW_ALLCHILDREN);
  237. }
  238. }
  239. }
  240. /*****************************************************************************
  241. *
  242. * Explorer_SetAfterImage
  243. *
  244. * The link overlay image has changed, so update the "after" image, too.
  245. * All we have to do is invalidate the window; our WM_PAINT handler will
  246. * paint the new effect.
  247. *
  248. *****************************************************************************/
  249. INLINE void
  250. Explorer_SetAfterImage(HWND hdlg)
  251. {
  252. InvalidateRect(GetDlgItem(hdlg, IDC_LINKAFTER), 0, 1);
  253. }
  254. /*****************************************************************************
  255. *
  256. * Explorer_After_OnPaint
  257. *
  258. * Paint the merged images.
  259. *
  260. * I used to use ILD_TRANSPARENT, except for some reason the background
  261. * wasn't erased by WM_ERASEBKGND. (Probably because statics don't
  262. * process that message.)
  263. *
  264. *****************************************************************************/
  265. LRESULT PASCAL
  266. Explorer_After_OnPaint(HWND hwnd)
  267. {
  268. PAINTSTRUCT ps;
  269. HDC hdc = BeginPaint(hwnd, &ps);
  270. if (hdc) {
  271. ImageList_SetBkColor(pedii->himl, GetSysColor(COLOR_BTNFACE));
  272. ImageList_Draw(pedii->himl, 0, hdc, 0, 0,
  273. ILD_NORMAL | INDEXTOOVERLAYMASK(1));
  274. EndPaint(hwnd, &ps);
  275. }
  276. return 0;
  277. }
  278. /*****************************************************************************
  279. *
  280. * Explorer_After_WndProc
  281. *
  282. * Subclass window procedure for the after-image.
  283. *
  284. *****************************************************************************/
  285. LRESULT EXPORT
  286. Explorer_After_WndProc(HWND hwnd, UINT wm, WPARAM wp, LPARAM lp)
  287. {
  288. switch (wm) {
  289. case WM_PAINT: return Explorer_After_OnPaint(hwnd);
  290. }
  291. return CallWindowProc(pedii->wpAfter, hwnd, wm, wp, lp);
  292. }
  293. /*****************************************************************************
  294. *
  295. * Explorer_GetIconSpecFromRegistry
  296. *
  297. * The output buffer must be MAX_PATH characters in length.
  298. *
  299. * Returns the icon index.
  300. *
  301. *****************************************************************************/
  302. int PASCAL
  303. Explorer_GetIconSpecFromRegistry(LPTSTR ptszBuf)
  304. {
  305. int iIcon;
  306. if (GetStrPkl(ptszBuf, cbCtch(MAX_PATH), &c_klLinkOvl)) {
  307. iIcon = ParseIconSpec(ptszBuf);
  308. } else {
  309. ptszBuf[0] = TEXT('\0');
  310. iIcon = 0;
  311. }
  312. return iIcon;
  313. }
  314. /*****************************************************************************
  315. *
  316. * Explorer_RefreshOverlayImage
  317. *
  318. * There was a change to the shortcut effects. Put a new overlay
  319. * image into the imagelist and update the After image as well.
  320. *
  321. *****************************************************************************/
  322. void PASCAL
  323. Explorer_RefreshOverlayImage(HWND hdlg)
  324. {
  325. HICON hicon = ExtractIcon(hinstCur, pedii->tszPathDll, pedii->iIcon);
  326. if ((UINT_PTR)hicon <= 1) {
  327. hicon = ExtractIcon(hinstCur, g_tszPathShell32, 29); /* default */
  328. }
  329. ImageList_ReplaceIcon(pedii->himl, 1, hicon);
  330. SafeDestroyIcon(hicon);
  331. Explorer_SetAfterImage(hdlg);
  332. }
  333. /*****************************************************************************
  334. *
  335. * Explorer_OnEffectChange
  336. *
  337. * There was a change to the shortcut effects.
  338. *
  339. * Put the new effect icon into the image list and update stuff.
  340. *
  341. *****************************************************************************/
  342. void PASCAL
  343. Explorer_OnEffectChange(HWND hdlg, UINT id)
  344. {
  345. if (id != pedii->idcCurEffect) {
  346. if (id == IDC_CUSTOMARROW) {
  347. EnableDlgItem(hdlg, IDC_CUSTOMCHANGE, TRUE);
  348. } else {
  349. EnableDlgItem(hdlg, IDC_CUSTOMCHANGE, FALSE);
  350. lstrcpy(pedii->tszPathDll, rgscei[id - IDC_LINKFIRST].ptszDll);
  351. pedii->iIcon = rgscei[id - IDC_LINKFIRST].iIcon;
  352. }
  353. pedii->idcCurEffect = id;
  354. pedii->fIconDirty = 1;
  355. Explorer_RefreshOverlayImage(hdlg);
  356. Common_SetDirty(hdlg);
  357. }
  358. }
  359. /*****************************************************************************
  360. *
  361. * Explorer_ChangeEffect
  362. *
  363. * The user wants to customize the link effect.
  364. *
  365. *****************************************************************************/
  366. void PASCAL
  367. Explorer_ChangeEffect(HWND hdlg)
  368. {
  369. if (PickIcon(hdlg, pedii->tszPathDll, cA(pedii->tszPathDll),
  370. &pedii->iIcon)) {
  371. pedii->fIconDirty = 1;
  372. Explorer_RefreshOverlayImage(hdlg);
  373. Common_SetDirty(hdlg);
  374. }
  375. }
  376. #if 0
  377. /*****************************************************************************
  378. *
  379. * Explorer_FactoryReset
  380. *
  381. * Restore to factory settings.
  382. *
  383. *****************************************************************************/
  384. BOOL PASCAL
  385. Explorer_FactoryReset(HWND hdlg)
  386. {
  387. if (pedii->idcCurEffect != IDC_LINKARROW) {
  388. if (pedii->idcCurEffect) {
  389. CheckDlgButton(hdlg, pedii->idcCurEffect, 0);
  390. }
  391. CheckDlgButton(hdlg, IDC_LINKARROW, 1);
  392. Explorer_OnEffectChange(hdlg, IDC_LINKARROW);
  393. }
  394. CheckDlgButton(hdlg, IDC_PREFIX, 1);
  395. CheckDlgButton(hdlg, IDC_EXITSAVE, 1);
  396. CheckDlgButton(hdlg, IDC_BANNER, 1);
  397. CheckDlgButton(hdlg, IDC_WELCOME, 1);
  398. if (mit.ReadCabinetState) {
  399. CheckDlgButton(hdlg, IDC_MAKEPRETTY, 1);
  400. pedii->ccComp.SetColor(clrDefAlt);
  401. }
  402. if (GetSysColorBrush(COLOR_HOTLIGHT)) {
  403. pedii->ccHot.SetColor(clrDefHot);
  404. }
  405. Common_SetDirty(hdlg);
  406. return 1;
  407. }
  408. #endif
  409. /*****************************************************************************
  410. *
  411. * Explorer_ChangeColor
  412. *
  413. *****************************************************************************/
  414. BOOL PASCAL
  415. Explorer_ChangeColor(HWND hdlg, int id)
  416. {
  417. CHOOSECOLOR cc;
  418. CustomColor *pcc = id == IDC_COMPRESSBTN ? &pedii->ccComp : &pedii->ccHot;
  419. DWORD rgdw[16];
  420. HKEY hk;
  421. ZeroMemory(rgdw, cbX(rgdw));
  422. if (RegOpenKey(HKEY_CURRENT_USER, c_tszRegPathAppearance, &hk) == 0) {
  423. DWORD cb = cbX(rgdw);
  424. RegQueryValueEx(hk, c_tszCustomColors, 0, 0, (LPBYTE)rgdw, &cb);
  425. RegCloseKey(hk);
  426. }
  427. cc.lStructSize = cbX(cc);
  428. cc.hwndOwner = hdlg;
  429. cc.rgbResult = pcc->GetColor();
  430. cc.lpCustColors = rgdw;
  431. cc.Flags = CC_RGBINIT;
  432. if (ChooseColor(&cc) && pcc->GetColor() != cc.rgbResult) {
  433. pcc->SetColor(cc.rgbResult);
  434. Common_SetDirty(hdlg);
  435. }
  436. return 1;
  437. }
  438. /*****************************************************************************
  439. *
  440. * Explorer_OnCommand
  441. *
  442. * Ooh, we got a command.
  443. *
  444. *****************************************************************************/
  445. void PASCAL
  446. Explorer_OnCommand(HWND hdlg, int id, UINT codeNotify)
  447. {
  448. switch (id) {
  449. case IDC_LINKARROW:
  450. case IDC_LIGHTARROW:
  451. case IDC_NOARROW:
  452. case IDC_CUSTOMARROW:
  453. if (codeNotify == BN_CLICKED) {
  454. Explorer_OnEffectChange(hdlg, id);
  455. }
  456. break;
  457. case IDC_CUSTOMCHANGE:
  458. if (codeNotify == BN_CLICKED) Explorer_ChangeEffect(hdlg);
  459. break;
  460. case IDC_COMPRESSBTN:
  461. case IDC_HOTTRACKBTN:
  462. if (codeNotify == BN_CLICKED) Explorer_ChangeColor(hdlg, id);
  463. break;
  464. #if 0
  465. case IDC_RESET: /* Reset to factory default */
  466. if (codeNotify == BN_CLICKED) Explorer_FactoryReset(hdlg);
  467. break;
  468. #endif
  469. }
  470. }
  471. /*****************************************************************************
  472. *
  473. * Explorer_GetLinkPrefix
  474. * Explorer_SetLinkPrefix
  475. *
  476. *****************************************************************************/
  477. BOOL PASCAL
  478. Explorer_GetLinkPrefix(LPARAM lParam, LPVOID pvRef)
  479. {
  480. return Link_GetShortcutTo();
  481. }
  482. BOOL PASCAL
  483. Explorer_SetLinkPrefix(BOOL f, LPARAM lParam, LPVOID pvRef)
  484. {
  485. if (!Link_SetShortcutTo(f) && pvRef) {
  486. LPBOOL pf = (LPBOOL)pvRef;
  487. *pf = TRUE;
  488. }
  489. return TRUE;
  490. }
  491. /*****************************************************************************
  492. *
  493. * Explorer_GetRestriction
  494. * Explorer_GetRestrictionClassic
  495. * Explorer_SetRestriction
  496. *
  497. *****************************************************************************/
  498. BOOL PASCAL
  499. Explorer_GetRestriction(LPARAM lParam, LPVOID pvRef)
  500. {
  501. LPCTSTR pszRest = (LPCTSTR)pvRef;
  502. return GetRestriction(pszRest);
  503. }
  504. BOOL PASCAL
  505. Explorer_GetRestrictionClassic(LPARAM lParam, LPVOID pvRef)
  506. {
  507. if (g_fIE4) {
  508. return -1;
  509. } else {
  510. LPCTSTR pszRest = (LPCTSTR)pvRef;
  511. return GetRestriction(pszRest);
  512. }
  513. }
  514. BOOL PASCAL
  515. Explorer_SetRestriction(BOOL f, LPARAM lParam, LPVOID pvRef)
  516. {
  517. LPCTSTR pszRest = (LPCTSTR)pvRef;
  518. BOOL fRc = SetRestriction(pszRest, f);
  519. return fRc;
  520. }
  521. /*****************************************************************************
  522. *
  523. * Explorer_GetWelcome
  524. * Explorer_SetWelcome
  525. *
  526. *****************************************************************************/
  527. BOOL PASCAL
  528. Explorer_GetWelcome(LPARAM lParam, LPVOID pvRef)
  529. {
  530. if (g_fIE4) {
  531. return -1;
  532. } else {
  533. return GetDwordPkl(&c_klWelcome, 1);
  534. }
  535. }
  536. BOOL PASCAL
  537. Explorer_SetWelcome(BOOL f, LPARAM lParam, LPVOID pvRef)
  538. {
  539. BOOL fRc = SetDwordPkl(&c_klWelcome, f);
  540. return fRc;
  541. }
  542. /*****************************************************************************
  543. *
  544. * Explorer_Get8Dot3
  545. * Explorer_Set8Dot3
  546. *
  547. * The setting is valid only if ReadCabinetState exists and we are not v5.
  548. *
  549. *****************************************************************************/
  550. BOOL PASCAL
  551. Explorer_Get8Dot3(LPARAM lParam, LPVOID pvRef)
  552. {
  553. CABINETSTATE cs;
  554. if (!g_fShell5 && mit.ReadCabinetState && mit.ReadCabinetState(&cs, cbX(cs))) {
  555. return !cs.fDontPrettyNames;
  556. } else {
  557. return -1;
  558. }
  559. }
  560. BOOL PASCAL
  561. Explorer_Set8Dot3(BOOL f, LPARAM lParam, LPVOID pvRef)
  562. {
  563. BOOL fRc = FALSE;
  564. CABINETSTATE cs;
  565. if (mit.ReadCabinetState(&cs, cbX(cs))) {
  566. if (cs.fDontPrettyNames == f) {
  567. fRc = TRUE;
  568. } else {
  569. cs.fDontPrettyNames = f;
  570. fRc = mit.WriteCabinetState(&cs);
  571. if (fRc && pvRef) {
  572. LPBOOL pf = (LPBOOL)pvRef;
  573. *pf = TRUE;
  574. }
  575. }
  576. }
  577. return fRc;
  578. }
  579. /*****************************************************************************
  580. *
  581. * Explorer_GetConnectedFiles
  582. * Explorer_SetConnectedFiles
  583. *
  584. *****************************************************************************/
  585. BOOL PASCAL
  586. Explorer_GetConnectedFiles(LPARAM lParam, LPVOID pvRef)
  587. {
  588. if (g_fShell5) {
  589. return !GetDwordPkl(&c_klNoConnection, 0);
  590. } else {
  591. return -1;
  592. }
  593. }
  594. BOOL PASCAL
  595. Explorer_SetConnectedFiles(BOOL f, LPARAM lParam, LPVOID pvRef)
  596. {
  597. BOOL fRc = SetDwordPkl(&c_klNoConnection, !f);
  598. return fRc;
  599. }
  600. /*****************************************************************************
  601. *
  602. * c_rgcliExplorer
  603. *
  604. *****************************************************************************/
  605. /*
  606. * Note that this needs to be in sync with the IDS_EXPLOREREFFECTS
  607. * strings.
  608. */
  609. CHECKLISTITEM c_rgcliExplorer[] = {
  610. { Explorer_GetLinkPrefix, Explorer_SetLinkPrefix, 0, },
  611. { Explorer_GetRestriction, Explorer_SetRestriction, (LPARAM)c_tszNoExitSave, },
  612. { Explorer_GetRestrictionClassic, Explorer_SetRestriction, (LPARAM)c_tszNoBanner, },
  613. { Explorer_GetWelcome, Explorer_SetWelcome, 0, },
  614. { Explorer_Get8Dot3, Explorer_Set8Dot3, 0, },
  615. { Explorer_GetConnectedFiles,
  616. Explorer_SetConnectedFiles, 0 },
  617. };
  618. /*****************************************************************************
  619. *
  620. * Explorer_OnInitDialog
  621. *
  622. * Find out which link icon people are using.
  623. *
  624. * When we initialize the image list, we just throw something random
  625. * into position 1. Explorer_OnEffectChange will put the right thing in.
  626. *
  627. *****************************************************************************/
  628. BOOL PASCAL
  629. Explorer_OnInitDialog(HWND hwndList)
  630. {
  631. int iscei;
  632. CABINETSTATE cs;
  633. HWND hdlg = GetParent(hwndList);
  634. pedii->iIcon = Explorer_GetIconSpecFromRegistry(pedii->tszPathDll);
  635. if (pedii->tszPathDll[0]) {
  636. for (iscei = 0; iscei < cA(rgscei); iscei++) {
  637. if (pedii->iIcon == rgscei[iscei].iIcon &&
  638. lstrcmpi(pedii->tszPathDll, rgscei[iscei].ptszDll) == 0) {
  639. break;
  640. }
  641. }
  642. } else {
  643. iscei = 0; /* Default */
  644. }
  645. if (iscei == IDC_LINKARROW - IDC_LINKFIRST && GetIntPkl(0, &c_klHackPtui)) {
  646. iscei = IDC_NOARROW - IDC_LINKFIRST;
  647. }
  648. /*
  649. * Don't need to listen to WM_SETTINGCHANGE because we place the
  650. * icon inside a static control which will not resize dynamically.
  651. */
  652. pedii->himl = ImageList_Create(GetSystemMetrics(SM_CXICON),
  653. GetSystemMetrics(SM_CYICON), 1,
  654. 2, 1);
  655. if (pedii->himl) {
  656. HICON hicon;
  657. hicon = (HICON)SendDlgItemMessage(hdlg, IDC_LINKBEFORE,
  658. STM_GETICON, 0, 0L);
  659. /* We start with whatever icon got dropped into IDC_BEFORE. */
  660. ImageList_AddIcon(pedii->himl, hicon); /* zero */
  661. ImageList_AddIcon(pedii->himl, hicon); /* one */
  662. if (pedii->tszPathDll[0]) {
  663. hicon = ExtractIcon(hinstCur, pedii->tszPathDll, pedii->iIcon);
  664. if (ImageList_AddIcon(pedii->himl, hicon) != 1) {
  665. /* Oh dear */
  666. }
  667. SafeDestroyIcon(hicon);
  668. }
  669. ImageList_SetOverlayImage(pedii->himl, 1, 1);
  670. pedii->wpAfter = SubclassWindow(GetDlgItem(hdlg, IDC_LINKAFTER),
  671. Explorer_After_WndProc);
  672. } else {
  673. /* Oh dear */
  674. }
  675. CheckDlgButton(hdlg, IDC_LINKFIRST + iscei, TRUE);
  676. pedii->idcCurEffect = -1;
  677. Explorer_OnEffectChange(hdlg, IDC_LINKFIRST + iscei);
  678. if (!RegCanModifyKey(pcdii->hkLMExplorer, c_tszShellIcons)) {
  679. EnableDlgItems(hdlg, IDC_LINKFIRST, IDC_LINKLAST, FALSE);
  680. }
  681. int iColorsLeft = 2;
  682. if (mit.ReadCabinetState && g_fNT) {
  683. pedii->ccComp.Init(GetDlgItem(hdlg, IDC_COMPRESSBTN));
  684. pedii->ccComp.SetColor(GetDwordPkl(&c_klAltColor, clrDefAlt));
  685. } else {
  686. DestroyDlgItems(hdlg, IDC_COMPRESSFIRST, IDC_COMPRESSLAST);
  687. iColorsLeft--;
  688. }
  689. /*
  690. * If COLOR_HOTLIGHT is supported, then do that too.
  691. */
  692. if (GetSysColorBrush(COLOR_HOTLIGHT)) {
  693. pedii->ccHot.Init(GetDlgItem(hdlg, IDC_HOTTRACKBTN));
  694. pedii->ccHot.SetColor(GetSysColor(COLOR_HOTLIGHT));
  695. } else {
  696. DestroyDlgItems(hdlg, IDC_HOTTRACKFIRST, IDC_HOTTRACKLAST);
  697. iColorsLeft--;
  698. }
  699. if (!iColorsLeft) {
  700. DestroyDlgItems(hdlg, IDC_CLRGROUP, IDC_CLRGROUP);
  701. }
  702. pedii->fIconDirty = 0;
  703. Checklist_OnInitDialog(hwndList, c_rgcliExplorer, cA(c_rgcliExplorer),
  704. IDS_EXPLOREREFFECTS, 0);
  705. PropSheet_UnChanged(GetParent(hdlg), hdlg);
  706. return 1;
  707. }
  708. /*****************************************************************************
  709. *
  710. * Explorer_ApplyOverlay
  711. *
  712. * This applies the overlay customization.
  713. *
  714. * HackPtui makes life (unfortunately) difficult. We signal that
  715. * HackPtui is necessary by setting the "HackPtui" registry
  716. * entry to 1.
  717. *
  718. *****************************************************************************/
  719. void PASCAL
  720. Explorer_ApplyOverlay(void)
  721. {
  722. /*
  723. * Assume that nothing special is needed.
  724. */
  725. DelPkl(&c_klLinkOvl);
  726. DelPkl(&c_klHackPtui);
  727. switch (pedii->idcCurEffect) {
  728. case IDC_LINKARROW:
  729. break; /* Nothing to do */
  730. case IDC_NOARROW: /* This is the tough one */
  731. if (g_fBuggyComCtl32) {
  732. SetIntPkl(1, &c_klHackPtui);
  733. } else {
  734. TCH tszBuild[MAX_PATH + 1 + 6]; /* comma + 65535 */
  735. default:
  736. wsprintf(tszBuild, c_tszSCommaU, pedii->tszPathDll, pedii->iIcon);
  737. SetStrPkl(&c_klLinkOvl, tszBuild);
  738. }
  739. break;
  740. }
  741. Misc_RebuildIcoCache();
  742. pedii->fIconDirty = 0;
  743. }
  744. /*****************************************************************************
  745. *
  746. * Explorer_OnApply
  747. *
  748. * Write the changes to the registry and force a refresh.
  749. *
  750. * HackPtui makes life (unfortunately) difficult. We signal that
  751. * HackPtui is necessary by setting the "HackPtui" registry
  752. * entry to 1.
  753. *
  754. *****************************************************************************/
  755. void NEAR PASCAL
  756. Explorer_OnApply(HWND hdlg)
  757. {
  758. CABINETSTATE cs;
  759. BOOL fNeedLogoff = FALSE;
  760. Checklist_OnApply(hdlg, c_rgcliExplorer, &fNeedLogoff, FALSE);
  761. if (fNeedLogoff) {
  762. Common_NeedLogoff(hdlg);
  763. }
  764. if (pedii->fIconDirty) {
  765. Explorer_ApplyOverlay();
  766. }
  767. if (mit.ReadCabinetState) {
  768. if (g_fNT && pedii->ccComp.GetColor() !=
  769. GetDwordPkl(&c_klAltColor, clrDefAlt)) {
  770. SetDwordPkl(&c_klAltColor, pedii->ccComp.GetColor());
  771. if (g_fNT5) {
  772. SendNotifyMessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0, 0);
  773. } else {
  774. Common_NeedLogoff(hdlg);
  775. }
  776. }
  777. }
  778. if (GetSysColorBrush(COLOR_HOTLIGHT)) {
  779. if (GetSysColor(COLOR_HOTLIGHT) != pedii->ccHot.GetColor()) {
  780. COLORREF clrHotlight = pedii->ccHot.GetColor();
  781. TCHAR tsz[64];
  782. int iColor = COLOR_HOTLIGHT;
  783. wsprintf(tsz, TEXT("%d %d %d"), GetRValue(clrHotlight),
  784. GetGValue(clrHotlight), GetBValue(clrHotlight));
  785. SetStrPkl(&c_klHotlight, tsz);
  786. SetSysColors(1, &iColor, &clrHotlight);
  787. }
  788. }
  789. }
  790. /*****************************************************************************
  791. *
  792. * Explorer_OnDestroy
  793. *
  794. * Clean up
  795. *
  796. *****************************************************************************/
  797. void PASCAL
  798. Explorer_OnDestroy(HWND hdlg)
  799. {
  800. ImageList_Destroy(pedii->himl);
  801. pedii->ccComp.Destroy();
  802. pedii->ccHot.Destroy();
  803. }
  804. /*****************************************************************************
  805. *
  806. * Explorer_OnWhatsThis
  807. *
  808. *****************************************************************************/
  809. void PASCAL
  810. Explorer_OnWhatsThis(HWND hwnd, int iItem)
  811. {
  812. LV_ITEM lvi;
  813. Misc_LV_GetItemInfo(hwnd, &lvi, iItem, LVIF_PARAM);
  814. WinHelp(hwnd, c_tszMyHelp, HELP_CONTEXTPOPUP, IDH_PREFIX + lvi.lParam);
  815. }
  816. /*****************************************************************************
  817. *
  818. * Oh yeah, we need this too.
  819. *
  820. *****************************************************************************/
  821. #pragma BEGIN_CONST_DATA
  822. LVCI lvciExplorer[] = {
  823. { IDC_WHATSTHIS, Explorer_OnWhatsThis },
  824. { 0, 0 },
  825. };
  826. LVV lvvExplorer = {
  827. Explorer_OnCommand,
  828. 0, /* Explorer_OnInitContextMenu */
  829. 0, /* Explorer_Dirtify */
  830. 0, /* Explorer_GetIcon */
  831. Explorer_OnInitDialog,
  832. Explorer_OnApply,
  833. Explorer_OnDestroy,
  834. 0, /* Explorer_OnSelChange */
  835. 6, /* iMenu */
  836. rgdwHelp,
  837. 0, /* Double-click action */
  838. lvvflCanCheck, /* We need check boxes */
  839. lvciExplorer,
  840. };
  841. #pragma END_CONST_DATA
  842. /*****************************************************************************
  843. *
  844. * Our window procedure.
  845. *
  846. *****************************************************************************/
  847. INT_PTR EXPORT
  848. Explorer_DlgProc(HWND hdlg, UINT wm, WPARAM wParam, LPARAM lParam)
  849. {
  850. return LV_DlgProc(&lvvExplorer, hdlg, wm, wParam, lParam);
  851. }