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.

1190 lines
41 KiB

  1. //*********************************************************************
  2. //* Microsoft Windows **
  3. //* Copyright(c) Microsoft Corp., 1996 **
  4. //*********************************************************************
  5. //
  6. // ADVANCED.C - "Advanced" Property Sheet
  7. //
  8. // HISTORY:
  9. //
  10. // 6/22/96 t-gpease created
  11. // 5/27/97 t-ashlm rewrote
  12. //
  13. #include "inetcplp.h"
  14. #include <mluisupp.h>
  15. //
  16. // Private Calls and structures
  17. //
  18. TCHAR g_szUnderline[3][64];
  19. // Reads a STRING and determines BOOL value: "yes" = TRUE | "no" = FALSE
  20. BOOL RegGetBooleanString(HUSKEY huskey, LPTSTR RegValue, BOOL Value);
  21. // Writes a STRING depending on the BOOL: TRUE = "yes" | FALSE = "no"
  22. BOOL RegSetBooleanString(HUSKEY huskey, LPTSTR RegValue, BOOL Value);
  23. // Reads a STRING of R,G,B values and returns a COLOREF.
  24. COLORREF RegGetColorRefString( HUSKEY huskey, LPTSTR RegValue, COLORREF Value);
  25. // Writes a STRING of R,G,B comma separated values.
  26. COLORREF RegSetColorRefString( HUSKEY huskey, LPTSTR RegValue, COLORREF Value);
  27. BOOL _AorW_GetFileNameFromBrowse(HWND hDlg,
  28. LPWSTR pszFilename,
  29. UINT cchFilename,
  30. LPCWSTR pszWorkingDir,
  31. LPCWSTR pszExt,
  32. LPCWSTR pszFilter,
  33. LPCWSTR pszTitle);
  34. //
  35. // Reg keys
  36. //
  37. #define REGSTR_PATH_ADVANCEDLIST REGSTR_PATH_IEXPLORER TEXT("\\AdvancedOptions")
  38. typedef struct {
  39. HWND hDlg; // handle of our dialog
  40. HWND hwndTree; // handle to the treeview
  41. IRegTreeOptions *pTO; // pointer to RegTreeOptions interface
  42. BOOL fChanged;
  43. BOOL fShowIEOnDesktop;
  44. } ADVANCEDPAGE, *LPADVANCEDPAGE;
  45. BOOL IsShowIEOnDesktopEnabled()
  46. {
  47. HKEY hk;
  48. if (SUCCEEDED(SHRegGetCLSIDKey(CLSID_Internet, TEXT("ShellFolder"), TRUE, FALSE, &hk)))
  49. {
  50. DWORD dwValue = 0, cbSize = SIZEOF(dwValue);
  51. SHGetValueW(hk, NULL, TEXT("Attributes"), NULL, (BYTE *)&dwValue, &cbSize);
  52. RegCloseKey(hk);
  53. return (dwValue & SFGAO_NONENUMERATED) != SFGAO_NONENUMERATED;;
  54. }
  55. return TRUE;
  56. }
  57. #define IE_DESKTOP_NAMESPACE_KEY TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Desktop\\Namespace\\{FBF23B42-E3F0-101B-8488-00AA003E56F8}")
  58. void ShowIEOnDesktop(BOOL fShow)
  59. {
  60. switch (GetUIVersion())
  61. {
  62. case 3:
  63. // win95 shell
  64. if (fShow)
  65. {
  66. TCHAR szTheInternet[MAX_PATH];
  67. int cch = MLLoadString(IDS_THE_INTERNET, szTheInternet, ARRAYSIZE(szTheInternet));
  68. SHSetValue(HKEY_LOCAL_MACHINE, IE_DESKTOP_NAMESPACE_KEY, NULL, REG_SZ,
  69. szTheInternet, (cch + 1) * sizeof(TCHAR));
  70. }
  71. else
  72. {
  73. SHDeleteKey(HKEY_LOCAL_MACHINE, IE_DESKTOP_NAMESPACE_KEY);
  74. }
  75. break;
  76. case 4:
  77. // IE4 integrated shell
  78. // doesnt have peruser, so we need to just
  79. // delete it by marking it NONENUMERATED
  80. {
  81. HKEY hk;
  82. if (SUCCEEDED(SHRegGetCLSIDKey(CLSID_Internet, TEXT("ShellFolder"), FALSE, FALSE, &hk)))
  83. {
  84. DWORD dwValue = 0, cbSize = SIZEOF(dwValue);
  85. SHGetValue(hk, NULL, TEXT("Attributes"), NULL, (BYTE *)&dwValue, &cbSize);
  86. dwValue = (dwValue & ~SFGAO_NONENUMERATED) | (fShow ? 0 : SFGAO_NONENUMERATED);
  87. SHSetValueW(hk, NULL, TEXT("Attributes"), REG_DWORD, (BYTE *)&dwValue, SIZEOF(dwValue));
  88. RegCloseKey(hk);
  89. }
  90. }
  91. break;
  92. default:
  93. // do nothing since just changing the settings
  94. // in the right place sets up the PER-USER
  95. // stuff correctly
  96. break;
  97. }
  98. }
  99. // AdvancedDlgInit()
  100. //
  101. // Initializes Advanced property sheet
  102. //
  103. // History:
  104. //
  105. // 6/13/96 t-gpease created
  106. // 5/27/96 t-ashlm rewrote
  107. //
  108. BOOL AdvancedDlgInit(HWND hDlg)
  109. {
  110. LPADVANCEDPAGE pAdv;
  111. HTREEITEM htvi;
  112. HRESULT hr;
  113. pAdv = (LPADVANCEDPAGE)LocalAlloc(LPTR, sizeof(*pAdv));
  114. if (!pAdv)
  115. {
  116. EndDialog(hDlg, 0);
  117. return FALSE; // no memory?
  118. }
  119. TraceMsg(TF_GENERAL, "\nInitializing Advanced Tab\n");
  120. pAdv->fShowIEOnDesktop = IsShowIEOnDesktopEnabled();
  121. InitCommonControls();
  122. // tell dialog where to get info
  123. SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)pAdv);
  124. // save dialog handle
  125. pAdv->hDlg = hDlg;
  126. pAdv->hwndTree = GetDlgItem( pAdv->hDlg, IDC_ADVANCEDTREE );
  127. CoInitialize(0);
  128. hr = CoCreateInstance(CLSID_CRegTreeOptions, NULL, CLSCTX_INPROC_SERVER,
  129. IID_IRegTreeOptions, (LPVOID *)&(pAdv->pTO));
  130. if (SUCCEEDED(hr))
  131. {
  132. #ifdef UNICODE // InitTree takes Ansi string
  133. char szRegPath[REGSTR_MAX_VALUE_LENGTH];
  134. SHTCharToAnsi(REGSTR_PATH_ADVANCEDLIST, szRegPath, ARRAYSIZE(szRegPath));
  135. hr = pAdv->pTO->InitTree(pAdv->hwndTree, HKEY_LOCAL_MACHINE, szRegPath, NULL);
  136. #else
  137. hr = pAdv->pTO->InitTree(pAdv->hwndTree, HKEY_LOCAL_MACHINE, REGSTR_PATH_ADVANCEDLIST, NULL);
  138. #endif
  139. }
  140. // find the first root and make sure that it is visible
  141. htvi = TreeView_GetRoot( pAdv->hwndTree );
  142. TreeView_EnsureVisible( pAdv->hwndTree, htvi );
  143. if (g_restrict.fAdvanced)
  144. {
  145. EnableDlgItem(hDlg, IDC_RESTORE_DEFAULT, FALSE);
  146. }
  147. return SUCCEEDED(hr) ? TRUE : FALSE;
  148. }
  149. #define REGKEY_DECLINED_IOD TEXT("Software\\Microsoft\\Active Setup\\Declined Install On Demand IEv5.PP2")
  150. #define REGKEY_DECLINED_COMPONENTS TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Declined Components IE5.pp2")
  151. //
  152. // AdvancedDlgOnCommand
  153. //
  154. // Handles Advanced property sheet window commands
  155. //
  156. // History:
  157. // 6/13/96 t-gpease created
  158. // 5/27/97 t-ashlm rewrote
  159. //
  160. void AdvancedDlgOnCommand(LPADVANCEDPAGE pAdv, UINT id, UINT nCmd)
  161. {
  162. switch (id)
  163. {
  164. case IDC_RESTORE_DEFAULT:
  165. if (nCmd == BN_CLICKED)
  166. {
  167. // forget all Install On Demands that the user requested we
  168. // never ask again
  169. // Warning : if you ever have subkeys - these will fail on NT
  170. RegDeleteKey(HKEY_CURRENT_USER, REGKEY_DECLINED_IOD);
  171. // forget all code downloads that user said No to
  172. RegDeleteKey(HKEY_CURRENT_USER, REGKEY_DECLINED_COMPONENTS);
  173. pAdv->pTO->WalkTree(WALK_TREE_RESTORE);
  174. pAdv->fChanged = TRUE;
  175. ENABLEAPPLY(pAdv->hDlg);
  176. }
  177. break;
  178. }
  179. }
  180. //
  181. // AdvancedDlgOnNotify()
  182. //
  183. // Handles Advanced property sheets WM_NOTIFY messages
  184. //
  185. // History:
  186. //
  187. // 6/13/96 t-gpease created
  188. //
  189. void AdvancedDlgOnNotify(LPADVANCEDPAGE pAdv, LPNMHDR psn)
  190. {
  191. SetWindowLongPtr( pAdv->hDlg, DWLP_MSGRESULT, (LONG_PTR)0); // handled
  192. switch (psn->code) {
  193. case TVN_KEYDOWN:
  194. {
  195. TV_KEYDOWN *pnm = (TV_KEYDOWN*)psn;
  196. if (pnm->wVKey == VK_SPACE)
  197. {
  198. if (!g_restrict.fAdvanced)
  199. {
  200. pAdv->pTO->ToggleItem((HTREEITEM)SendMessage(pAdv->hwndTree, TVM_GETNEXTITEM, TVGN_CARET, NULL));
  201. ENABLEAPPLY(pAdv->hDlg);
  202. pAdv->fChanged = TRUE;
  203. // Return TRUE so that the treeview swallows the space key. Otherwise
  204. // it tries to search for an element starting with a space and beeps.
  205. SetWindowLongPtr(pAdv->hDlg, DWLP_MSGRESULT, TRUE);
  206. }
  207. }
  208. break;
  209. }
  210. case NM_CLICK:
  211. case NM_DBLCLK:
  212. { // is this click in our tree?
  213. if ( psn->idFrom == IDC_ADVANCEDTREE )
  214. { // yes...
  215. TV_HITTESTINFO ht;
  216. GetCursorPos( &ht.pt ); // get where we were hit
  217. ScreenToClient( pAdv->hwndTree, &ht.pt ); // translate it to our window
  218. // retrieve the item hit
  219. if (!g_restrict.fAdvanced)
  220. {
  221. pAdv->pTO->ToggleItem(TreeView_HitTest( pAdv->hwndTree, &ht));
  222. ENABLEAPPLY(pAdv->hDlg);
  223. pAdv->fChanged = TRUE;
  224. }
  225. }
  226. }
  227. break;
  228. case PSN_QUERYCANCEL:
  229. case PSN_KILLACTIVE:
  230. case PSN_RESET:
  231. SetWindowLongPtr(pAdv->hDlg, DWLP_MSGRESULT, FALSE);
  232. break;
  233. case PSN_APPLY:
  234. {
  235. if (pAdv->fChanged)
  236. {
  237. pAdv->pTO->WalkTree( WALK_TREE_SAVE );
  238. // Now see if the user changed the "Show Internet Explorer on the Desktop"
  239. // setting.
  240. if (pAdv->fShowIEOnDesktop != IsShowIEOnDesktopEnabled())
  241. {
  242. pAdv->fShowIEOnDesktop = !pAdv->fShowIEOnDesktop;
  243. // They did, so now see if it's integrated shell or not.
  244. ShowIEOnDesktop(pAdv->fShowIEOnDesktop);
  245. // Now refresh the desktop
  246. SHITEMID mkid = {0};
  247. SHChangeNotify(SHCNE_UPDATEDIR, SHCNF_IDLIST | SHCNF_FLUSHNOWAIT, &mkid, NULL);
  248. }
  249. InternetSetOption( NULL, INTERNET_OPTION_SETTINGS_CHANGED, NULL, 0);
  250. UpdateAllWindows();
  251. pAdv->fChanged = FALSE;
  252. }
  253. }
  254. break;
  255. }
  256. }
  257. //
  258. // AdvancedDlgProc
  259. //
  260. // SubDialogs:
  261. // Temporary Internet Files (cache)
  262. //
  263. // History:
  264. //
  265. // 6/12/96 t-gpease created
  266. // 5/27/97 t-ashlm rewrote
  267. //
  268. INT_PTR CALLBACK AdvancedDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  269. {
  270. LPADVANCEDPAGE pAdv;
  271. if (uMsg == WM_INITDIALOG)
  272. return AdvancedDlgInit(hDlg);
  273. else
  274. pAdv = (LPADVANCEDPAGE)GetWindowLongPtr(hDlg, DWLP_USER);
  275. if (!pAdv)
  276. return FALSE;
  277. switch (uMsg)
  278. {
  279. case WM_NOTIFY:
  280. AdvancedDlgOnNotify(pAdv, (LPNMHDR)lParam);
  281. return TRUE;
  282. break;
  283. case WM_COMMAND:
  284. AdvancedDlgOnCommand(pAdv, LOWORD(wParam), HIWORD(wParam));
  285. return TRUE;
  286. break;
  287. case WM_HELP: // F1
  288. {
  289. LPHELPINFO lphelpinfo;
  290. lphelpinfo = (LPHELPINFO)lParam;
  291. if (lphelpinfo->iCtrlId != IDC_ADVANCEDTREE)
  292. {
  293. ResWinHelp( (HWND)((LPHELPINFO)lParam)->hItemHandle, IDS_HELPFILE,
  294. HELP_WM_HELP, (DWORD_PTR)(LPSTR)mapIDCsToIDHs);
  295. }
  296. else
  297. {
  298. HTREEITEM hItem;
  299. //Is this help invoked throught F1 key
  300. if (GetAsyncKeyState(VK_F1) < 0)
  301. {
  302. // Yes. WE need to give help for the currently selected item
  303. hItem = TreeView_GetSelection(pAdv->hwndTree);
  304. }
  305. else
  306. {
  307. //No, We need to give help for the item at the cursor position
  308. TV_HITTESTINFO ht;
  309. ht.pt =((LPHELPINFO)lParam)->MousePos;
  310. ScreenToClient(pAdv->hwndTree, &ht.pt); // Translate it to our window
  311. hItem = TreeView_HitTest(pAdv->hwndTree, &ht);
  312. }
  313. if (FAILED(pAdv->pTO->ShowHelp(hItem, HELP_WM_HELP)))
  314. {
  315. ResWinHelp( (HWND)((LPHELPINFO)lParam)->hItemHandle, IDS_HELPFILE,
  316. HELP_WM_HELP, (DWORD_PTR)(LPSTR)mapIDCsToIDHs);
  317. }
  318. }
  319. break;
  320. }
  321. case WM_CONTEXTMENU: // right mouse click
  322. {
  323. TV_HITTESTINFO ht;
  324. GetCursorPos( &ht.pt ); // get where we were hit
  325. ScreenToClient( pAdv->hwndTree, &ht.pt ); // translate it to our window
  326. // retrieve the item hit
  327. if (FAILED(pAdv->pTO->ShowHelp(TreeView_HitTest( pAdv->hwndTree, &ht),HELP_CONTEXTMENU)))
  328. {
  329. ResWinHelp( (HWND) wParam, IDS_HELPFILE,
  330. HELP_CONTEXTMENU, (DWORD_PTR)(LPSTR)mapIDCsToIDHs);
  331. }
  332. break;
  333. }
  334. case WM_DESTROY:
  335. // destroying this deliberately flushes its update (see WM_DESTROY in the UpdateWndProc);
  336. #ifndef UNIX
  337. // Should only be destroyed in Process Detach.
  338. if (g_hwndUpdate)
  339. DestroyWindow(g_hwndUpdate);
  340. #endif
  341. // free the tree
  342. if (pAdv->pTO)
  343. {
  344. pAdv->pTO->WalkTree( WALK_TREE_DELETE );
  345. pAdv->pTO->Release();
  346. pAdv->pTO=NULL;
  347. }
  348. // free local memory
  349. ASSERT(pAdv);
  350. LocalFree(pAdv);
  351. // make sure we don't re-enter
  352. SetWindowLongPtr( hDlg, DWLP_USER, (LONG)NULL );
  353. CoUninitialize();
  354. break;
  355. } // switch
  356. return FALSE; // not handled
  357. } // AdvancedDlgProc
  358. //////////////////////////////////////////////
  359. //
  360. // Buttons on bottom
  361. //
  362. ////////////////////////////////////////////////////////////////////////////////////////////
  363. typedef struct tagCOLORSINFO {
  364. HWND hDlg;
  365. BOOL fUseWindowsDefaults;
  366. COLORREF colorWindowText;
  367. COLORREF colorWindowBackground;
  368. COLORREF colorLinkViewed;
  369. COLORREF colorLinkNotViewed;
  370. COLORREF colorLinkHover;
  371. BOOL fUseHoverColor;
  372. } COLORSINFO, *LPCOLORSINFO;
  373. VOID Color_DrawButton(HWND hDlg, LPDRAWITEMSTRUCT lpdis, COLORREF the_color )
  374. {
  375. SIZE thin = { GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER) };
  376. RECT rc = lpdis->rcItem;
  377. HDC hdc = lpdis->hDC;
  378. BOOL bFocus = ((lpdis->itemState & ODS_FOCUS) && !(lpdis->itemState & ODS_DISABLED));
  379. if (!thin.cx) thin.cx = 1;
  380. if (!thin.cy) thin.cy = 1;
  381. FillRect(hdc, &rc, GetSysColorBrush(COLOR_3DFACE));
  382. // Draw any caption
  383. TCHAR szCaption[80];
  384. int cxButton = 23*(rc.bottom - rc.top)/12;
  385. if (GetWindowText(lpdis->hwndItem, szCaption, ARRAYSIZE(szCaption)))
  386. {
  387. COLORREF crText;
  388. RECT rcText = rc;
  389. rcText.right -= cxButton;
  390. int nOldMode = SetBkMode(hdc, TRANSPARENT);
  391. if (lpdis->itemState & ODS_DISABLED)
  392. {
  393. // Draw disabled text using the embossed look
  394. crText = SetTextColor(hdc, GetSysColor(COLOR_BTNHIGHLIGHT));
  395. RECT rcOffset = rcText;
  396. OffsetRect(&rcOffset, 1, 1);
  397. DrawText(hdc, szCaption, -1, &rcOffset, DT_VCENTER|DT_SINGLELINE);
  398. SetTextColor(hdc, GetSysColor(COLOR_BTNSHADOW));
  399. }
  400. else
  401. {
  402. crText = SetTextColor(hdc, GetSysColor(COLOR_WINDOWTEXT));
  403. }
  404. DrawText(hdc, szCaption, -1, &rcText, DT_VCENTER|DT_SINGLELINE);
  405. SetTextColor(hdc, crText);
  406. SetBkMode(hdc, nOldMode);
  407. }
  408. // Draw the button portion
  409. rc.left = rc.right - cxButton;
  410. if (lpdis->itemState & ODS_SELECTED)
  411. {
  412. DrawEdge(hdc, &rc, EDGE_SUNKEN, BF_RECT | BF_ADJUST);
  413. OffsetRect(&rc, 1, 1);
  414. }
  415. else
  416. {
  417. DrawEdge(hdc, &rc, EDGE_RAISED, BF_RECT | BF_ADJUST);
  418. }
  419. if (bFocus)
  420. {
  421. InflateRect(&rc, -thin.cx, -thin.cy);
  422. DrawFocusRect(hdc, &rc);
  423. InflateRect(&rc, thin.cx, thin.cy);
  424. }
  425. // color sample
  426. if ( !(lpdis->itemState & ODS_DISABLED) )
  427. {
  428. HBRUSH hBrush;
  429. InflateRect(&rc, -2 * thin.cx, -2 * thin.cy);
  430. FrameRect(hdc, &rc, GetSysColorBrush(COLOR_BTNTEXT));
  431. InflateRect(&rc, -thin.cx, -thin.cy);
  432. hBrush = CreateSolidBrush( the_color );
  433. FillRect(hdc, &rc, hBrush);
  434. DeleteObject(hBrush);
  435. }
  436. }
  437. COLORREF g_CustomColors[16] = { 0 };
  438. // ChooseColorW is yet implemented in comdlg32.dll
  439. BOOL UseColorPicker( HWND hWnd, COLORREF *the_color, int extra_flags )
  440. {
  441. // Make a local copy of the custom colors so they are not saved if the
  442. // color picker dialog is cancelled
  443. COLORREF customColors[16];
  444. memcpy(customColors, g_CustomColors, sizeof(customColors));
  445. CHOOSECOLORA cc;
  446. cc.lStructSize = sizeof(cc);
  447. cc.hwndOwner = hWnd;
  448. cc.hInstance = NULL;
  449. cc.rgbResult = (DWORD) *the_color;
  450. cc.lpCustColors = customColors;
  451. cc.Flags = CC_RGBINIT | extra_flags;
  452. cc.lCustData = (DWORD) NULL;
  453. cc.lpfnHook = NULL;
  454. cc.lpTemplateName = NULL;
  455. if (ChooseColorA(&cc))
  456. {
  457. *the_color = cc.rgbResult;
  458. memcpy(g_CustomColors, customColors, sizeof(g_CustomColors));
  459. InvalidateRect( hWnd, NULL, FALSE );
  460. return TRUE;
  461. }
  462. TraceMsg(TF_GENERAL, "\nChooseColor() return 0\n");
  463. return FALSE;
  464. }
  465. VOID AppearanceDimFields( HWND hDlg )
  466. {
  467. // reverse the function of the check.... if CHECKED turn off the color
  468. // selectors.
  469. BOOL setting = !IsDlgButtonChecked( hDlg, IDC_GENERAL_APPEARANCE_USE_CUSTOM_COLORS_CHECKBOX ) && !g_restrict.fColors;
  470. EnableWindow(GetDlgItem(hDlg, IDC_GENERAL_APPEARANCE_COLOR_TEXT), setting);
  471. EnableWindow(GetDlgItem(hDlg, IDC_GENERAL_APPEARANCE_COLOR_TEXT_LABEL), setting);
  472. EnableWindow(GetDlgItem(hDlg, IDC_GENERAL_APPEARANCE_COLOR_BACKGROUND), setting);
  473. EnableWindow(GetDlgItem(hDlg, IDC_GENERAL_APPEARANCE_COLOR_BACKGROUND_LABEL), setting);
  474. EnableWindow(GetDlgItem(hDlg, IDC_GENERAL_APPEARANCE_COLOR_HOVER),
  475. IsDlgButtonChecked(hDlg, IDC_GENERAL_APPEARANCE_USE_HOVER_COLOR_CHECKBOX) && !g_restrict.fLinks);
  476. }
  477. BOOL General_DrawItem(HWND hDlg, WPARAM wParam, LPARAM lParam, LPCOLORSINFO pci)
  478. {
  479. switch (GET_WM_COMMAND_ID(wParam, lParam))
  480. {
  481. case IDC_GENERAL_APPEARANCE_COLOR_TEXT:
  482. Color_DrawButton(hDlg, (LPDRAWITEMSTRUCT)lParam, pci->colorWindowText);
  483. return TRUE;
  484. case IDC_GENERAL_APPEARANCE_COLOR_BACKGROUND:
  485. Color_DrawButton(hDlg, (LPDRAWITEMSTRUCT)lParam, pci->colorWindowBackground);
  486. return TRUE;
  487. case IDC_GENERAL_APPEARANCE_COLOR_LINKS:
  488. Color_DrawButton(hDlg, (LPDRAWITEMSTRUCT)lParam, pci->colorLinkNotViewed);
  489. return TRUE;
  490. case IDC_GENERAL_APPEARANCE_COLOR_VISITED_LINKS:
  491. Color_DrawButton(hDlg, (LPDRAWITEMSTRUCT)lParam, pci->colorLinkViewed);
  492. return TRUE;
  493. case IDC_GENERAL_APPEARANCE_COLOR_HOVER:
  494. Color_DrawButton(hDlg, (LPDRAWITEMSTRUCT)lParam, pci->colorLinkHover);
  495. return TRUE;
  496. }
  497. return FALSE;
  498. }
  499. INT_PTR CALLBACK ColorsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam,LPARAM lParam)
  500. {
  501. LPCOLORSINFO pci = (LPCOLORSINFO) GetWindowLongPtr(hDlg, DWLP_USER);
  502. switch (uMsg)
  503. {
  504. case WM_INITDIALOG:
  505. {
  506. DWORD cb = sizeof(DWORD);
  507. HUSKEY huskey;
  508. pci = (LPCOLORSINFO)LocalAlloc(LPTR, sizeof(COLORSINFO));
  509. if (!pci)
  510. {
  511. EndDialog(hDlg, IDCANCEL);
  512. return FALSE;
  513. }
  514. // tell dialog where to get info
  515. SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)pci);
  516. // save the handle to the page
  517. pci->hDlg = hDlg;
  518. // set default values
  519. pci->fUseWindowsDefaults = TRUE;
  520. pci->colorWindowText = RGB(0,0,0);
  521. pci->colorWindowBackground = RGB(192,192,192);
  522. pci->colorLinkViewed = RGB(0, 128, 128);
  523. pci->colorLinkNotViewed = RGB(0, 0, 255);
  524. pci->colorLinkHover = RGB(255, 0, 0);
  525. pci->fUseHoverColor = TRUE;
  526. if (SHRegOpenUSKey(REGSTR_PATH_IEXPLORER,
  527. KEY_READ|KEY_WRITE, // samDesired
  528. NULL, // hUSKeyRelative
  529. &huskey,
  530. FALSE) == ERROR_SUCCESS)
  531. {
  532. HUSKEY huskeySub;
  533. if (SHRegOpenUSKey(REGSTR_KEY_MAIN,
  534. KEY_READ|KEY_WRITE,
  535. huskey,
  536. &huskeySub,
  537. FALSE) == ERROR_SUCCESS)
  538. {
  539. pci->fUseWindowsDefaults = RegGetBooleanString(huskeySub,
  540. REGSTR_VAL_USEDLGCOLORS, pci->fUseWindowsDefaults);
  541. SHRegCloseUSKey(huskeySub);
  542. }
  543. if (SHRegOpenUSKey(REGSTR_KEY_IE_SETTINGS,
  544. KEY_READ|KEY_WRITE,
  545. huskey,
  546. &huskeySub,
  547. FALSE) == ERROR_SUCCESS)
  548. {
  549. pci->colorWindowText = RegGetColorRefString(huskeySub,
  550. REGSTR_VAL_TEXTCOLOR, pci->colorWindowText);
  551. pci->colorWindowBackground = RegGetColorRefString(huskeySub,
  552. REGSTR_VAL_BACKGROUNDCOLOR, pci->colorWindowBackground);
  553. pci->colorLinkViewed = RegGetColorRefString(huskeySub,
  554. REGSTR_VAL_ANCHORCOLORVISITED, pci->colorLinkViewed);
  555. pci->colorLinkNotViewed = RegGetColorRefString(huskeySub,
  556. REGSTR_VAL_ANCHORCOLOR, pci->colorLinkNotViewed);
  557. pci->colorLinkHover = RegGetColorRefString(huskeySub,
  558. REGSTR_VAL_ANCHORCOLORHOVER, pci->colorLinkHover);
  559. pci->fUseHoverColor = RegGetBooleanString(huskeySub,
  560. REGSTR_VAL_USEHOVERCOLOR, pci->fUseHoverColor);
  561. SHRegCloseUSKey(huskeySub);
  562. }
  563. SHRegCloseUSKey(huskey);
  564. }
  565. cb = sizeof(g_CustomColors);
  566. SHRegGetUSValue(REGSTR_PATH_IE_SETTINGS, REGSTR_VAL_IE_CUSTOMCOLORS, NULL, (LPBYTE)&g_CustomColors,
  567. &cb, FALSE, NULL, NULL);
  568. //
  569. // select appropriate dropdown item here for underline links
  570. //
  571. CheckDlgButton(hDlg, IDC_GENERAL_APPEARANCE_USE_CUSTOM_COLORS_CHECKBOX, pci->fUseWindowsDefaults);
  572. CheckDlgButton(hDlg, IDC_GENERAL_APPEARANCE_USE_HOVER_COLOR_CHECKBOX, pci->fUseHoverColor);
  573. AppearanceDimFields(hDlg);
  574. if (g_restrict.fLinks)
  575. {
  576. EnableWindow(GetDlgItem(hDlg, IDC_GENERAL_APPEARANCE_COLOR_LINKS), FALSE);
  577. EnableWindow(GetDlgItem(hDlg, IDC_GENERAL_APPEARANCE_COLOR_VISITED_LINKS), FALSE);
  578. EnableWindow(GetDlgItem(hDlg, IDC_GENERAL_APPEARANCE_USE_HOVER_COLOR_CHECKBOX), FALSE);
  579. }
  580. if (g_restrict.fColors)
  581. {
  582. EnableWindow(GetDlgItem(hDlg, IDC_GENERAL_APPEARANCE_COLOR_TEXT), FALSE);
  583. EnableWindow(GetDlgItem(hDlg, IDC_GENERAL_APPEARANCE_COLOR_BACKGROUND), FALSE);
  584. EnableWindow(GetDlgItem(hDlg, IDC_GENERAL_APPEARANCE_USE_CUSTOM_COLORS_CHECKBOX), FALSE);
  585. }
  586. return TRUE;
  587. }
  588. case WM_DRAWITEM:
  589. return General_DrawItem(hDlg, wParam, lParam, pci);
  590. break;
  591. case WM_COMMAND:
  592. switch (LOWORD(wParam))
  593. {
  594. case IDOK:
  595. {
  596. HUSKEY huskey;
  597. if (SHRegOpenUSKey(REGSTR_PATH_IEXPLORER,
  598. KEY_WRITE, // samDesired
  599. NULL, // hUSKeyRelative
  600. &huskey,
  601. FALSE) == ERROR_SUCCESS)
  602. {
  603. HUSKEY huskeySub;
  604. if (SHRegOpenUSKey(REGSTR_KEY_MAIN,
  605. KEY_WRITE,
  606. huskey,
  607. &huskeySub,
  608. FALSE) == ERROR_SUCCESS)
  609. {
  610. pci->fUseWindowsDefaults = RegSetBooleanString(huskeySub,
  611. REGSTR_VAL_USEDLGCOLORS, pci->fUseWindowsDefaults);
  612. SHRegCloseUSKey(huskeySub);
  613. }
  614. if (SHRegOpenUSKey(REGSTR_KEY_IE_SETTINGS,
  615. KEY_WRITE,
  616. huskey,
  617. &huskeySub,
  618. FALSE) == ERROR_SUCCESS)
  619. {
  620. pci->colorWindowText = RegSetColorRefString(huskeySub,
  621. REGSTR_VAL_TEXTCOLOR, pci->colorWindowText);
  622. pci->colorWindowBackground = RegSetColorRefString(huskeySub,
  623. REGSTR_VAL_BACKGROUNDCOLOR, pci->colorWindowBackground);
  624. pci->colorLinkViewed = RegSetColorRefString(huskeySub,
  625. REGSTR_VAL_ANCHORCOLORVISITED, pci->colorLinkViewed);
  626. pci->colorLinkNotViewed = RegSetColorRefString(huskeySub,
  627. REGSTR_VAL_ANCHORCOLOR, pci->colorLinkNotViewed);
  628. pci->colorLinkHover = RegSetColorRefString(huskeySub,
  629. REGSTR_VAL_ANCHORCOLORHOVER, pci->colorLinkHover);
  630. pci->fUseHoverColor = RegSetBooleanString(huskeySub,
  631. REGSTR_VAL_USEHOVERCOLOR, pci->fUseHoverColor);
  632. SHRegCloseUSKey(huskeySub);
  633. }
  634. SHRegCloseUSKey(huskey);
  635. }
  636. // custom colors
  637. SHRegSetUSValue(REGSTR_PATH_IE_SETTINGS, REGSTR_VAL_IE_CUSTOMCOLORS, REGSTR_VAL_IE_CUSTOMCOLORS_TYPE, (LPBYTE)&g_CustomColors,
  638. sizeof(g_CustomColors), SHREGSET_FORCE_HKCU);
  639. // refresh the browser
  640. UpdateAllWindows();
  641. EndDialog(hDlg, IDOK);
  642. break;
  643. }
  644. case IDCANCEL:
  645. EndDialog(hDlg, IDCANCEL);
  646. break;
  647. case IDC_GENERAL_APPEARANCE_USE_CUSTOM_COLORS_CHECKBOX:
  648. if ( GET_WM_COMMAND_CMD(wParam, lParam) == BN_CLICKED )
  649. {
  650. pci->fUseWindowsDefaults =
  651. IsDlgButtonChecked(hDlg, IDC_GENERAL_APPEARANCE_USE_CUSTOM_COLORS_CHECKBOX);
  652. AppearanceDimFields(hDlg);
  653. }
  654. break;
  655. case IDC_GENERAL_APPEARANCE_USE_HOVER_COLOR_CHECKBOX:
  656. if ( GET_WM_COMMAND_CMD(wParam, lParam) == BN_CLICKED )
  657. {
  658. pci->fUseHoverColor =
  659. IsDlgButtonChecked(hDlg, IDC_GENERAL_APPEARANCE_USE_HOVER_COLOR_CHECKBOX);
  660. AppearanceDimFields(hDlg);
  661. }
  662. break;
  663. case IDC_GENERAL_APPEARANCE_COLOR_TEXT:
  664. if ( GET_WM_COMMAND_CMD(wParam, lParam) == BN_CLICKED )
  665. {
  666. UseColorPicker( hDlg, &pci->colorWindowText, CC_SOLIDCOLOR);
  667. }
  668. break;
  669. case IDC_GENERAL_APPEARANCE_COLOR_BACKGROUND:
  670. if ( GET_WM_COMMAND_CMD(wParam, lParam) == BN_CLICKED )
  671. {
  672. UseColorPicker( hDlg, &pci->colorWindowBackground, CC_SOLIDCOLOR);
  673. }
  674. break;
  675. case IDC_GENERAL_APPEARANCE_COLOR_LINKS:
  676. if ( GET_WM_COMMAND_CMD(wParam, lParam) == BN_CLICKED )
  677. {
  678. UseColorPicker( hDlg, &pci->colorLinkNotViewed, CC_SOLIDCOLOR);
  679. }
  680. break;
  681. case IDC_GENERAL_APPEARANCE_COLOR_VISITED_LINKS:
  682. if ( GET_WM_COMMAND_CMD(wParam, lParam) == BN_CLICKED )
  683. {
  684. UseColorPicker( hDlg, &pci->colorLinkViewed, CC_SOLIDCOLOR);
  685. }
  686. break;
  687. case IDC_GENERAL_APPEARANCE_COLOR_HOVER:
  688. if ( GET_WM_COMMAND_CMD(wParam, lParam) == BN_CLICKED )
  689. {
  690. UseColorPicker( hDlg, &pci->colorLinkHover, CC_SOLIDCOLOR);
  691. }
  692. break;
  693. default:
  694. return FALSE;
  695. }
  696. return TRUE;
  697. break;
  698. case WM_HELP: // F1
  699. ResWinHelp( (HWND)((LPHELPINFO)lParam)->hItemHandle, IDS_HELPFILE,
  700. HELP_WM_HELP, (DWORD_PTR)(LPSTR)mapIDCsToIDHs);
  701. break;
  702. case WM_CONTEXTMENU: // right mouse click
  703. ResWinHelp( (HWND) wParam, IDS_HELPFILE,
  704. HELP_CONTEXTMENU, (DWORD_PTR)(LPSTR)mapIDCsToIDHs);
  705. break;
  706. case WM_DESTROY:
  707. ASSERT(pci);
  708. if (pci)
  709. {
  710. LocalFree(pci);
  711. }
  712. break;
  713. }
  714. return FALSE;
  715. }
  716. typedef struct tagACCESSIBILITYINFO
  717. {
  718. HWND hDlg;
  719. BOOL fMyColors;
  720. BOOL fMyFontStyle;
  721. BOOL fMyFontSize;
  722. BOOL fMyStyleSheet;
  723. TCHAR szStyleSheetPath[MAX_PATH];
  724. } ACCESSIBILITYINFO, *LPACCESSIBILITYINFO;
  725. INT_PTR CALLBACK AccessibilityDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam,LPARAM lParam)
  726. {
  727. LPACCESSIBILITYINFO pai = (LPACCESSIBILITYINFO) GetWindowLongPtr(hDlg, DWLP_USER);
  728. switch (uMsg)
  729. {
  730. case WM_INITDIALOG:
  731. {
  732. HKEY hkey;
  733. DWORD cb;
  734. pai = (LPACCESSIBILITYINFO)LocalAlloc(LPTR, sizeof(ACCESSIBILITYINFO));
  735. if (!pai)
  736. {
  737. EndDialog(hDlg, IDCANCEL);
  738. return FALSE;
  739. }
  740. SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)pai);
  741. pai->hDlg = hDlg;
  742. if (RegCreateKeyEx(HKEY_CURRENT_USER,
  743. TEXT("Software\\Microsoft\\Internet Explorer\\Settings"),
  744. 0, NULL, 0,
  745. KEY_READ,
  746. NULL,
  747. &hkey,
  748. NULL) == ERROR_SUCCESS)
  749. {
  750. cb = sizeof(pai->fMyColors);
  751. RegQueryValueEx(hkey, TEXT("Always Use My Colors"), NULL, NULL, (LPBYTE)&(pai->fMyColors), &cb);
  752. cb = sizeof(pai->fMyFontStyle);
  753. RegQueryValueEx(hkey, TEXT("Always Use My Font Face"), NULL, NULL, (LPBYTE)&(pai->fMyFontStyle),&cb);
  754. cb = sizeof(pai->fMyFontSize);
  755. RegQueryValueEx(hkey, TEXT("Always Use My Font Size"), NULL, NULL, (LPBYTE)&(pai->fMyFontSize),&cb);
  756. RegCloseKey(hkey);
  757. }
  758. if (RegCreateKeyEx(HKEY_CURRENT_USER,
  759. TEXT("Software\\Microsoft\\Internet Explorer\\Styles"),
  760. 0, NULL, 0,
  761. KEY_READ,
  762. NULL,
  763. &hkey,
  764. NULL) == ERROR_SUCCESS)
  765. {
  766. cb = sizeof(pai->fMyStyleSheet);
  767. RegQueryValueEx(hkey, TEXT("Use My Stylesheet"), NULL, NULL, (LPBYTE)&(pai->fMyStyleSheet),&cb);
  768. cb = sizeof(pai->szStyleSheetPath);
  769. RegQueryValueEx(hkey, TEXT("User Stylesheet"), NULL, NULL, (LPBYTE)&(pai->szStyleSheetPath), &cb);
  770. RegCloseKey(hkey);
  771. }
  772. CheckDlgButton(hDlg, IDC_CHECK_COLOR, pai->fMyColors);
  773. CheckDlgButton(hDlg, IDC_CHECK_FONT_STYLE, pai->fMyFontStyle);
  774. CheckDlgButton(hDlg, IDC_CHECK_FONT_SIZE, pai->fMyFontSize);
  775. CheckDlgButton(hDlg, IDC_CHECK_USE_MY_STYLESHEET, pai->fMyStyleSheet);
  776. SetDlgItemText(hDlg, IDC_EDIT_STYLESHEET, pai->szStyleSheetPath);
  777. SHAutoComplete(GetDlgItem(hDlg, IDC_EDIT_STYLESHEET), SHACF_DEFAULT);
  778. if (!pai->fMyStyleSheet || g_restrict.fAccessibility)
  779. {
  780. EnableWindow(GetDlgItem(hDlg, IDC_STATIC_STYLESHEET), FALSE);
  781. EnableWindow(GetDlgItem(hDlg, IDC_EDIT_STYLESHEET), FALSE);
  782. EnableWindow(GetDlgItem(hDlg, IDC_STYLESHEET_BROWSE), FALSE);
  783. }
  784. if (g_restrict.fAccessibility)
  785. {
  786. EnableWindow(GetDlgItem(hDlg, IDC_CHECK_COLOR), FALSE);
  787. EnableWindow(GetDlgItem(hDlg, IDC_CHECK_FONT_STYLE), FALSE);
  788. EnableWindow(GetDlgItem(hDlg, IDC_CHECK_FONT_SIZE), FALSE);
  789. EnableWindow(GetDlgItem(hDlg, IDC_CHECK_USE_MY_STYLESHEET), FALSE);
  790. }
  791. break;
  792. }
  793. case WM_COMMAND:
  794. switch (LOWORD(wParam))
  795. {
  796. case IDOK:
  797. {
  798. HKEY hkey;
  799. GetDlgItemText(hDlg, IDC_EDIT_STYLESHEET, pai->szStyleSheetPath, sizeof(pai->szStyleSheetPath));
  800. if (!PathFileExists(pai->szStyleSheetPath) && IsDlgButtonChecked(hDlg, IDC_CHECK_USE_MY_STYLESHEET))
  801. {
  802. MLShellMessageBox(hDlg, MAKEINTRESOURCEW(IDS_FILENOTFOUND), NULL, MB_ICONHAND|MB_OK);
  803. break;
  804. }
  805. if (RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("Software\\Microsoft\\Internet Explorer\\Settings"),0, KEY_WRITE, &hkey) == ERROR_SUCCESS)
  806. {
  807. DWORD cb;
  808. cb = sizeof(pai->fMyColors);
  809. pai->fMyColors = IsDlgButtonChecked(hDlg, IDC_CHECK_COLOR);
  810. RegSetValueEx(hkey, TEXT("Always Use My Colors"), NULL, REG_DWORD, (LPBYTE)&(pai->fMyColors), cb);
  811. cb = sizeof(pai->fMyFontStyle);
  812. pai->fMyFontStyle = IsDlgButtonChecked(hDlg, IDC_CHECK_FONT_STYLE);
  813. RegSetValueEx(hkey, TEXT("Always Use My Font Face"), NULL, REG_DWORD, (LPBYTE)&(pai->fMyFontStyle), cb);
  814. cb = sizeof(pai->fMyFontSize);
  815. pai->fMyFontSize = IsDlgButtonChecked(hDlg, IDC_CHECK_FONT_SIZE);
  816. RegSetValueEx(hkey, TEXT("Always Use My Font Size"), NULL, REG_DWORD, (LPBYTE)&(pai->fMyFontSize),cb);
  817. RegCloseKey(hkey);
  818. }
  819. if (RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("Software\\Microsoft\\Internet Explorer\\Styles"), 0, KEY_WRITE, &hkey) == ERROR_SUCCESS)
  820. {
  821. DWORD cb;
  822. #ifndef UNIX
  823. cb = sizeof(pai->szStyleSheetPath);
  824. #else
  825. // We don't know if this is exactly what we need to do, so we ifdef it.
  826. cb = (_tcslen(pai->szStyleSheetPath) + 1) * sizeof(TCHAR);
  827. #endif
  828. RegSetValueEx(hkey, TEXT("User Stylesheet"), NULL, REG_SZ, (LPBYTE)&(pai->szStyleSheetPath),cb);
  829. cb = sizeof(pai->fMyStyleSheet);
  830. pai->fMyStyleSheet = IsDlgButtonChecked(hDlg, IDC_CHECK_USE_MY_STYLESHEET);
  831. RegSetValueEx(hkey, TEXT("Use My Stylesheet"), NULL, REG_DWORD, (LPBYTE)&(pai->fMyStyleSheet),cb);
  832. RegCloseKey(hkey);
  833. }
  834. UpdateAllWindows(); // refresh the browser
  835. EndDialog(hDlg, IDOK);
  836. break;
  837. }
  838. case IDCANCEL:
  839. EndDialog(hDlg, IDCANCEL);
  840. break;
  841. case IDC_CHECK_USE_MY_STYLESHEET:
  842. {
  843. DWORD fChecked;
  844. fChecked = IsDlgButtonChecked(hDlg, IDC_CHECK_USE_MY_STYLESHEET);
  845. EnableWindow(GetDlgItem(hDlg, IDC_STATIC_STYLESHEET), fChecked);
  846. EnableWindow(GetDlgItem(hDlg, IDC_EDIT_STYLESHEET), fChecked);
  847. EnableWindow(GetDlgItem(hDlg, IDC_STYLESHEET_BROWSE), fChecked);
  848. EnableWindow(GetDlgItem(hDlg,IDOK), IsDlgButtonChecked(hDlg, IDC_CHECK_USE_MY_STYLESHEET) ? (GetWindowTextLength(GetDlgItem(hDlg, IDC_EDIT_STYLESHEET)) ? TRUE:FALSE) : TRUE);
  849. break;
  850. }
  851. case IDC_EDIT_STYLESHEET:
  852. switch(HIWORD(wParam))
  853. {
  854. case EN_CHANGE:
  855. EnableWindow(GetDlgItem(hDlg,IDOK), IsDlgButtonChecked(hDlg, IDC_CHECK_USE_MY_STYLESHEET) ? (GetWindowTextLength(GetDlgItem(hDlg, IDC_EDIT_STYLESHEET)) ? TRUE:FALSE) : TRUE);
  856. break;
  857. }
  858. break;
  859. case IDC_STYLESHEET_BROWSE:
  860. {
  861. TCHAR szFilenameBrowse[MAX_PATH];
  862. int ret;
  863. TCHAR szExt[MAX_PATH];
  864. TCHAR szFilter[MAX_PATH];
  865. szFilenameBrowse[0] = 0;
  866. // why is IDS_STYLESHEET_EXT in shdoclc.rc?
  867. MLLoadString(IDS_STYLESHEET_EXT, szExt, ARRAYSIZE(szExt));
  868. int cchFilter = MLLoadShellLangString(IDS_STYLESHEET_FILTER, szFilter, ARRAYSIZE(szFilter)-1);
  869. // Make sure we have a double null termination on the filter
  870. szFilter[cchFilter + 1] = 0;
  871. ret = _AorW_GetFileNameFromBrowse(hDlg, szFilenameBrowse, ARRAYSIZE(szFilenameBrowse), NULL, szExt,
  872. szFilter, NULL);
  873. if (ret > 0)
  874. {
  875. SetDlgItemText(hDlg, IDC_EDIT_STYLESHEET, szFilenameBrowse);
  876. }
  877. break;
  878. }
  879. default:
  880. return FALSE;
  881. }
  882. return TRUE;
  883. break;
  884. case WM_HELP: // F1
  885. ResWinHelp( (HWND)((LPHELPINFO)lParam)->hItemHandle, IDS_HELPFILE,
  886. HELP_WM_HELP, (DWORD_PTR)(LPSTR)mapIDCsToIDHs);
  887. break;
  888. case WM_CONTEXTMENU: // right mouse click
  889. ResWinHelp( (HWND) wParam, IDS_HELPFILE,
  890. HELP_CONTEXTMENU, (DWORD_PTR)(LPSTR)mapIDCsToIDHs);
  891. break;
  892. case WM_DESTROY:
  893. ASSERT(pai);
  894. if (pai)
  895. {
  896. LocalFree(pai);
  897. }
  898. break;
  899. }
  900. return FALSE;
  901. }
  902. #define TEMP_SMALL_BUF_SZ 256
  903. inline BOOL IsNotResource(LPCWSTR pszItem)
  904. {
  905. return (HIWORD(pszItem) != 0);
  906. }
  907. BOOL WINAPI _AorW_GetFileNameFromBrowse
  908. (
  909. HWND hwnd,
  910. LPWSTR pszFilePath, // IN OUT
  911. UINT cchFilePath,
  912. LPCWSTR pszWorkingDir, //IN OPTIONAL
  913. LPCWSTR pszDefExt, //IN OPTIONAL
  914. LPCWSTR pszFilters, //IN OPTIONAL
  915. LPCWSTR pszTitle //IN OPTIONAL
  916. )
  917. {
  918. BOOL bResult;
  919. #ifndef UNIX
  920. // Determine which version of NT or Windows we're running on
  921. OSVERSIONINFOA osvi;
  922. osvi.dwOSVersionInfoSize = sizeof(osvi);
  923. GetVersionExA(&osvi);
  924. BOOL fRunningOnNT = (VER_PLATFORM_WIN32_NT == osvi.dwPlatformId);
  925. if (fRunningOnNT)
  926. {
  927. #endif
  928. bResult = GetFileNameFromBrowse(hwnd,
  929. pszFilePath,
  930. cchFilePath,
  931. pszWorkingDir,
  932. pszDefExt,
  933. pszFilters,
  934. pszTitle);
  935. #ifndef UNIX
  936. }
  937. else
  938. {
  939. // Thunk to ansi
  940. CHAR szFilters[TEMP_SMALL_BUF_SZ*2];
  941. CHAR szPath[MAX_PATH];
  942. CHAR szDir[MAX_PATH];
  943. CHAR szExt[TEMP_SMALL_BUF_SZ];
  944. CHAR szTitle[TEMP_SMALL_BUF_SZ];
  945. // Always move pszFilePath stuff to szPath buffer. Should never be a resourceid.
  946. SHUnicodeToAnsi(pszFilePath, szPath, ARRAYSIZE(szPath));
  947. if (IsNotResource(pszWorkingDir))
  948. {
  949. SHUnicodeToAnsi(pszWorkingDir, szDir, ARRAYSIZE(szDir));
  950. pszWorkingDir = (LPCWSTR)szDir;
  951. }
  952. if (IsNotResource(pszDefExt))
  953. {
  954. SHUnicodeToAnsi(pszDefExt, szExt, ARRAYSIZE(szExt));
  955. pszDefExt = (LPCWSTR)szExt;
  956. }
  957. if (IsNotResource(pszFilters))
  958. {
  959. int nIndex = 1;
  960. // Find the double terminator
  961. while (pszFilters[nIndex] || pszFilters[nIndex-1])
  962. nIndex++;
  963. // nIndex+1 looks like bunk unless it goes past the terminator
  964. WideCharToMultiByte(CP_ACP, 0, (LPCTSTR)pszFilters, nIndex+1, szFilters, ARRAYSIZE(szFilters), NULL, NULL);
  965. pszFilters = (LPCWSTR)szFilters;
  966. }
  967. if (IsNotResource(pszTitle))
  968. {
  969. SHUnicodeToAnsi(pszTitle, szTitle, ARRAYSIZE(szTitle));
  970. pszTitle = (LPCWSTR)szTitle;
  971. }
  972. bResult = GetFileNameFromBrowse(hwnd, (LPWSTR)szPath, ARRAYSIZE(szPath), pszWorkingDir, pszDefExt, pszFilters, pszTitle);
  973. SHAnsiToUnicode(szPath, pszFilePath, cchFilePath);
  974. }
  975. #endif
  976. return bResult;
  977. }