OptionsGeneral.cpp 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680
  1. // OptionsGeneral.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "CP_Main.h"
  5. #include "OptionsGeneral.h"
  6. #include "InternetUpdate.h"
  7. #include <io.h>
  8. #include <Mmsystem.h> //play sound
  9. #include "Path.h"
  10. #include "AdvGeneral.h"
  11. #include "DimWnd.h"
  12. #include "HyperLink.h"
  13. using namespace nsPath;
  14. #define DEFAULT_THEME _T("(Ditto)")
  15. #ifdef _DEBUG
  16. #define new DEBUG_NEW
  17. #undef THIS_FILE
  18. static char THIS_FILE[] = __FILE__;
  19. #endif
  20. /////////////////////////////////////////////////////////////////////////////
  21. // COptionsGeneral property page
  22. IMPLEMENT_DYNCREATE(COptionsGeneral, CPropertyPage)
  23. COptionsGeneral::COptionsGeneral() : CPropertyPage(COptionsGeneral::IDD)
  24. {
  25. m_csTitle = theApp.m_Language.GetString("GeneralTitle", "General");
  26. m_psp.pszTitle = m_csTitle;
  27. m_psp.dwFlags |= PSP_USETITLE;
  28. memset(&m_LogFont, 0, sizeof(LOGFONT));
  29. //{{AFX_DATA_INIT(COptionsGeneral)
  30. //}}AFX_DATA_INIT
  31. }
  32. COptionsGeneral::~COptionsGeneral()
  33. {
  34. }
  35. void COptionsGeneral::DoDataExchange(CDataExchange* pDX)
  36. {
  37. CPropertyPage::DoDataExchange(pDX);
  38. //{{AFX_DATA_MAP(COptionsGeneral)
  39. //DDX_Control(pDX, IDC_ENSURE, m_EnsureConnected);
  40. // DDX_Control(pDX, IDC_EDIT_SAVE_DELAY, m_SaveDelay);
  41. DDX_Control(pDX, IDC_COMBO_LANGUAGE, m_cbLanguage);
  42. DDX_Control(pDX, IDC_PATH, m_ePath);
  43. DDX_Control(pDX, IDC_EXPIRE_AFTER, m_eExpireAfter);
  44. DDX_Control(pDX, IDC_MAX_SAVED_COPIES, m_eMaxSavedCopies);
  45. DDX_Control(pDX, IDC_EXPIRE, m_btExpire);
  46. DDX_Control(pDX, IDC_START_ON_STARTUP, m_btRunOnStartup);
  47. DDX_Control(pDX, IDC_EDIT_APP_COPY_INCLUDE, m_copyAppInclude);
  48. DDX_Control(pDX, IDC_EDIT_APP_COPY_EXCLUDE, m_copyAppExclude);
  49. DDX_Control(pDX, IDC_MAXIMUM, m_btMaximumCheck);
  50. //}}AFX_DATA_MAP
  51. DDX_Control(pDX, IDC_COMBO_THEME, m_cbTheme);
  52. DDX_Control(pDX, IDC_BUTTON_FONT, m_btFont);
  53. DDX_Control(pDX, IDC_BUTTON_DEFAULT_FAULT, m_btDefaultButton);
  54. DDX_Control(pDX, IDC_COMBO_POPUP_POSITION, m_popupPositionCombo);
  55. DDX_Control(pDX, IDC_MFCLINK_ENV_VAR, m_envVarLink);
  56. }
  57. BEGIN_MESSAGE_MAP(COptionsGeneral, CPropertyPage)
  58. //{{AFX_MSG_MAP(COptionsGeneral)
  59. ON_BN_CLICKED(IDC_GET_PATH, OnGetPath)
  60. ON_BN_CLICKED(IDC_BUTTON_ABOUT, OnButtonAbout)
  61. //}}AFX_MSG_MAP
  62. ON_BN_CLICKED(IDC_BUTTON_ADVANCED, &COptionsGeneral::OnBnClickedButtonAdvanced)
  63. ON_WM_CTLCOLOR()
  64. ON_BN_CLICKED(IDC_BUTTON_THEME, &COptionsGeneral::OnBnClickedButtonTheme)
  65. ON_BN_CLICKED(IDC_BUTTON_DEFAULT_FAULT, &COptionsGeneral::OnBnClickedButtonDefaultFault)
  66. ON_BN_CLICKED(IDC_BUTTON_FONT, &COptionsGeneral::OnBnClickedButtonFont)
  67. ON_EN_CHANGE(IDC_PATH, &COptionsGeneral::OnEnChangePath)
  68. ON_BN_CLICKED(IDC_MAXIMUM, &COptionsGeneral::OnClickedMaximumEntries)
  69. ON_BN_CLICKED(IDC_EXPIRE, &COptionsGeneral::OnClickedExpireEntries)
  70. END_MESSAGE_MAP()
  71. /////////////////////////////////////////////////////////////////////////////
  72. // COptionsGeneral message handlers
  73. BOOL COptionsGeneral::OnInitDialog()
  74. {
  75. CPropertyPage::OnInitDialog();
  76. CString url = _T("https://sourceforge.net/p/ditto-cp/wiki/EnvironmentVariables/");
  77. m_brush.CreateSolidBrush(RGB(251, 251, 251));
  78. m_pParent = (COptionsSheet *)GetParent();
  79. #ifndef _DEBUG
  80. if (CGetSetOptions::GetIsWindowsApp())
  81. {
  82. m_btRunOnStartup.SetCheck(BST_CHECKED);
  83. GetDlgItem(IDC_START_ON_STARTUP)->EnableWindow(FALSE);
  84. }
  85. else
  86. {
  87. m_btRunOnStartup.SetCheck(CGetSetOptions::GetRunOnStartUp());
  88. }
  89. #endif
  90. m_btMaximumCheck.SetCheck(CGetSetOptions::GetCheckForMaxEntries());
  91. if (CGetSetOptions::GetCheckForMaxEntries() == FALSE)
  92. {
  93. m_eMaxSavedCopies.EnableWindow(FALSE);
  94. }
  95. m_btExpire.SetCheck(CGetSetOptions::GetCheckForExpiredEntries());
  96. if (CGetSetOptions::GetCheckForExpiredEntries() == FALSE)
  97. {
  98. m_eExpireAfter.EnableWindow(FALSE);
  99. }
  100. m_eExpireAfter.SetNumber(CGetSetOptions::GetExpiredEntries());
  101. m_eMaxSavedCopies.SetNumber(CGetSetOptions::GetMaxEntries());
  102. if(CGetSetOptions::GetDisableExpireClipsConfig())
  103. {
  104. m_btMaximumCheck.EnableWindow(FALSE);
  105. m_btExpire.EnableWindow(FALSE);
  106. m_eExpireAfter.EnableWindow(FALSE);
  107. m_eMaxSavedCopies.EnableWindow(FALSE);
  108. }
  109. m_copyAppInclude.SetWindowText(g_Opt.GetCopyAppInclude());
  110. m_copyAppExclude.SetWindowText(g_Opt.GetCopyAppExclude());
  111. CGetSetOptions::GetFont(m_LogFont);
  112. CString cs;
  113. cs.Format(_T("Font - %s (%d)"), m_LogFont.lfFaceName, GetFontSize(m_hWnd, m_LogFont));
  114. m_btFont.SetWindowText(cs);
  115. FillThemes();
  116. FillLanguages();
  117. int caretPos = m_popupPositionCombo.AddString(_T("At Caret"));
  118. m_popupPositionCombo.SetItemData(caretPos, POS_AT_CARET);
  119. int cursorPos = m_popupPositionCombo.AddString(_T("At Cursor"));
  120. m_popupPositionCombo.SetItemData(cursorPos, POS_AT_CURSOR);
  121. int prevPos = m_popupPositionCombo.AddString(_T("At Previous Position"));
  122. m_popupPositionCombo.SetItemData(prevPos, POS_AT_PREVIOUS);
  123. switch (CGetSetOptions::GetQuickPastePosition())
  124. {
  125. case POS_AT_CARET:
  126. m_popupPositionCombo.SetCurSel(caretPos);
  127. break;
  128. case POS_AT_CURSOR:
  129. m_popupPositionCombo.SetCurSel(cursorPos);
  130. break;
  131. case POS_AT_PREVIOUS:
  132. m_popupPositionCombo.SetCurSel(prevPos);
  133. break;
  134. default:
  135. m_popupPositionCombo.SetCurSel(cursorPos);
  136. }
  137. UpdateData(FALSE);
  138. theApp.m_Language.UpdateOptionGeneral(this);
  139. //move after we translate so the en change gets called and we update with the correct translated value for environment variable
  140. CString csPath = CGetSetOptions::GetDBPath(false);
  141. m_ePath.SetWindowText(csPath);
  142. return TRUE;
  143. }
  144. #define NO_MATCH -2
  145. #define FOUND_MATCH -1
  146. void COptionsGeneral::FillLanguages()
  147. {
  148. CString csFile = CGetSetOptions::GetPath(PATH_LANGUAGE);
  149. csFile += "*.xml";
  150. CString csLanguage = CGetSetOptions::GetLanguageFile();
  151. CFileFind find;
  152. BOOL bCont = find.FindFile(csFile);
  153. int nEnglishIndex = NO_MATCH;
  154. while(bCont)
  155. {
  156. bCont = find.FindNextFile();
  157. int nIndex = m_cbLanguage.AddString(find.GetFileTitle());
  158. if(find.GetFileTitle() == csLanguage)
  159. {
  160. nEnglishIndex = -1;
  161. m_cbLanguage.SetCurSel(nIndex);
  162. }
  163. else if(find.GetFileTitle() == _T("English"))
  164. {
  165. if(nEnglishIndex == NO_MATCH)
  166. nEnglishIndex = nIndex;
  167. }
  168. }
  169. if(nEnglishIndex >= 0)
  170. {
  171. m_cbLanguage.SetCurSel(nEnglishIndex);
  172. }
  173. }
  174. BOOL COptionsGeneral::OnApply()
  175. {
  176. UpdateData();
  177. #ifndef _DEBUG
  178. if (CGetSetOptions::GetIsWindowsApp() == FALSE)
  179. {
  180. CGetSetOptions::SetRunOnStartUp(m_btRunOnStartup.GetCheck());
  181. }
  182. #endif
  183. CGetSetOptions::SetCheckForMaxEntries(m_btMaximumCheck.GetCheck());
  184. CGetSetOptions::SetCheckForExpiredEntries(m_btExpire.GetCheck());
  185. CGetSetOptions::SetMaxEntries(m_eMaxSavedCopies.GetNumber());
  186. CGetSetOptions::SetExpiredEntries(m_eExpireAfter.GetNumber());
  187. CString stringVal;
  188. m_copyAppInclude.GetWindowText(stringVal);
  189. g_Opt.SetCopyAppInclude(stringVal);
  190. m_copyAppExclude.GetWindowText(stringVal);
  191. g_Opt.SetCopyAppExclude(stringVal);
  192. CString csLanguage;
  193. if(m_cbLanguage.GetCurSel() >= 0)
  194. {
  195. m_cbLanguage.GetLBText(m_cbLanguage.GetCurSel(), csLanguage);
  196. g_Opt.SetLanguageFile(csLanguage);
  197. }
  198. if(csLanguage.IsEmpty() == FALSE)
  199. {
  200. if(!theApp.m_Language.LoadLanguageFile(csLanguage))
  201. {
  202. CString cs;
  203. cs.Format(_T("Error loading language file - %s - \n\n%s"), csLanguage, theApp.m_Language.m_csLastError);
  204. MessageBox(cs, _T("Ditto"), MB_OK);
  205. }
  206. }
  207. CString toSavePath;
  208. m_ePath.GetWindowText(toSavePath);
  209. CString resolvedPath = CGetSetOptions::ResolvePath(toSavePath);
  210. bool bOpenNewDatabase = false;
  211. if(resolvedPath.IsEmpty() == FALSE)
  212. {
  213. if(FileExists(resolvedPath) == FALSE)
  214. {
  215. CString cs;
  216. cs.Format(_T("The database %s does not exist.\n\nCreate a new database?"), resolvedPath);
  217. if(MessageBox(cs, _T("Ditto"), MB_YESNO) == IDYES)
  218. {
  219. // -- create a new one
  220. if(CreateDB(resolvedPath))
  221. {
  222. bOpenNewDatabase = true;
  223. }
  224. else
  225. MessageBox(_T("Error Creating Database"));
  226. }
  227. else
  228. return FALSE;
  229. }
  230. else
  231. {
  232. if(ValidDB(resolvedPath) == FALSE)
  233. {
  234. MessageBox(_T("Invalid Database"), _T("Ditto"), MB_OK);
  235. m_ePath.SetFocus();
  236. return FALSE;
  237. }
  238. else
  239. {
  240. bOpenNewDatabase = true;
  241. }
  242. }
  243. if(bOpenNewDatabase)
  244. {
  245. CGetSetOptions::SetDBPath(toSavePath);
  246. if(OpenDatabase(resolvedPath) == FALSE)
  247. {
  248. MessageBox(_T("Error Opening new database"), _T("Ditto"), MB_OK);
  249. m_ePath.SetFocus();
  250. return FALSE;
  251. }
  252. else
  253. {
  254. theApp.RefreshView();
  255. }
  256. }
  257. }
  258. CGetSetOptions::SetQuickPastePosition((int)m_popupPositionCombo.GetItemData(m_popupPositionCombo.GetCurSel()));
  259. if (m_LogFont.lfWeight != 0)
  260. {
  261. CGetSetOptions::SetFont(m_LogFont);
  262. }
  263. CString currentTheme = g_Opt.GetTheme();
  264. CString csTheme = _T("");
  265. if (m_cbTheme.GetCurSel() >= 0)
  266. {
  267. if (m_cbTheme.GetItemData(m_cbTheme.GetCurSel()) == 1)
  268. {
  269. m_cbTheme.GetLBText(m_cbTheme.GetCurSel(), csTheme);
  270. g_Opt.SetTheme(csTheme);
  271. }
  272. else
  273. {
  274. g_Opt.SetTheme("");
  275. }
  276. }
  277. else
  278. {
  279. g_Opt.SetTheme("");
  280. }
  281. if (currentTheme != csTheme)
  282. {
  283. m_pParent->m_themeChanged = TRUE;
  284. }
  285. return CPropertyPage::OnApply();
  286. }
  287. BOOL COptionsGeneral::OnSetActive()
  288. {
  289. return CPropertyPage::OnSetActive();
  290. }
  291. //void COptionsGeneral::OnSetDbPath()
  292. //{
  293. // if(m_btSetDatabasePath.GetCheck() == BST_CHECKED)
  294. // {
  295. // m_ePath.EnableWindow(TRUE);
  296. // m_btGetPath.EnableWindow(TRUE);
  297. // }
  298. // else
  299. // {
  300. // m_ePath.EnableWindow(FALSE);
  301. // m_btGetPath.EnableWindow(FALSE);
  302. // }
  303. //}
  304. void COptionsGeneral::OnGetPath()
  305. {
  306. OPENFILENAME FileName;
  307. TCHAR szFileName[400];
  308. TCHAR szDir[400];
  309. memset(&FileName, 0, sizeof(FileName));
  310. memset(szFileName, 0, sizeof(szFileName));
  311. memset(&szDir, 0, sizeof(szDir));
  312. FileName.lStructSize = sizeof(FileName);
  313. FileName.lpstrTitle = _T("Open Database");
  314. FileName.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST | OFN_NOCHANGEDIR;
  315. FileName.nMaxFile = 400;
  316. FileName.lpstrFile = szFileName;
  317. FileName.lpstrInitialDir = szDir;
  318. FileName.lpstrFilter = _T("Ditto Databases (*.db; *.mdb)\0*.db;*.mdb\0\0");
  319. FileName.lpstrDefExt = _T("db");
  320. FileName.hwndOwner = m_hWnd;
  321. if(GetOpenFileName(&FileName) == 0)
  322. return;
  323. CString csPath(FileName.lpstrFile);
  324. if(FileExists(csPath))
  325. {
  326. if(ValidDB(csPath) == FALSE)
  327. {
  328. MessageBox(_T("Invalid Database"), _T("Ditto"), MB_OK);
  329. m_ePath.SetFocus();
  330. }
  331. else
  332. {
  333. m_ePath.SetWindowText(csPath);
  334. }
  335. }
  336. else
  337. {
  338. m_ePath.SetWindowText(csPath);
  339. }
  340. }
  341. void COptionsGeneral::OnButtonAbout()
  342. {
  343. CDimWnd dim(this->GetParent());
  344. CMultiLanguage Lang;
  345. CString csLanguage;
  346. m_cbLanguage.GetLBText(m_cbLanguage.GetCurSel(), csLanguage);
  347. Lang.SetOnlyGetHeader(true);
  348. if(Lang.LoadLanguageFile(csLanguage))
  349. {
  350. CString csMessage;
  351. csMessage.Format(_T("Language - %s\n")
  352. _T("Version - %d\n")
  353. _T("Author - %s\n")
  354. _T("Notes - %s"), csLanguage,
  355. Lang.GetVersion(),
  356. Lang.GetAuthor(),
  357. Lang.GetNotes());
  358. MessageBox(csMessage, _T("Ditto"), MB_OK);
  359. }
  360. else
  361. {
  362. CString csError;
  363. csError.Format(_T("Error loading language file - %s - reason = "), csLanguage, Lang.m_csLastError);
  364. MessageBox(csError, _T("Ditto"), MB_OK);
  365. }
  366. }
  367. void COptionsGeneral::OnBnClickedButtonAdvanced()
  368. {
  369. CDimWnd dim(this->GetParent());
  370. CAdvGeneral adv(this);
  371. adv.DoModal();
  372. }
  373. HBRUSH COptionsGeneral::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
  374. {
  375. HBRUSH hbr = CPropertyPage::OnCtlColor(pDC, pWnd, nCtlColor);
  376. switch(nCtlColor)
  377. {
  378. case CTLCOLOR_DLG: // dialog
  379. case CTLCOLOR_STATIC: // static, checkbox, read-only edit, etc.
  380. //pDC->SetBkColor(RGB(251, 251, 251));
  381. //hbr = m_brush;
  382. break;
  383. }
  384. return hbr;
  385. }
  386. void COptionsGeneral::FillThemes()
  387. {
  388. CString csFile = CGetSetOptions::GetPath(PATH_THEMES);
  389. csFile += "*.xml";
  390. CString csTheme = CGetSetOptions::GetTheme();
  391. m_cbTheme.Clear();
  392. int windowsSettingIndex = m_cbTheme.AddString(theApp.m_Language.GetString("FollowWindowsTheme", "(Follow windows light/dark themes)"));
  393. //_T("(Follow windows light/dark themes)"));
  394. m_cbTheme.SetItemData(windowsSettingIndex, 0);
  395. CFileFind find;
  396. BOOL bCont = find.FindFile(csFile);
  397. bool bSetCurSel = false;
  398. while (bCont)
  399. {
  400. bCont = find.FindNextFile();
  401. CTheme theme;
  402. if (theme.Load(find.GetFileTitle(), true, false))
  403. {
  404. if (theme.FileVersion() >= 2 && theme.FileVersion() < 100)
  405. {
  406. int nIndex = m_cbTheme.AddString(find.GetFileTitle());
  407. m_cbTheme.SetItemData(nIndex, 1);
  408. if (find.GetFileTitle() == csTheme)
  409. {
  410. m_cbTheme.SetCurSel(nIndex);
  411. bSetCurSel = true;
  412. }
  413. }
  414. }
  415. }
  416. int nIndex = m_cbTheme.AddString(DEFAULT_THEME);
  417. m_cbTheme.SetItemData(nIndex, 1);
  418. if (csTheme == DEFAULT_THEME)
  419. {
  420. m_cbTheme.SetCurSel(nIndex);
  421. bSetCurSel = true;
  422. }
  423. if (bSetCurSel == false)
  424. {
  425. int count = m_cbTheme.GetCount();
  426. for (int i = 0; i < count; i++)
  427. {
  428. if (m_cbTheme.GetItemData(i) == 0)
  429. {
  430. m_cbTheme.SetCurSel(i);
  431. break;
  432. }
  433. }
  434. }
  435. }
  436. void COptionsGeneral::OnBnClickedButtonTheme()
  437. {
  438. CDimWnd dim(this->GetParent());
  439. CTheme theme;
  440. CString csTheme;
  441. m_cbTheme.GetLBText(m_cbTheme.GetCurSel(), csTheme);
  442. if (m_cbTheme.GetItemData(m_cbTheme.GetCurSel()) == 0)
  443. return;
  444. if (csTheme == DEFAULT_THEME)
  445. return;
  446. if (theme.Load(csTheme, true, false))
  447. {
  448. CString csMessage;
  449. csMessage.Format(_T("Theme - %s\n")
  450. _T("Version - %d\n")
  451. _T("Author - %s\n")
  452. _T("Notes - %s"), csTheme,
  453. theme.FileVersion(),
  454. theme.Author(),
  455. theme.Notes());
  456. MessageBox(csMessage, _T("Ditto"), MB_OK);
  457. }
  458. else
  459. {
  460. CString csError;
  461. csError.Format(_T("Error loading theme file - %s - reason = "), csTheme, theme.LastError());
  462. MessageBox(csError, _T("Ditto"), MB_OK);
  463. }
  464. }
  465. void COptionsGeneral::OnBnClickedButtonDefaultFault()
  466. {
  467. memset(&m_LogFont, 0, sizeof(m_LogFont));
  468. m_LogFont.lfHeight = -13;
  469. m_LogFont.lfWeight = 400;
  470. m_LogFont.lfCharSet = 1;
  471. STRCPY(m_LogFont.lfFaceName, _T("Segoe UI"));
  472. CString cs;
  473. cs.Format(_T("Font - %s (%d)"), m_LogFont.lfFaceName, GetFontSize(m_hWnd, m_LogFont));
  474. m_btFont.SetWindowText(cs);
  475. }
  476. int COptionsGeneral::GetFontSize(HWND hWnd, const LOGFONT& lf)
  477. {
  478. //font is saved un scaled, so scale it with the default values to get the font size
  479. int nFontSize = -::MulDiv(lf.lfHeight, 72, 96);
  480. return nFontSize;
  481. }
  482. void COptionsGeneral::OnBnClickedButtonFont()
  483. {
  484. //don't pass in an hwnd so it uses GetDeviceCaps to get the dpi, system not per monitor
  485. CDPI dpi;
  486. m_LogFont.lfHeight = dpi.Scale(m_LogFont.lfHeight);
  487. CFontDialog dlg(&m_LogFont, (CF_TTONLY | CF_SCREENFONTS), 0, this);
  488. if (dlg.DoModal() == IDOK)
  489. {
  490. memcpy(&m_LogFont, dlg.m_cf.lpLogFont, sizeof(LOGFONT));
  491. //save the font unscaled, we will scale it per monitor later
  492. m_LogFont.lfHeight = dpi.UnScale(m_LogFont.lfHeight);
  493. CString cs;
  494. cs.Format(_T("Font - %s (%d)"), m_LogFont.lfFaceName, GetFontSize(m_hWnd, m_LogFont));
  495. m_btFont.SetWindowText(cs);
  496. }
  497. }
  498. //void COptionsGeneral::OnNMClickSyslinkEnvVarInfo(NMHDR *pNMHDR, LRESULT *pResult)
  499. //{
  500. // CString url = _T("https:////sourceforge.net//p//ditto-cp//wiki//EnvironmentVariables//");
  501. //
  502. // CHyperLink::GotoURL(url, SW_SHOW);
  503. //
  504. // *pResult = 0;
  505. //}
  506. //
  507. //
  508. //void COptionsGeneral::OnEnChangePath()
  509. //{
  510. // // TODO: If this is a RICHEDIT control, the control will not
  511. // // send this notification unless you override the CPropertyPage::OnInitDialog()
  512. // // function and call CRichEditCtrl().SetEventMask()
  513. // // with the ENM_CHANGE flag ORed into the mask.
  514. //
  515. // // TODO: Add your control notification handler code here
  516. //}
  517. void COptionsGeneral::OnEnChangePath()
  518. {
  519. if (m_originalEnvVariables == _T(""))
  520. {
  521. m_envVarLink.GetWindowText(m_originalEnvVariables);
  522. }
  523. CString toSavePath;
  524. m_ePath.GetWindowText(toSavePath);
  525. if (toSavePath.Find(_T("%")) >= 0)
  526. {
  527. CString resolvedPath = CGetSetOptions::ResolvePath(toSavePath);
  528. m_envVarLink.SetWindowText(resolvedPath);
  529. }
  530. else
  531. {
  532. m_envVarLink.SetWindowText(m_originalEnvVariables);
  533. }
  534. }
  535. void COptionsGeneral::OnClickedMaximumEntries()
  536. {
  537. if (m_btMaximumCheck.GetCheck() == BST_CHECKED)
  538. {
  539. m_eMaxSavedCopies.EnableWindow(TRUE);
  540. }
  541. else
  542. {
  543. m_eMaxSavedCopies.EnableWindow(FALSE);
  544. }
  545. }
  546. void COptionsGeneral::OnClickedExpireEntries()
  547. {
  548. if (m_btExpire.GetCheck() == BST_CHECKED)
  549. {
  550. m_eExpireAfter.EnableWindow(TRUE);
  551. }
  552. else
  553. {
  554. m_eExpireAfter.EnableWindow(FALSE);
  555. }
  556. }