OptionsGeneral.cpp 16 KB

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