Options.cpp 60 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479
  1. #include "stdafx.h"
  2. #include "Options.h"
  3. #include "AlphaBlend.h"
  4. #include "Misc.h"
  5. #include "shared/TextConvert.h"
  6. #include "sqlite\CppSQLite3.h"
  7. #include "Path.h"
  8. #include "CP_Main.h"
  9. #include "ActionEnums.h"
  10. using namespace nsPath;
  11. UINT WritePrivateProfileInt(LPCTSTR lpAppName, LPCTSTR lpKeyName, INT nValue, LPCTSTR lpFileName)
  12. {
  13. // Locals
  14. TCHAR szBuff[25];
  15. // Format
  16. SPRINTF(szBuff, _T("%d"), nValue);
  17. // Write
  18. return WritePrivateProfileString(lpAppName, lpKeyName, szBuff, lpFileName);
  19. }
  20. long CGetSetOptions::m_nLinesPerRow;
  21. BOOL CGetSetOptions::m_bUseCtrlNumAccel;
  22. BOOL CGetSetOptions::m_bAllowDuplicates;
  23. BOOL CGetSetOptions::m_bUpdateTimeOnPaste;
  24. BOOL CGetSetOptions::m_bSaveMultiPaste;
  25. BOOL CGetSetOptions::m_bShowPersistent;
  26. long CGetSetOptions::m_bDescTextSize;
  27. BOOL CGetSetOptions::m_bDescShowLeadingWhiteSpace;
  28. BOOL CGetSetOptions::m_bAllwaysShowDescription;
  29. long CGetSetOptions::m_bDoubleClickingOnCaptionDoes;
  30. BOOL CGetSetOptions::m_bPrompForNewGroupName;
  31. BOOL CGetSetOptions::m_bSendPasteOnFirstTenHotKeys;
  32. CSendClients CGetSetOptions::m_SendClients[MAX_SEND_CLIENTS];
  33. long CGetSetOptions::m_lAutoSendClientCount;
  34. CString CGetSetOptions::m_csIPListToPutOnClipboard;
  35. BOOL CGetSetOptions::m_bLogSendReceiveErrors;
  36. BOOL CGetSetOptions::m_HideDittoOnHotKeyIfAlreadyShown;
  37. long CGetSetOptions::m_lPort;
  38. BOOL CGetSetOptions::m_bDrawThumbnail;
  39. CStringA CGetSetOptions::m_csPassword;
  40. BOOL CGetSetOptions::m_bDrawRTF;
  41. BOOL CGetSetOptions::m_bMultiPasteReverse;
  42. CString CGetSetOptions::m_csPlaySoundOnCopy;
  43. CStringArray CGetSetOptions::m_csNetworkPasswordArray;
  44. BOOL CGetSetOptions::m_bSendPasteMessageAfterSelection;
  45. BOOL CGetSetOptions::m_bFindAsYouType;
  46. BOOL CGetSetOptions::m_bEnsureEntireWindowCanBeSeen;
  47. BOOL CGetSetOptions::m_bShowAllClipsInMainList;
  48. long CGetSetOptions::m_lMaxClipSizeInBytes;
  49. DWORD CGetSetOptions::m_dwSaveClipDelay;
  50. long CGetSetOptions::m_lProcessDrawClipboardDelay;
  51. BOOL CGetSetOptions::m_bEnableDebugLogging;
  52. BOOL CGetSetOptions::m_bEnsureConnectToClipboard;
  53. bool CGetSetOptions::m_bOutputDebugString;
  54. bool CGetSetOptions::m_bInConversion = false;
  55. bool CGetSetOptions::m_bFromIni = false;
  56. bool CGetSetOptions::m_portable = false;
  57. bool CGetSetOptions::m_windowsApp = false;
  58. CString CGetSetOptions::m_csIniFileName;
  59. __int64 CGetSetOptions::nLastDbWriteTime = 0;
  60. CTheme CGetSetOptions::m_Theme;
  61. BOOL CGetSetOptions::m_showScrollBar = false;
  62. CGetSetOptions g_Opt;
  63. BOOL CGetSetOptions::m_bShowAlwaysOnTopWarning = TRUE;
  64. CRegExFilterHelper CGetSetOptions::m_regexHelper;
  65. CGetSetOptions::CGetSetOptions()
  66. {
  67. }
  68. CGetSetOptions::~CGetSetOptions()
  69. {
  70. }
  71. void CGetSetOptions::LoadSettings()
  72. {
  73. CString exeDir = CGetSetOptions::GetExeFileName();
  74. exeDir = GetFilePath(exeDir);
  75. FIX_CSTRING_PATH(exeDir);
  76. CString windowsAppFile = exeDir += _T("WindowsApp");
  77. if (FileExists(windowsAppFile))
  78. {
  79. m_windowsApp = true;
  80. m_bFromIni = true;
  81. //always use the ini file in the app data folder for windows store
  82. m_csIniFileName = GetIniFileName(false);
  83. }
  84. else
  85. {
  86. m_csIniFileName = GetIniFileName(true);
  87. CString portable = GetFilePath(m_csIniFileName);
  88. portable += _T("portable");
  89. if (FileExists(portable))
  90. {
  91. m_portable = true;
  92. }
  93. //first check if ini file is in app directory
  94. if (m_portable || FileExists(m_csIniFileName))
  95. {
  96. m_bFromIni = true;
  97. }
  98. else
  99. {
  100. //next check if it's in app data
  101. m_csIniFileName = GetIniFileName(false);
  102. if (FileExists(m_csIniFileName))
  103. {
  104. m_bFromIni = true;
  105. }
  106. }
  107. }
  108. if(m_bFromIni)
  109. {
  110. CString csPath = GetFilePath(m_csIniFileName);
  111. if(FileExists(csPath) == FALSE)
  112. CreateDirectory(csPath, NULL);
  113. //create the ini file as unicode, this way we can save unicode string to the ini file
  114. //http://www.codeproject.com/Articles/9071/Using-Unicode-in-INI-files
  115. CreateIniFile(m_csIniFileName);
  116. }
  117. /*CString cs = GetDBPath();
  118. SetDBPath(_T("some path"));
  119. CString cs2 = GetDBPath();*/
  120. GetSetCurrentDirectory();
  121. //First time we run, set some defaults
  122. if (GetDBPath() == _T("") &&
  123. GetTotalCopyCount() == 0)
  124. {
  125. SetCheckForMaxEntries(TRUE);
  126. SetSimpleTextSearch(TRUE);
  127. }
  128. m_nLinesPerRow = GetLinesPerRow();
  129. m_bUseCtrlNumAccel = GetUseCtrlNumForFirstTenHotKeys();
  130. m_bAllowDuplicates = GetAllowDuplicates();
  131. m_bUpdateTimeOnPaste = GetUpdateTimeOnPaste();
  132. m_bSaveMultiPaste = GetSaveMultiPaste();
  133. m_bShowPersistent = GetShowPersistent();
  134. m_bDescTextSize = GetDescTextSize();
  135. m_bDescShowLeadingWhiteSpace = GetDescShowLeadingWhiteSpace();
  136. m_bAllwaysShowDescription = GetAllwaysShowDescription();
  137. m_bDoubleClickingOnCaptionDoes = GetDoubleClickingOnCaptionDoes();
  138. m_bPrompForNewGroupName = GetPrompForNewGroupName();
  139. m_bSendPasteOnFirstTenHotKeys = GetSendPasteOnFirstTenHotKeys();
  140. m_csIPListToPutOnClipboard = GetListToPutOnClipboard();
  141. m_bLogSendReceiveErrors = GetLogSendReceiveErrors();
  142. m_HideDittoOnHotKeyIfAlreadyShown = GetHideDittoOnHotKeyIfAlreadyShown();
  143. m_lPort = GetPort();
  144. m_bDrawThumbnail = GetDrawThumbnail();
  145. m_csPassword = GetNetworkPassword();
  146. m_bDrawRTF = GetDrawRTF();
  147. m_bMultiPasteReverse = GetMultiPasteReverse();
  148. m_csPlaySoundOnCopy = GetPlaySoundOnCopy();
  149. m_bSendPasteMessageAfterSelection = GetSendPasteAfterSelection();
  150. m_bFindAsYouType = GetFindAsYouType();
  151. m_bEnsureEntireWindowCanBeSeen = GetEnsureEntireWindowCanBeSeen();
  152. m_bShowAllClipsInMainList = GetShowAllClipsInMainList();
  153. m_lMaxClipSizeInBytes = GetMaxClipSizeInBytes();
  154. m_dwSaveClipDelay = GetSaveClipDelay();
  155. m_lProcessDrawClipboardDelay = GetProcessDrawClipboardDelay();
  156. m_bEnableDebugLogging = GetEnableDebugLogging();
  157. m_bEnsureConnectToClipboard = GetEnsureConnectToClipboard();
  158. m_bOutputDebugString = false;
  159. m_showScrollBar = GetShowScrollBar();
  160. m_bShowAlwaysOnTopWarning = GetShowAlwaysOnTopWarning();
  161. GetExtraNetworkPassword(true);
  162. for(int i = 0; i < MAX_SEND_CLIENTS; i++)
  163. {
  164. GetSendClients(i);
  165. }
  166. for (int i = 0; i < MAX_REGEX_FILTERS; i++)
  167. {
  168. CRegExFilterData data;
  169. data.m_regEx = GetRegexFilter(i);
  170. data.m_processFilters = GetRegexFilterByProcessName(i);
  171. m_regexHelper.Add(i, data);
  172. }
  173. GetClientSendCount();
  174. m_Theme.Load(GetTheme());
  175. }
  176. void CGetSetOptions::CreateIniFile(CString path)
  177. {
  178. if (!::PathFileExists(path))
  179. {
  180. // UTF16-LE BOM(FFFE)
  181. WORD wBOM = 0xFEFF;
  182. DWORD NumberOfBytesWritten;
  183. HANDLE hFile = ::CreateFile(path, GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
  184. ::WriteFile(hFile, &wBOM, sizeof(WORD), &NumberOfBytesWritten, NULL);
  185. //LPTSTR pszSectionB = _T("[StringTable]"); // section name with bracket
  186. //::WriteFile(hFile, pszSectionB, (_tcslen(pszSectionB) + 1)*(sizeof(TCHAR)), &NumberOfBytesWritten, NULL);
  187. ::CloseHandle(hFile);
  188. }
  189. }
  190. void CGetSetOptions::ConverSettingsToIni()
  191. {
  192. m_bInConversion = true;
  193. CSize sz;
  194. CPoint pt;
  195. GetQuickPasteSize(sz);
  196. SetQuickPasteSize(sz);
  197. GetQuickPastePoint(pt);
  198. SetQuickPastePoint(pt);
  199. GetEditWndSize(sz);
  200. SetEditWndSize(sz);
  201. GetEditWndPoint(pt);
  202. SetEditWndPoint(pt);
  203. SetShowIconInSysTray(GetShowIconInSysTray());
  204. SetRunOnStartUp(GetRunOnStartUp());
  205. SetEnableTransparency(GetEnableTransparency());
  206. SetTransparencyPercent(GetTransparencyPercent());
  207. SetLinesPerRow(GetLinesPerRow());
  208. SetQuickPastePosition(GetQuickPastePosition());
  209. SetCopyGap(GetCopyGap());
  210. SetDBPath(GetDBPath());
  211. SetCheckForMaxEntries(GetCheckForMaxEntries());
  212. SetCheckForExpiredEntries(GetCheckForExpiredEntries());
  213. SetMaxEntries(GetMaxEntries());
  214. SetExpiredEntries(GetExpiredEntries());
  215. SetTripCopyCount(GetTripCopyCount());
  216. SetTripPasteCount(GetTripPasteCount());
  217. SetTripDate(GetTripDate());
  218. SetTotalCopyCount(GetTotalCopyCount());
  219. SetTotalPasteCount(GetTotalPasteCount());
  220. SetTotalDate(GetTotalDate());
  221. SetUpdateFilePath(GetUpdateFilePath());
  222. SetUpdateInstallPath(GetUpdateInstallPath());
  223. SetLastUpdate(GetLastUpdate());
  224. SetCheckForUpdates(GetCheckForUpdates());
  225. SetUseCtrlNumForFirstTenHotKeys(GetUseCtrlNumForFirstTenHotKeys());
  226. SetAllowDuplicates(GetAllowDuplicates());
  227. SetUpdateTimeOnPaste(GetUpdateTimeOnPaste());
  228. SetSaveMultiPaste(GetSaveMultiPaste());
  229. SetShowPersistent(GetShowPersistent());
  230. SetShowTextForFirstTenHotKeys(GetShowTextForFirstTenHotKeys());
  231. SetMainHWND(GetMainHWND());
  232. SetCaptionPos(GetCaptionPos());
  233. SetAutoHide(GetAutoHide());
  234. SetDescTextSize(GetDescTextSize());
  235. SetDescShowLeadingWhiteSpace(GetDescShowLeadingWhiteSpace());
  236. SetAllwaysShowDescription(GetAllwaysShowDescription());
  237. SetDoubleClickingOnCaptionDoes(GetDoubleClickingOnCaptionDoes());
  238. SetPrompForNewGroupName(GetPrompForNewGroupName());
  239. SetSendPasteOnFirstTenHotKeys(GetSendPasteOnFirstTenHotKeys());
  240. for(int i = 0; i < MAX_SEND_CLIENTS; i++)
  241. {
  242. GetSendClients(i);
  243. SetSendClients(m_SendClients[i], i);
  244. }
  245. SetListToPutOnClipboard(GetListToPutOnClipboard());
  246. SetLogSendReceiveErrors(GetLogSendReceiveErrors());
  247. SetHideDittoOnHotKeyIfAlreadyShown(GetHideDittoOnHotKeyIfAlreadyShown());
  248. SetPort(GetPort());
  249. SetDisableRecieve(GetDisableRecieve());
  250. LOGFONT font;
  251. GetFont(font);
  252. SetFont(font);
  253. SetDrawThumbnail(GetDrawThumbnail());
  254. CStringA PassA = GetNetworkPassword();
  255. CString PassW = PassA;
  256. SetNetworkPassword(PassW);
  257. SetDrawRTF(GetDrawRTF());
  258. SetMultiPasteReverse(GetMultiPasteReverse());
  259. SetPlaySoundOnCopy(GetPlaySoundOnCopy());
  260. SetSendPasteAfterSelection(GetSendPasteAfterSelection());
  261. SetFindAsYouType(GetFindAsYouType());
  262. SetEnsureEntireWindowCanBeSeen(GetEnsureEntireWindowCanBeSeen());
  263. SetShowAllClipsInMainList(GetShowAllClipsInMainList());
  264. SetExtraNetworkPassword(GetExtraNetworkPassword(false));
  265. SetMaxClipSizeInBytes(GetMaxClipSizeInBytes());
  266. SetLanguageFile(GetLanguageFile());
  267. SetSaveClipDelay(GetSaveClipDelay());
  268. SetProcessDrawClipboardDelay(GetProcessDrawClipboardDelay());
  269. SetEnableDebugLogging(GetEnableDebugLogging());
  270. SetEnsureConnectToClipboard(GetEnsureConnectToClipboard());
  271. SetPromptWhenDeletingClips(GetPromptWhenDeletingClips());
  272. SetLastImportDir(GetLastImportDir());
  273. SetLastExportDir(GetLastExportDir());
  274. SetUpdateDescWhenSavingClip(GetUpdateDescWhenSavingClip());
  275. m_bInConversion = false;
  276. }
  277. CString CGetSetOptions::GetIniFileName(bool bLocalIniFile)
  278. {
  279. CString csPath = _T("c:\\program files\\Ditto\\");
  280. if(bLocalIniFile)
  281. {
  282. csPath = GetFilePath(GetExeFileName());
  283. }
  284. else
  285. {
  286. csPath = GetAppDataPath();
  287. }
  288. csPath += "Ditto.Settings";
  289. return csPath;
  290. }
  291. CString CGetSetOptions::GetAppDataPath()
  292. {
  293. CString csPath;
  294. LPMALLOC pMalloc;
  295. if (GetIsWindowsApp())
  296. {
  297. if (SUCCEEDED(::SHGetMalloc(&pMalloc)))
  298. {
  299. LPITEMIDLIST pidlPrograms;
  300. SHGetSpecialFolderLocation(NULL, CSIDL_LOCAL_APPDATA, &pidlPrograms);
  301. TCHAR string[MAX_PATH];
  302. SHGetPathFromIDList(pidlPrograms, string);
  303. pMalloc->Free(pidlPrograms);
  304. pMalloc->Release();
  305. csPath = string;
  306. }
  307. FIX_CSTRING_PATH(csPath);
  308. csPath += "Ditto_WindowsApp\\";
  309. }
  310. else
  311. {
  312. if (SUCCEEDED(::SHGetMalloc(&pMalloc)))
  313. {
  314. LPITEMIDLIST pidlPrograms;
  315. SHGetSpecialFolderLocation(NULL, CSIDL_APPDATA, &pidlPrograms);
  316. TCHAR string[MAX_PATH];
  317. SHGetPathFromIDList(pidlPrograms, string);
  318. pMalloc->Free(pidlPrograms);
  319. pMalloc->Release();
  320. csPath = string;
  321. }
  322. FIX_CSTRING_PATH(csPath);
  323. csPath += "Ditto\\";
  324. }
  325. return csPath;
  326. }
  327. CString CGetSetOptions::GetTempFilePath()
  328. {
  329. CString csPath;
  330. wchar_t wchPath[MAX_PATH];
  331. if (GetTempPathW(MAX_PATH, wchPath))
  332. {
  333. csPath = wchPath;
  334. csPath += _T("Ditto\\");
  335. CreateDirectory(csPath, NULL);
  336. }
  337. return csPath;
  338. }
  339. long CGetSetOptions::GetResolutionProfileLong(CString csName, long lDefaultValue, CString csNewPath)
  340. {
  341. CString resName;
  342. resName.Format(_T("(%dx%d)_%s"), GetScreenWidth(), GetScreenHeight(), csName);
  343. long value = GetProfileLong(resName, INT_MIN, csNewPath);
  344. if(value == INT_MIN)
  345. {
  346. value = GetProfileLong(csName, lDefaultValue, csNewPath);
  347. }
  348. return value;
  349. }
  350. BOOL CGetSetOptions::SetResolutionProfileLong(CString csName, long lValue)
  351. {
  352. CString resName;
  353. resName.Format(_T("(%dx%d)_%s"), GetScreenWidth(), GetScreenHeight(), csName);
  354. return SetProfileLong(resName, lValue);
  355. }
  356. long CGetSetOptions::GetProfileLong(CString csName, long lDefaultValue, CString csNewPath)
  357. {
  358. if(m_bFromIni && !m_bInConversion)
  359. {
  360. CString csApp(_T("Ditto"));
  361. if(csNewPath.IsEmpty() == FALSE)
  362. {
  363. csApp = csNewPath;
  364. }
  365. return GetPrivateProfileInt(csApp, csName, lDefaultValue, m_csIniFileName);
  366. }
  367. CString csPath(_T(REG_PATH));
  368. if(csNewPath.IsEmpty() == FALSE)
  369. {
  370. csPath += "\\" + csNewPath;
  371. }
  372. HKEY hkKey;
  373. long lResult = RegOpenKeyEx(HKEY_CURRENT_USER, csPath, NULL, KEY_READ, &hkKey);
  374. if(lResult != ERROR_SUCCESS)
  375. return lDefaultValue;
  376. DWORD buffer;
  377. DWORD len = sizeof(buffer);
  378. DWORD type;
  379. lResult = ::RegQueryValueEx(hkKey, csName, 0, &type, (LPBYTE)&buffer, &len);
  380. RegCloseKey(hkKey);
  381. if(lResult == ERROR_SUCCESS)
  382. return (long)buffer;
  383. return lDefaultValue;
  384. }
  385. CString CGetSetOptions::GetProfileString(CString csName, CString csDefault, CString csNewPath)
  386. {
  387. if(m_bFromIni && !m_bInConversion)
  388. {
  389. CString csApp(_T("Ditto"));
  390. if(csNewPath.IsEmpty() == FALSE)
  391. {
  392. csApp = csNewPath;
  393. }
  394. TCHAR cString[MAX_PATH];
  395. GetPrivateProfileString(csApp, csName, csDefault, cString, sizeof(cString), m_csIniFileName);
  396. return cString;
  397. }
  398. CString csPath(_T(REG_PATH));
  399. if(csNewPath.IsEmpty() == FALSE)
  400. {
  401. csPath += "\\" + csNewPath;
  402. }
  403. HKEY hkKey;
  404. long lResult = RegOpenKeyEx(HKEY_CURRENT_USER, csPath, NULL, KEY_READ, &hkKey);
  405. TCHAR szString[256];
  406. ZeroMemory(szString, sizeof(szString));
  407. DWORD dwBufLen = 256;
  408. lResult = ::RegQueryValueEx(hkKey , csName, NULL, NULL, (LPBYTE)szString, &dwBufLen);
  409. RegCloseKey(hkKey);
  410. if(lResult != ERROR_SUCCESS)
  411. return csDefault;
  412. return szString;
  413. }
  414. BOOL CGetSetOptions::SetProfileLong(CString csName, long lValue)
  415. {
  416. if(m_bFromIni)
  417. {
  418. return WritePrivateProfileInt(_T("Ditto"), csName, lValue, m_csIniFileName);
  419. }
  420. HKEY hkKey;
  421. DWORD dWord;
  422. long lResult = RegCreateKeyEx(HKEY_CURRENT_USER, _T(REG_PATH), NULL,
  423. NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS,
  424. NULL, &hkKey, &dWord);
  425. if(lResult != ERROR_SUCCESS)
  426. return FALSE;
  427. DWORD val = (DWORD)lValue;
  428. lResult = ::RegSetValueEx(hkKey, csName, 0, REG_DWORD, (LPBYTE)&val, sizeof(DWORD));
  429. RegCloseKey(hkKey);
  430. return lResult == ERROR_SUCCESS;
  431. }
  432. BOOL CGetSetOptions::SetProfileString(CString csName, CString csValue)
  433. {
  434. if(m_bFromIni)
  435. {
  436. return WritePrivateProfileString(_T("Ditto"), csName, csValue, m_csIniFileName);
  437. }
  438. HKEY hkKey;
  439. DWORD dWord;
  440. long lResult = RegCreateKeyEx(HKEY_CURRENT_USER, _T(REG_PATH), NULL,
  441. NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS,
  442. NULL, &hkKey, &dWord);
  443. if(lResult != ERROR_SUCCESS)
  444. return FALSE;
  445. ::RegSetValueEx(hkKey, csName, NULL, REG_SZ,
  446. (BYTE*)(LPCTSTR)csValue, csValue.GetLength()*sizeof(TCHAR));
  447. RegCloseKey(hkKey);
  448. return lResult == ERROR_SUCCESS;
  449. }
  450. BOOL CGetSetOptions::SetProfileData(CString csName, LPVOID lpData, DWORD dwLength)
  451. {
  452. if(m_bFromIni)
  453. {
  454. ASSERT(!"SetProfileData not supported in .ini settings");
  455. return FALSE;
  456. }
  457. HKEY hkKey;
  458. DWORD dWord;
  459. long lResult = RegCreateKeyEx(HKEY_CURRENT_USER, _T(REG_PATH), NULL,
  460. NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS,
  461. NULL, &hkKey, &dWord);
  462. if(lResult != ERROR_SUCCESS)
  463. return FALSE;
  464. ::RegSetValueEx(hkKey, csName, NULL, REG_BINARY,
  465. (BYTE*)lpData, dwLength);
  466. RegCloseKey(hkKey);
  467. return lResult == ERROR_SUCCESS;
  468. }
  469. BOOL CGetSetOptions::GetProfileFont(CString csSection, LOGFONT &font)
  470. {
  471. font.lfHeight = GetPrivateProfileInt(csSection, _T("Height"), 0, m_csIniFileName);
  472. font.lfWidth = GetPrivateProfileInt(csSection, _T("Width"), 0, m_csIniFileName);
  473. font.lfEscapement = GetPrivateProfileInt(csSection, _T("Escapement"), 0, m_csIniFileName);
  474. font.lfOrientation = GetPrivateProfileInt(csSection, _T("Orientation"), 0, m_csIniFileName);
  475. font.lfWeight = GetPrivateProfileInt(csSection, _T("Weight"), 0, m_csIniFileName);
  476. font.lfItalic = GetPrivateProfileInt(csSection, _T("Italic"), 0, m_csIniFileName);
  477. font.lfUnderline = GetPrivateProfileInt(csSection, _T("Underline"), 0, m_csIniFileName);
  478. font.lfStrikeOut = GetPrivateProfileInt(csSection, _T("StrikeOut"), 0, m_csIniFileName);
  479. font.lfCharSet = GetPrivateProfileInt(csSection, _T("CharSet"), 0, m_csIniFileName);
  480. font.lfOutPrecision = GetPrivateProfileInt(csSection, _T("OutPrecision"), 0, m_csIniFileName);
  481. font.lfClipPrecision = GetPrivateProfileInt(csSection, _T("ClipPrecision"), 0, m_csIniFileName);
  482. font.lfQuality = GetPrivateProfileInt(csSection, _T("Quality"), 0, m_csIniFileName);
  483. font.lfPitchAndFamily = GetPrivateProfileInt(csSection, _T("PitchAndFamily"), 0, m_csIniFileName);
  484. GetPrivateProfileString(csSection, _T("FaceName"), _T(""), font.lfFaceName, sizeof(font.lfFaceName), m_csIniFileName);
  485. return TRUE;
  486. }
  487. BOOL CGetSetOptions::SetProfileFont(CString csSection, LOGFONT &font)
  488. {
  489. WritePrivateProfileInt(csSection, _T("Height"), font.lfHeight, m_csIniFileName);
  490. WritePrivateProfileInt(csSection, _T("Width"), font.lfWidth, m_csIniFileName);
  491. WritePrivateProfileInt(csSection, _T("Escapement"), font.lfEscapement, m_csIniFileName);
  492. WritePrivateProfileInt(csSection, _T("Orientation"), font.lfOrientation, m_csIniFileName);
  493. WritePrivateProfileInt(csSection, _T("Weight"), font.lfWeight, m_csIniFileName);
  494. WritePrivateProfileInt(csSection, _T("Italic"), font.lfItalic, m_csIniFileName);
  495. WritePrivateProfileInt(csSection, _T("Underline"), font.lfUnderline, m_csIniFileName);
  496. WritePrivateProfileInt(csSection, _T("StrikeOut"), font.lfStrikeOut, m_csIniFileName);
  497. WritePrivateProfileInt(csSection, _T("CharSet"), font.lfCharSet, m_csIniFileName);
  498. WritePrivateProfileInt(csSection, _T("OutPrecision"), font.lfOutPrecision, m_csIniFileName);
  499. WritePrivateProfileInt(csSection, _T("ClipPrecision"), font.lfClipPrecision, m_csIniFileName);
  500. WritePrivateProfileInt(csSection, _T("Quality"), font.lfQuality, m_csIniFileName);
  501. WritePrivateProfileInt(csSection, _T("PitchAndFamily"), font.lfPitchAndFamily, m_csIniFileName);
  502. WritePrivateProfileString(csSection, _T("FaceName"), font.lfFaceName, m_csIniFileName);
  503. return TRUE;
  504. }
  505. LPVOID CGetSetOptions::GetProfileData(CString csName, DWORD &dwLength)
  506. {
  507. if(m_bFromIni && !m_bInConversion)
  508. {
  509. ASSERT(!"GetProfileData not supported in .ini settings");
  510. return NULL;
  511. }
  512. HKEY hkKey;
  513. long lResult = RegOpenKeyEx(HKEY_CURRENT_USER, _T(REG_PATH),
  514. NULL, KEY_READ, &hkKey);
  515. lResult = ::RegQueryValueEx(hkKey , csName, NULL, NULL, NULL, &dwLength);
  516. if(lResult != ERROR_SUCCESS)
  517. return NULL;
  518. LPVOID lpVoid = new BYTE[dwLength];
  519. lResult = ::RegQueryValueEx(hkKey , csName, NULL, NULL, (LPBYTE)lpVoid, &dwLength);
  520. RegCloseKey(hkKey);
  521. if(lResult != ERROR_SUCCESS)
  522. return NULL;
  523. return lpVoid;
  524. }
  525. BOOL CGetSetOptions::GetShowIconInSysTray()
  526. {
  527. return GetProfileLong("ShowIconInSystemTray", TRUE);
  528. }
  529. BOOL CGetSetOptions::SetShowIconInSysTray(BOOL bShow)
  530. {
  531. return SetProfileLong("ShowIconInSystemTray", bShow);
  532. }
  533. BOOL CGetSetOptions::SetEnableTransparency(BOOL bCheck)
  534. {
  535. return SetProfileLong("EnableTransparency", bCheck);
  536. }
  537. BOOL CGetSetOptions::GetEnableTransparency()
  538. {
  539. return GetProfileLong("EnableTransparency", FALSE);
  540. }
  541. BOOL CGetSetOptions::SetTransparencyPercent(long lPercent)
  542. {
  543. if(lPercent > OPACITY_MAX)
  544. lPercent = OPACITY_MAX;
  545. if(lPercent < 0)
  546. lPercent = 0;
  547. return SetProfileLong("TransparencyPercent", lPercent);
  548. }
  549. long CGetSetOptions::GetTransparencyPercent()
  550. {
  551. long lValue = GetProfileLong("TransparencyPercent", 14);
  552. if(lValue > OPACITY_MAX) lValue = OPACITY_MAX;
  553. if(lValue < 0) lValue = 0;
  554. return lValue;
  555. }
  556. BOOL CGetSetOptions::SetLinesPerRow(long lLines)
  557. {
  558. m_nLinesPerRow = lLines;
  559. return SetProfileLong("LinesPerRow", lLines);
  560. }
  561. long CGetSetOptions::GetLinesPerRow()
  562. {
  563. return GetProfileLong("LinesPerRow", 2);
  564. }
  565. BOOL CGetSetOptions::GetRunOnStartUp()
  566. {
  567. HKEY hkRun;
  568. LONG nResult = RegOpenKeyEx(HKEY_CURRENT_USER,
  569. _T("Software\\Microsoft\\Windows\\CurrentVersion\\Run"),
  570. NULL, KEY_READ, &hkRun);
  571. if(nResult != ERROR_SUCCESS)
  572. return FALSE;
  573. nResult = RegQueryValueEx(hkRun, GetAppName(), NULL, NULL, NULL, NULL);
  574. RegCloseKey(hkRun);
  575. return nResult == ERROR_SUCCESS;
  576. }
  577. void CGetSetOptions::SetRunOnStartUp(BOOL bRun)
  578. {
  579. HKEY hkRun;
  580. LONG nResult = RegOpenKeyEx(HKEY_CURRENT_USER,
  581. _T("Software\\Microsoft\\Windows\\CurrentVersion\\Run"),
  582. NULL, KEY_ALL_ACCESS, &hkRun);
  583. if(nResult != ERROR_SUCCESS)
  584. return;
  585. if(bRun)
  586. {
  587. CString sExeName = GetExeFileName();
  588. ::RegSetValueEx(hkRun, GetAppName(), NULL, REG_SZ,
  589. (BYTE*)(LPCTSTR)sExeName, sExeName.GetLength()*sizeof(TCHAR));
  590. }
  591. else
  592. {
  593. ::RegDeleteValue(hkRun, GetAppName());
  594. }
  595. ::RegCloseKey(hkRun);
  596. }
  597. CString CGetSetOptions::GetExeFileName()
  598. {
  599. CString sExeName;
  600. GetModuleFileName(NULL, sExeName.GetBuffer(_MAX_PATH),_MAX_PATH);
  601. sExeName.ReleaseBuffer();
  602. return sExeName;
  603. }
  604. CString CGetSetOptions::GetAppName()
  605. {
  606. return "Ditto";
  607. }
  608. BOOL CGetSetOptions::SetQuickPastePosition(long lPosition)
  609. {
  610. return SetProfileLong("ShowQuickPastePosition", lPosition);
  611. }
  612. long CGetSetOptions::GetQuickPastePosition()
  613. {
  614. return GetProfileLong("ShowQuickPastePosition", POS_AT_CURSOR);
  615. }
  616. BOOL CGetSetOptions::SetQuickPasteSize(CSize size)
  617. {
  618. BOOL bRet = SetResolutionProfileLong("QuickPasteCX", size.cx);
  619. bRet = SetResolutionProfileLong("QuickPasteCY", size.cy);
  620. return bRet;
  621. }
  622. void CGetSetOptions::GetQuickPasteSize(CSize &size)
  623. {
  624. size.cx = GetResolutionProfileLong("QuickPasteCX", 300);
  625. size.cy = GetResolutionProfileLong("QuickPasteCY", 300);
  626. if(size.cx <= 0 && size.cy <= 0)
  627. {
  628. size.cx = 300;
  629. size.cy = 300;
  630. }
  631. }
  632. BOOL CGetSetOptions::SetQuickPastePoint(CPoint point)
  633. {
  634. BOOL bRet = SetResolutionProfileLong("QuickPasteX", point.x);
  635. bRet = SetResolutionProfileLong("QuickPasteY", point.y);
  636. return bRet;
  637. }
  638. void CGetSetOptions::GetQuickPastePoint(CPoint &point)
  639. {
  640. point.x = GetResolutionProfileLong("QuickPasteX", 300);
  641. point.y = GetResolutionProfileLong("QuickPasteY", 300);
  642. if(point.x <= 0 && point.y <= 0)
  643. {
  644. point.x = 300;
  645. point.y = 300;
  646. }
  647. }
  648. BOOL CGetSetOptions::SetEditWndSize(CSize size)
  649. {
  650. BOOL bRet = SetResolutionProfileLong("EditWndCX", size.cx);
  651. bRet = SetResolutionProfileLong("EditWndCY", size.cy);
  652. return bRet;
  653. }
  654. void CGetSetOptions::GetEditWndSize(CSize &size)
  655. {
  656. size.cx = GetResolutionProfileLong("EditWndCX", 600);
  657. size.cy = GetResolutionProfileLong("EditWndCY", 600);
  658. if(size.cx <= 0 && size.cy <= 0)
  659. {
  660. size.cx = 600;
  661. size.cy = 600;
  662. }
  663. }
  664. BOOL CGetSetOptions::SetEditWndPoint(CPoint point)
  665. {
  666. BOOL bRet = SetResolutionProfileLong("EditWndX", point.x);
  667. bRet = SetResolutionProfileLong("EditWndY", point.y);
  668. return bRet;
  669. }
  670. void CGetSetOptions::GetEditWndPoint(CPoint &point)
  671. {
  672. point.x = GetResolutionProfileLong("EditWndX", 100);
  673. point.y = GetResolutionProfileLong("EditWndY", 100);
  674. if(point.x <= 0 && point.y <= 0)
  675. {
  676. point.x = 100;
  677. point.y = 100;
  678. }
  679. }
  680. long CGetSetOptions::GetCopyGap()
  681. {
  682. return GetProfileLong("CopyGap", 150);
  683. }
  684. void CGetSetOptions::SetCopyGap(long lGap)
  685. {
  686. SetProfileLong("CopyGap", lGap);
  687. }
  688. BOOL CGetSetOptions::SetDBPathOld(CString csPath)
  689. {
  690. return SetProfileString("DBPath", csPath);
  691. }
  692. CString CGetSetOptions::GetDBPathOld()
  693. {
  694. return GetProfileString("DBPath", "");
  695. }
  696. BOOL CGetSetOptions::SetDBPath(CString csPath)
  697. {
  698. return SetProfileString("DBPath3", csPath);
  699. }
  700. CString CGetSetOptions::GetDBPath()
  701. {
  702. CString csDBPath;
  703. csDBPath = GetProfileString("DBPath3", "");
  704. return csDBPath;
  705. }
  706. void CGetSetOptions::SetCheckForMaxEntries(BOOL bVal)
  707. {
  708. SetProfileLong("CheckForMaxEntries", bVal);
  709. }
  710. BOOL CGetSetOptions::GetCheckForMaxEntries()
  711. {
  712. BOOL bDefault = FALSE;
  713. if(GetIsPortableDitto())
  714. bDefault = TRUE;
  715. return GetProfileLong("CheckForMaxEntries", bDefault);
  716. }
  717. void CGetSetOptions::SetCheckForExpiredEntries(BOOL bVal)
  718. {
  719. SetProfileLong("CheckForExpiredEntries", bVal);
  720. }
  721. BOOL CGetSetOptions::GetCheckForExpiredEntries()
  722. {
  723. return GetProfileLong("CheckForExpiredEntries", FALSE);
  724. }
  725. void CGetSetOptions::SetMaxEntries(long lVal)
  726. {
  727. SetProfileLong("MaxEntries", lVal);
  728. }
  729. long CGetSetOptions::GetMaxEntries()
  730. {
  731. long lMax = 500;
  732. if(GetIsPortableDitto())
  733. lMax = 100;
  734. return GetProfileLong("MaxEntries", lMax);
  735. }
  736. void CGetSetOptions::SetExpiredEntries(long lVal)
  737. {
  738. SetProfileLong("ExpiredEntries", lVal);
  739. }
  740. long CGetSetOptions::GetExpiredEntries()
  741. {
  742. return GetProfileLong("ExpiredEntries", 5);
  743. }
  744. void CGetSetOptions::SetTripCopyCount(long lVal)
  745. {
  746. // negative means a relative offset
  747. if(lVal < 0)
  748. lVal = GetTripCopyCount() - lVal; // add the absolute value
  749. if(GetTripDate() == 0)
  750. SetTripDate(-1);
  751. SetProfileLong("TripCopies", lVal);
  752. }
  753. long CGetSetOptions::GetTripCopyCount()
  754. {
  755. return GetProfileLong("TripCopies", 0);
  756. }
  757. void CGetSetOptions::SetTripPasteCount(long lVal)
  758. {
  759. // negative means a relative offset
  760. if(lVal < 0)
  761. lVal = GetTripPasteCount() - lVal; // add the absolute value
  762. if(GetTripDate() == 0)
  763. SetTripDate(-1);
  764. SetProfileLong("TripPastes", lVal);
  765. }
  766. long CGetSetOptions::GetTripPasteCount()
  767. {
  768. return GetProfileLong("TripPastes", 0);
  769. }
  770. void CGetSetOptions::SetTripDate(long lDate)
  771. {
  772. if(lDate == -1)
  773. lDate = (long)CTime::GetCurrentTime().GetTime();
  774. SetProfileLong("TripDate", lDate);
  775. }
  776. long CGetSetOptions::GetTripDate()
  777. {
  778. return GetProfileLong("TripDate", 0);
  779. }
  780. void CGetSetOptions::SetTotalCopyCount(long lVal)
  781. {
  782. // negative means a relative offset
  783. if(lVal < 0)
  784. lVal = GetTotalCopyCount() - lVal; // add the absolute value
  785. if(GetTotalDate() == 0)
  786. SetTotalDate(-1);
  787. SetProfileLong("TotalCopies", lVal);
  788. }
  789. long CGetSetOptions::GetTotalCopyCount()
  790. {
  791. return GetProfileLong("TotalCopies", 0);
  792. }
  793. void CGetSetOptions::SetTotalPasteCount(long lVal)
  794. {
  795. // negative means a relative offset
  796. if(lVal < 0)
  797. lVal = GetTotalPasteCount() - lVal; // add the absolute value
  798. if(GetTotalDate() == 0)
  799. SetTotalDate(-1);
  800. SetProfileLong("TotalPastes", lVal);
  801. }
  802. long CGetSetOptions::GetTotalPasteCount()
  803. {
  804. return GetProfileLong("TotalPastes", 0);
  805. }
  806. void CGetSetOptions::SetTotalDate(long lDate)
  807. {
  808. if(lDate == -1)
  809. lDate = (long)CTime::GetCurrentTime().GetTime();
  810. SetProfileLong("TotalDate", lDate);
  811. }
  812. long CGetSetOptions::GetTotalDate()
  813. {
  814. return GetProfileLong("TotalDate", 0);
  815. }
  816. CString CGetSetOptions::GetUpdateFilePath()
  817. {
  818. return GetProfileString("UpdateFilePath", "");
  819. }
  820. BOOL CGetSetOptions::SetUpdateFilePath(CString cs)
  821. {
  822. return SetProfileString("UpdateFilePath", cs);
  823. }
  824. CString CGetSetOptions::GetUpdateInstallPath()
  825. {
  826. return GetProfileString("UpdateInstallPath", "");
  827. }
  828. BOOL CGetSetOptions::SetUpdateInstallPath(CString cs)
  829. {
  830. return SetProfileString("UpdateInstallPath", cs);
  831. }
  832. long CGetSetOptions::GetLastUpdate()
  833. {
  834. return GetProfileLong("LastUpdateDay", 0);
  835. }
  836. long CGetSetOptions::SetLastUpdate(long lValue)
  837. {
  838. return SetProfileLong("LastUpdateDay", lValue);
  839. }
  840. BOOL CGetSetOptions::GetCheckForUpdates()
  841. {
  842. return GetProfileLong("CheckForUpdates", TRUE);
  843. }
  844. BOOL CGetSetOptions::SetCheckForUpdates(BOOL bCheck)
  845. {
  846. return SetProfileLong("CheckForUpdates", bCheck);
  847. }
  848. void CGetSetOptions::SetUseCtrlNumForFirstTenHotKeys(BOOL bVal)
  849. {
  850. SetProfileLong("UseCtrlNumForFirstTenHotKeys", bVal);
  851. m_bUseCtrlNumAccel = bVal;
  852. }
  853. BOOL CGetSetOptions::GetUseCtrlNumForFirstTenHotKeys()
  854. {
  855. return GetProfileLong("UseCtrlNumForFirstTenHotKeys", 0);
  856. }
  857. void CGetSetOptions::SetAllowDuplicates(BOOL bVal)
  858. {
  859. SetProfileLong("AllowDuplicates", bVal);
  860. m_bAllowDuplicates = bVal;
  861. }
  862. BOOL CGetSetOptions::GetAllowDuplicates()
  863. {
  864. return GetProfileLong("AllowDuplicates", 0);
  865. }
  866. void CGetSetOptions::SetUpdateTimeOnPaste(BOOL bVal)
  867. {
  868. SetProfileLong("UpdateTimeOnPaste", bVal);
  869. m_bUpdateTimeOnPaste = bVal;
  870. }
  871. BOOL CGetSetOptions::GetUpdateTimeOnPaste()
  872. {
  873. return GetProfileLong("UpdateTimeOnPaste", TRUE);
  874. }
  875. void CGetSetOptions::SetSaveMultiPaste(BOOL bVal)
  876. {
  877. SetProfileLong("SaveMultiPaste", bVal);
  878. m_bSaveMultiPaste = bVal;
  879. }
  880. BOOL CGetSetOptions::GetSaveMultiPaste()
  881. {
  882. return GetProfileLong("SaveMultiPaste", 0);
  883. }
  884. void CGetSetOptions::SetShowPersistent(BOOL bVal)
  885. {
  886. SetProfileLong("ShowPersistent", bVal);
  887. m_bShowPersistent = bVal;
  888. }
  889. BOOL CGetSetOptions::GetShowPersistent()
  890. {
  891. return GetProfileLong("ShowPersistent", 0);
  892. }
  893. void CGetSetOptions::SetShowTextForFirstTenHotKeys(BOOL bVal)
  894. {
  895. SetProfileLong("ShowTextForFirstTenHotKeys", bVal);
  896. }
  897. BOOL CGetSetOptions::GetShowTextForFirstTenHotKeys()
  898. {
  899. return GetProfileLong("ShowTextForFirstTenHotKeys", TRUE);
  900. }
  901. void CGetSetOptions::SetMainHWND(long lhWnd)
  902. {
  903. SetProfileLong("MainhWnd", lhWnd);
  904. }
  905. BOOL CGetSetOptions::GetMainHWND()
  906. {
  907. return GetProfileLong("MainhWnd", 0);
  908. }
  909. void CGetSetOptions::SetCaptionPos(long lPos)
  910. {
  911. SetProfileLong("CaptionPos", lPos);
  912. }
  913. long CGetSetOptions::GetCaptionPos()
  914. {
  915. return GetProfileLong("CaptionPos", CAPTION_RIGHT);
  916. }
  917. void CGetSetOptions::SetAutoHide(BOOL bAutoHide)
  918. {
  919. SetProfileLong("AutoHide", bAutoHide);
  920. }
  921. BOOL CGetSetOptions::GetAutoHide()
  922. {
  923. return GetProfileLong("AutoHide", FALSE);
  924. }
  925. void CGetSetOptions::SetDescTextSize(long lSize)
  926. {
  927. SetProfileLong("DescTextSize", lSize);
  928. m_bDescTextSize = lSize;
  929. }
  930. long CGetSetOptions::GetDescTextSize()
  931. {
  932. return GetProfileLong("DescTextSize", 500);
  933. }
  934. void CGetSetOptions::SetDescShowLeadingWhiteSpace(BOOL bVal)
  935. {
  936. SetProfileLong("DescShowLeadingWhiteSpace", bVal);
  937. m_bDescShowLeadingWhiteSpace = bVal;
  938. }
  939. BOOL CGetSetOptions::GetDescShowLeadingWhiteSpace()
  940. {
  941. return GetProfileLong("DescShowLeadingWhiteSpace", FALSE);
  942. }
  943. void CGetSetOptions::SetAllwaysShowDescription(long bShow)
  944. {
  945. SetProfileLong("AllwaysShowDescription", bShow);
  946. m_bAllwaysShowDescription = bShow;
  947. }
  948. BOOL CGetSetOptions::GetAllwaysShowDescription()
  949. {
  950. return GetProfileLong("AllwaysShowDescription", FALSE);
  951. }
  952. void CGetSetOptions::SetDoubleClickingOnCaptionDoes(long lOption)
  953. {
  954. SetProfileLong("DoubleClickingOnCaptionDoes", lOption);
  955. m_bDoubleClickingOnCaptionDoes = lOption;
  956. }
  957. long CGetSetOptions::GetDoubleClickingOnCaptionDoes()
  958. {
  959. return GetProfileLong("DoubleClickingOnCaptionDoes", TOGGLES_ALLWAYS_ON_TOP);
  960. }
  961. void CGetSetOptions::SetPrompForNewGroupName(BOOL bOption)
  962. {
  963. SetProfileLong("PrompForNewGroupName", bOption);
  964. m_bPrompForNewGroupName = bOption;
  965. }
  966. BOOL CGetSetOptions::GetPrompForNewGroupName()
  967. {
  968. return GetProfileLong("PrompForNewGroupName", TRUE);
  969. }
  970. void CGetSetOptions::SetSendPasteOnFirstTenHotKeys(BOOL bOption)
  971. {
  972. SetProfileLong("SendPasteOnFirstTenHotKeys", bOption);
  973. m_bSendPasteOnFirstTenHotKeys = bOption;
  974. }
  975. BOOL CGetSetOptions::GetSendPasteOnFirstTenHotKeys()
  976. {
  977. return GetProfileLong("SendPasteOnFirstTenHotKeys", TRUE);
  978. }
  979. void CGetSetOptions::SetSendClients(CSendClients Client, int nPos)
  980. {
  981. CString cs;
  982. cs.Format(_T("sendclient_ip_%d"), nPos);
  983. SetProfileString(cs, Client.csIP);
  984. cs.Format(_T("sendclient_autosend_%d"), nPos);
  985. SetProfileLong(cs, Client.bSendAll);
  986. cs.Format(_T("sendclient_description_%d"), nPos);
  987. SetProfileString(cs, Client.csDescription);
  988. Client.bShownFirstError = m_SendClients[nPos].bShownFirstError;
  989. m_SendClients[nPos] = Client;
  990. }
  991. CSendClients CGetSetOptions::GetSendClients(int nPos)
  992. {
  993. CSendClients Client;
  994. CString cs;
  995. cs.Format(_T("sendclient_ip_%d"), nPos);
  996. Client.csIP = GetProfileString(cs, "");
  997. cs.Format(_T("sendclient_autosend_%d"), nPos);
  998. Client.bSendAll = GetProfileLong(cs, FALSE);
  999. cs.Format(_T("sendclient_description_%d"), nPos);
  1000. Client.csDescription = GetProfileString(cs, "");
  1001. m_SendClients[nPos] = Client;
  1002. return Client;
  1003. }
  1004. void CGetSetOptions::GetClientSendCount()
  1005. {
  1006. m_lAutoSendClientCount = 0;
  1007. for(int i = 0; i < MAX_SEND_CLIENTS; i++)
  1008. {
  1009. if(m_SendClients[i].csIP.GetLength() > 0)
  1010. {
  1011. if(m_SendClients[i].bSendAll)
  1012. m_lAutoSendClientCount++;
  1013. }
  1014. }
  1015. }
  1016. CString CGetSetOptions::GetListToPutOnClipboard()
  1017. {
  1018. CString cs = GetProfileString("ListToPutOnClipboard", "");
  1019. cs.MakeUpper();
  1020. return cs;
  1021. }
  1022. BOOL CGetSetOptions::SetListToPutOnClipboard(CString cs)
  1023. {
  1024. cs.MakeUpper();
  1025. m_csIPListToPutOnClipboard = cs;
  1026. return SetProfileString("ListToPutOnClipboard", cs);
  1027. }
  1028. void CGetSetOptions::SetLogSendReceiveErrors(BOOL bOption)
  1029. {
  1030. m_bLogSendReceiveErrors = bOption;
  1031. SetProfileLong("LogSendReceiveErrors", bOption);
  1032. }
  1033. BOOL CGetSetOptions::GetLogSendReceiveErrors()
  1034. {
  1035. return GetProfileLong("LogSendReceiveErrors", FALSE);
  1036. }
  1037. BOOL CGetSetOptions::GetHideDittoOnHotKeyIfAlreadyShown()
  1038. {
  1039. return GetProfileLong("HideDittoOnHotKeyIfAlreadyShown", TRUE);
  1040. }
  1041. void CGetSetOptions::SetHideDittoOnHotKeyIfAlreadyShown(BOOL bVal)
  1042. {
  1043. m_HideDittoOnHotKeyIfAlreadyShown = bVal;
  1044. SetProfileLong("HideDittoOnHotKeyIfAlreadyShown", bVal);
  1045. }
  1046. void CGetSetOptions::SetPort(long lPort)
  1047. {
  1048. m_lPort = lPort;
  1049. SetProfileLong("SendRecvPort", lPort);
  1050. }
  1051. long CGetSetOptions::GetPort()
  1052. {
  1053. return GetProfileLong("SendRecvPort", 23443);
  1054. }
  1055. BOOL CGetSetOptions::GetDisableRecieve()
  1056. {
  1057. BOOL bDefault = FALSE;
  1058. if(GetIsPortableDitto())
  1059. bDefault = TRUE;
  1060. if(GetIsWindowsApp())
  1061. bDefault = TRUE;
  1062. return GetProfileLong("DisableRecieve", bDefault);
  1063. }
  1064. void CGetSetOptions::SetDisableRecieve(BOOL bVal)
  1065. {
  1066. SetProfileLong("DisableRecieve", bVal);
  1067. }
  1068. BOOL CGetSetOptions::GetFont(LOGFONT &font)
  1069. {
  1070. if(m_bFromIni && !m_bInConversion)
  1071. {
  1072. GetProfileFont("DisplayFont5", font);
  1073. //Return true if there is a font name
  1074. //other wise load the default font below
  1075. if(font.lfFaceName[0] != 0)
  1076. {
  1077. return TRUE;
  1078. }
  1079. }
  1080. else
  1081. {
  1082. DWORD dwLength = 0;
  1083. LPVOID lpVoid = GetProfileData("DisplayFont5", dwLength);
  1084. if(lpVoid)
  1085. {
  1086. if(sizeof(font) == dwLength)
  1087. {
  1088. memcpy(&font, lpVoid, dwLength);
  1089. delete[] lpVoid;
  1090. lpVoid = NULL;
  1091. return TRUE;
  1092. }
  1093. else
  1094. {
  1095. ASSERT(!"invalid font struct size");
  1096. }
  1097. delete[] lpVoid;
  1098. lpVoid = NULL;
  1099. }
  1100. }
  1101. ZeroMemory(&font, sizeof(font));
  1102. font.lfHeight = -theApp.m_metrics.PointsToPixels(10);
  1103. font.lfWeight = 400;
  1104. font.lfCharSet = 1;
  1105. STRCPY(font.lfFaceName, _T("Segoe UI"));
  1106. return TRUE;
  1107. }
  1108. void CGetSetOptions::SetFont(LOGFONT &font)
  1109. {
  1110. if(m_bFromIni)
  1111. {
  1112. SetProfileFont("DisplayFont5", font);
  1113. }
  1114. else
  1115. {
  1116. SetProfileData("DisplayFont5", &font, sizeof(LOGFONT));
  1117. }
  1118. }
  1119. void CGetSetOptions::SetDrawThumbnail(long bDraw)
  1120. {
  1121. SetProfileLong("DrawThumbnail", bDraw);
  1122. m_bDrawThumbnail = bDraw;
  1123. }
  1124. BOOL CGetSetOptions::GetDrawThumbnail()
  1125. {
  1126. BOOL bDrawThumbnails = TRUE;
  1127. return GetProfileLong("DrawThumbnail", bDrawThumbnails);
  1128. }
  1129. void CGetSetOptions::SetExtraNetworkPassword(CString csPassword)
  1130. {
  1131. SetProfileString("NetworkExtraPassword", csPassword);
  1132. }
  1133. CString CGetSetOptions::GetExtraNetworkPassword(bool bFillArray)
  1134. {
  1135. CString cs = GetProfileString("NetworkExtraPassword", "");
  1136. if(bFillArray)
  1137. {
  1138. m_csNetworkPasswordArray.RemoveAll();
  1139. TCHAR seps[] = _T(",");
  1140. TCHAR *token;
  1141. TCHAR *pString = cs.GetBuffer(cs.GetLength());
  1142. /* Establish string and get the first token: */
  1143. token = STRTOK(pString, seps);
  1144. while(token != NULL)
  1145. {
  1146. CString cs(token);
  1147. cs.TrimLeft();
  1148. cs.TrimRight();
  1149. m_csNetworkPasswordArray.Add(cs);
  1150. // Get next token
  1151. token = STRTOK(NULL, seps);
  1152. }
  1153. cs.ReleaseBuffer();
  1154. }
  1155. return cs;
  1156. }
  1157. void CGetSetOptions::SetNetworkPassword(CString csPassword)
  1158. {
  1159. CTextConvert Con;
  1160. Con.ConvertToUTF8(csPassword, m_csPassword);
  1161. SetProfileString("NetworkStringPassword", csPassword);
  1162. }
  1163. CStringA CGetSetOptions::GetNetworkPassword()
  1164. {
  1165. CString cs = GetProfileString("NetworkStringPassword", "LetMeIn");
  1166. CTextConvert Con;
  1167. CStringA csReturn;
  1168. Con.ConvertToUTF8(cs, csReturn);
  1169. return csReturn;
  1170. }
  1171. void CGetSetOptions::SetDrawRTF(long bDraw)
  1172. {
  1173. SetProfileLong("DrawRTF", bDraw);
  1174. m_bDrawRTF = bDraw;
  1175. }
  1176. BOOL CGetSetOptions::GetDrawRTF()
  1177. {
  1178. return GetProfileLong("DrawRTF", FALSE);
  1179. }
  1180. void CGetSetOptions::SetMultiPasteReverse(BOOL bVal)
  1181. {
  1182. SetProfileLong("MultiPasteReverse", bVal);
  1183. m_bMultiPasteReverse = bVal;
  1184. }
  1185. BOOL CGetSetOptions::GetMultiPasteReverse()
  1186. {
  1187. return GetProfileLong("MultiPasteReverse", TRUE);
  1188. }
  1189. void CGetSetOptions::SetPlaySoundOnCopy(CString cs)
  1190. {
  1191. m_csPlaySoundOnCopy = cs;
  1192. SetProfileString("PlaySoundOnCopy", cs);
  1193. }
  1194. CString CGetSetOptions::GetPlaySoundOnCopy()
  1195. {
  1196. return GetProfileString("PlaySoundOnCopy", "");
  1197. }
  1198. void CGetSetOptions::SetSendPasteAfterSelection(BOOL bVal)
  1199. {
  1200. m_bSendPasteMessageAfterSelection = bVal;
  1201. SetProfileLong("SendPasteMessageAfterSelection", bVal);
  1202. }
  1203. BOOL CGetSetOptions::GetSendPasteAfterSelection()
  1204. {
  1205. return GetProfileLong("SendPasteMessageAfterSelection", TRUE);
  1206. }
  1207. void CGetSetOptions::SetFindAsYouType(BOOL bVal)
  1208. {
  1209. m_bFindAsYouType = bVal;
  1210. SetProfileLong("FindAsYouType", bVal);
  1211. }
  1212. BOOL CGetSetOptions::GetFindAsYouType()
  1213. {
  1214. return GetProfileLong("FindAsYouType", TRUE);
  1215. }
  1216. void CGetSetOptions::SetEnsureEntireWindowCanBeSeen(BOOL bVal)
  1217. {
  1218. m_bEnsureEntireWindowCanBeSeen = bVal;
  1219. SetProfileLong("EnsureEntireWindowCanBeSeen", bVal);
  1220. }
  1221. BOOL CGetSetOptions::GetEnsureEntireWindowCanBeSeen()
  1222. {
  1223. return GetProfileLong("EnsureEntireWindowCanBeSeen", TRUE);
  1224. }
  1225. void CGetSetOptions::SetShowAllClipsInMainList(BOOL bVal)
  1226. {
  1227. m_bShowAllClipsInMainList = bVal;
  1228. SetProfileLong("ShowAllClipsInMainList", bVal);
  1229. }
  1230. BOOL CGetSetOptions::GetShowAllClipsInMainList()
  1231. {
  1232. return GetProfileLong("ShowAllClipsInMainList", TRUE);
  1233. }
  1234. long CGetSetOptions::GetMaxClipSizeInBytes()
  1235. {
  1236. return GetProfileLong("MaxClipSizeInBytes", 0);
  1237. }
  1238. void CGetSetOptions::SetMaxClipSizeInBytes(long lSize)
  1239. {
  1240. m_lMaxClipSizeInBytes = lSize;
  1241. SetProfileLong("MaxClipSizeInBytes", lSize);
  1242. }
  1243. CString CGetSetOptions::GetLanguageFile()
  1244. {
  1245. return GetProfileString("LanguageFile", "");
  1246. }
  1247. void CGetSetOptions::SetLanguageFile(CString csLanguage)
  1248. {
  1249. SetProfileString("LanguageFile", csLanguage);
  1250. }
  1251. ULONG CGetSetOptions::GetSaveClipDelay()
  1252. {
  1253. return (ULONG)GetProfileLong("SaveClipDelay", 500);
  1254. }
  1255. void CGetSetOptions::SetSaveClipDelay(DWORD dwDelay)
  1256. {
  1257. m_dwSaveClipDelay = dwDelay;
  1258. SetProfileLong("SaveClipDelay", dwDelay);
  1259. }
  1260. long CGetSetOptions::GetProcessDrawClipboardDelay()
  1261. {
  1262. return GetProfileLong("ProcessDrawClipboardDelay", 100);
  1263. }
  1264. void CGetSetOptions::SetProcessDrawClipboardDelay(long lDelay)
  1265. {
  1266. m_lProcessDrawClipboardDelay = lDelay;
  1267. SetProfileLong("ProcessDrawClipboardDelay", lDelay);
  1268. }
  1269. BOOL CGetSetOptions::GetEnableDebugLogging()
  1270. {
  1271. return GetProfileLong("EnableDebugLogging", FALSE);
  1272. }
  1273. void CGetSetOptions::SetEnableDebugLogging(BOOL bEnable)
  1274. {
  1275. m_bEnableDebugLogging = bEnable;
  1276. SetProfileLong("EnableDebugLogging", bEnable);
  1277. }
  1278. BOOL CGetSetOptions::GetEnsureConnectToClipboard()
  1279. {
  1280. return GetProfileLong("EnsureConnected2", FALSE);
  1281. }
  1282. void CGetSetOptions::SetEnsureConnectToClipboard(BOOL bSet)
  1283. {
  1284. m_bEnsureConnectToClipboard = bSet;
  1285. SetProfileLong("EnsureConnected2", bSet);
  1286. }
  1287. BOOL CGetSetOptions::GetPromptWhenDeletingClips()
  1288. {
  1289. return GetProfileLong("PromptWhenDeletingClips", TRUE);
  1290. }
  1291. void CGetSetOptions::SetPromptWhenDeletingClips(BOOL bSet)
  1292. {
  1293. SetProfileLong("PromptWhenDeletingClips", bSet);
  1294. }
  1295. CString CGetSetOptions::GetLastImportDir()
  1296. {
  1297. return GetProfileString("LastImportDir", "");
  1298. }
  1299. void CGetSetOptions::SetLastImportDir(CString csDir)
  1300. {
  1301. SetProfileString("LastImportDir", csDir);
  1302. }
  1303. CString CGetSetOptions::GetLastExportDir()
  1304. {
  1305. return GetProfileString("LastExportDir", "");
  1306. }
  1307. void CGetSetOptions::SetLastExportDir(CString csDir)
  1308. {
  1309. SetProfileString("LastExportDir", csDir);
  1310. }
  1311. BOOL CGetSetOptions::GetUpdateDescWhenSavingClip()
  1312. {
  1313. return GetProfileLong("UpdateDescWhenSaving", TRUE);
  1314. }
  1315. void CGetSetOptions::SetUpdateDescWhenSavingClip(BOOL bSet)
  1316. {
  1317. SetProfileLong("UpdateDescWhenSaving", bSet);
  1318. }
  1319. CString CGetSetOptions::GetPath(long lPathID)
  1320. {
  1321. CString csDir = CGetSetOptions::GetExeFileName();
  1322. csDir = GetFilePath(csDir);
  1323. FIX_CSTRING_PATH(csDir);
  1324. //U3_APP_DATA_PATH - <U3_DEVICE_PATH>\System\Apps\{app_unique_id}\Data
  1325. //U3_HOST_EXEC_PATH - %APPDATA%\U3\{device_serial_number}\{app_unique_id}\Exec
  1326. //U3_DEVICE_EXEC_PATH - <U3_DEVICE_PATH>\System\Apps\{app_unique_id}\Exec
  1327. switch(lPathID)
  1328. {
  1329. case PATH_HELP:
  1330. csDir += "Help\\";
  1331. break;
  1332. case PATH_LANGUAGE:
  1333. csDir += "language\\";
  1334. break;
  1335. case PATH_THEMES:
  1336. csDir += "Themes\\";
  1337. break;
  1338. case PATH_LOG_FILE:if(CGetSetOptions::GetIsPortableDitto() == false)
  1339. csDir = GetAppDataPath();
  1340. break;
  1341. case PATH_UPDATE_FILE:
  1342. //same path as the executable
  1343. break;
  1344. case PATH_DATABASE:
  1345. break;
  1346. case PATH_INI:
  1347. break;
  1348. case PATH_U3_HWND_INI:
  1349. break;
  1350. case PATH_ADDINS:
  1351. csDir += "Addins\\";
  1352. break;
  1353. case PATH_REMOTE_FILES:
  1354. if (CGetSetOptions::GetIsPortableDitto() == false)
  1355. {
  1356. csDir = GetTempFilePath();
  1357. }
  1358. csDir += "ReceivedFiles\\";
  1359. break;
  1360. case PATH_DRAG_FILES:
  1361. if (CGetSetOptions::GetIsPortableDitto() == false)
  1362. {
  1363. csDir = GetTempFilePath();
  1364. }
  1365. csDir += "DragFiles\\";
  1366. break;
  1367. case PATH_CLIP_DIFF:
  1368. if (CGetSetOptions::GetIsPortableDitto() == false)
  1369. {
  1370. csDir = GetTempFilePath();
  1371. }
  1372. csDir += _T("ClipCompare\\");
  1373. break;
  1374. }
  1375. CreateDirectory(csDir, NULL);
  1376. return csDir;
  1377. }
  1378. void CGetSetOptions::WriteU3Hwnd(HWND hWnd)
  1379. {
  1380. CString csIniFile = GetPath(PATH_U3_HWND_INI);
  1381. csIniFile += _T("DittohWnd.ini");
  1382. WritePrivateProfileInt(_T("Ditto"), _T("MainhWnd"), (int)hWnd, csIniFile);
  1383. }
  1384. long CGetSetOptions::GetDittoRestoreClipboardDelay()
  1385. {
  1386. return GetProfileLong("RestoreClipboardDelay", 750);
  1387. }
  1388. void CGetSetOptions::SetDittoRestoreClipboardDelay(long lDelay)
  1389. {
  1390. SetProfileLong("RestoreClipboardDelay", lDelay);
  1391. }
  1392. void CGetSetOptions::GetCopyBufferItem(int nPos, CCopyBufferItem &Item)
  1393. {
  1394. Item.m_lCopyHotKey = GetProfileLong(StrF(_T("CopyBufferCopyHotKey_%d"), nPos), 0);
  1395. Item.m_lPasteHotKey = GetProfileLong(StrF(_T("CopyBufferPasteHotKey_%d"), nPos), 0);
  1396. Item.m_lCutHotKey = GetProfileLong(StrF(_T("CopyBufferCutHotKey_%d"), nPos), 0);
  1397. Item.m_bPlaySoundOnCopy = GetProfileLong(StrF(_T("CopyBufferPlaySound_%d"), nPos), 0);
  1398. }
  1399. void CGetSetOptions::SetCopyBufferItem(int nPos, CCopyBufferItem &Item)
  1400. {
  1401. SetProfileLong(StrF(_T("CopyBufferCopyHotKey_%d"), nPos), Item.m_lCopyHotKey);
  1402. SetProfileLong(StrF(_T("CopyBufferPasteHotKey_%d"), nPos), Item.m_lPasteHotKey);
  1403. SetProfileLong(StrF(_T("CopyBufferCutHotKey_%d"), nPos), Item.m_lCutHotKey);
  1404. SetProfileLong(StrF(_T("CopyBufferPlaySound_%d"), nPos), Item.m_bPlaySoundOnCopy);
  1405. }
  1406. CString CGetSetOptions::GetMultiPasteSeparator(bool bConvertToLineFeeds)
  1407. {
  1408. CString csSep = GetProfileString(_T("MultiPasteSeparator"), _T("[LF]"));
  1409. if(bConvertToLineFeeds)
  1410. {
  1411. CString csLineFeed(_T("\r\n"));
  1412. csSep.Replace(_T("[LF]"), csLineFeed);
  1413. csSep.Replace(_T("[lf]"), csLineFeed);
  1414. }
  1415. return csSep;
  1416. }
  1417. void CGetSetOptions::SetMultiPasteSeparator(CString csSep)
  1418. {
  1419. SetProfileString(_T("MultiPasteSeparator"), csSep);
  1420. }
  1421. BOOL CGetSetOptions::GetSetCurrentDirectory()
  1422. {
  1423. if(m_portable)
  1424. {
  1425. CString csExePath = GetFilePath(GetExeFileName());
  1426. FIX_CSTRING_PATH(csExePath);
  1427. ::SetCurrentDirectory(csExePath);
  1428. }
  1429. return m_portable == true;
  1430. }
  1431. bool CGetSetOptions::GetIsPortableDitto()
  1432. {
  1433. return m_portable;
  1434. }
  1435. bool CGetSetOptions::GetIsWindowsApp()
  1436. {
  1437. return m_windowsApp;
  1438. }
  1439. CString CGetSetOptions::GetPasteString(CString csAppName)
  1440. {
  1441. CString csString = GetProfileString(csAppName, _T(""), _T("PasteStrings"));
  1442. if(csString.IsEmpty())
  1443. return GetDefaultPasteString();
  1444. return csString;
  1445. }
  1446. CString CGetSetOptions::GetDefaultPasteString()
  1447. {
  1448. //ascii value for v
  1449. //for other language keyboards v gets converted to something else so send the base ascii value
  1450. return GetProfileString(_T("DefaultPasteString"), _T("^{VKEY86}"));
  1451. }
  1452. CString CGetSetOptions::GetCopyString(CString csAppName)
  1453. {
  1454. CString csString = GetProfileString(csAppName, _T(""), _T("CopyStrings"));
  1455. if(csString.IsEmpty())
  1456. return GetDefaultCopyString();
  1457. return csString;
  1458. }
  1459. CString CGetSetOptions::GetDefaultCopyString()
  1460. {
  1461. //ascii value for c
  1462. //for other language keyboards c gets converted to something else so send the base ascii value
  1463. return GetProfileString(_T("DefaultCopyString"), _T("^{VKEY67}"));
  1464. }
  1465. CString CGetSetOptions::GetCutString(CString csAppName)
  1466. {
  1467. CString csString = GetProfileString(csAppName, _T(""), _T("CutStrings"));
  1468. if(csString.IsEmpty())
  1469. return GetDefaultCutString();
  1470. return csString;
  1471. }
  1472. CString CGetSetOptions::GetDefaultCutString()
  1473. {
  1474. //ascii value for x
  1475. //for other language keyboards x gets converted to something else so send the base ascii value
  1476. return GetProfileString(_T("DefaultCutString"), _T("^{VKEY88}"));
  1477. }
  1478. BOOL CGetSetOptions::GetEditWordWrap()
  1479. {
  1480. return GetProfileLong(_T("EditWordWrap"), TRUE);
  1481. }
  1482. void CGetSetOptions::SetEditWordWrap(BOOL bSet)
  1483. {
  1484. SetProfileLong(_T("EditWordWrap"), bSet);
  1485. }
  1486. bool CGetSetOptions::GetAllowFriends()
  1487. {
  1488. return (GetProfileLong("AllowFriends", TRUE) == TRUE);
  1489. }
  1490. long CGetSetOptions::GetAutoMaxDelay()
  1491. {
  1492. return GetProfileLong(_T("AutoMaxDelaySeconds"), 2);
  1493. }
  1494. void CGetSetOptions::SetAutoMaxDelay(long lDelay)
  1495. {
  1496. SetProfileLong(_T("AutoMaxDelaySeconds"), lDelay);
  1497. }
  1498. void CGetSetOptions::SetTheme(CString csTheme)
  1499. {
  1500. SetProfileString(_T("Theme2"), csTheme);
  1501. }
  1502. CString CGetSetOptions::GetTheme()
  1503. {
  1504. return GetProfileString(_T("Theme2"), "");
  1505. }
  1506. long CGetSetOptions::GetKeyStateWaitTimerCount()
  1507. {
  1508. return GetProfileLong(_T("KeyStateWaitTimerCount"), 20);
  1509. }
  1510. long CGetSetOptions::GetKeyStatePasteDelay()
  1511. {
  1512. return GetProfileLong(_T("KeyStatePasteDelay"), 200);
  1513. }
  1514. DWORD CGetSetOptions::GetDittoHotKey()
  1515. {
  1516. return (DWORD)GetProfileLong(_T("DittoHotKey"), 704);
  1517. }
  1518. DWORD CGetSetOptions::SendKeysDelay()
  1519. {
  1520. return (DWORD)GetProfileLong(_T("SendKeysDelay"), 50);
  1521. }
  1522. DWORD CGetSetOptions::WaitForActiveWndTimeout()
  1523. {
  1524. return (DWORD)GetProfileLong(_T("WaitForActiveWndTimeout"), 100);
  1525. }
  1526. DWORD CGetSetOptions::FocusChangedDelay()
  1527. {
  1528. return (DWORD)GetProfileLong(_T("FocusChangedDelay"), 100);
  1529. }
  1530. DWORD CGetSetOptions::FocusWndTimerTimeout()
  1531. {
  1532. return (DWORD)GetProfileLong(_T("FocusWndTimerTimeout"), 2000);
  1533. }
  1534. BOOL CGetSetOptions::GetConnectedToClipboard()
  1535. {
  1536. return GetProfileLong("ConnectedToClipboard", TRUE);
  1537. }
  1538. void CGetSetOptions::SetConnectedToClipboard(BOOL val)
  1539. {
  1540. SetProfileLong("ConnectedToClipboard", val);
  1541. }
  1542. DWORD CGetSetOptions::GetTextOnlyRestoreDelay()
  1543. {
  1544. return (DWORD)GetProfileLong(_T("TextOnlyRestoreDelay"), 2000);
  1545. }
  1546. DWORD CGetSetOptions::GetTextOnlyPasteDelay()
  1547. {
  1548. return (DWORD)GetProfileLong(_T("TextOnlyPasteDelay"), 0);
  1549. }
  1550. BOOL CGetSetOptions::GetSetFocusToApp(CString csAppName)
  1551. {
  1552. CString focusCheck;
  1553. focusCheck = "SetFocus_";
  1554. focusCheck += csAppName;
  1555. return GetProfileLong(focusCheck, FALSE);
  1556. }
  1557. DWORD CGetSetOptions::SelectedIndex()
  1558. {
  1559. return (DWORD)GetProfileLong(_T("SelectedIndex"), 0);
  1560. }
  1561. void CGetSetOptions::SetCopyAppInclude(CString csAppName)
  1562. {
  1563. SetProfileString(_T("CopyAppInclude"), csAppName);
  1564. }
  1565. CString CGetSetOptions::GetCopyAppInclude()
  1566. {
  1567. CString includeApp = GetProfileString(_T("CopyAppInclude"), "*");
  1568. if(includeApp == "")
  1569. {
  1570. includeApp = "*";
  1571. }
  1572. return includeApp;
  1573. }
  1574. void CGetSetOptions::SetCopyAppExclude(CString csAppName)
  1575. {
  1576. SetProfileString(_T("CopyAppExclude"), csAppName);
  1577. }
  1578. CString CGetSetOptions::GetCopyAppExclude()
  1579. {
  1580. return GetProfileString(_T("CopyAppExclude"), "");
  1581. }
  1582. CString CGetSetOptions::GetCopyAppSeparator()
  1583. {
  1584. return GetProfileString(_T("CopyAppSeparator"), ";");
  1585. }
  1586. DWORD CGetSetOptions::GetNoFormatsRetryDelay()
  1587. {
  1588. return GetProfileLong(_T("NoFormatsRetryDelay"), 200);
  1589. }
  1590. DWORD CGetSetOptions::GetMainDeletesDeleteCount()
  1591. {
  1592. return GetProfileLong(_T("MainDeletesDeleteCount"), 100);
  1593. }
  1594. DWORD CGetSetOptions::GetIdleSecondsBeforeDelete()
  1595. {
  1596. return GetProfileLong(_T("IdleSecondsBeforeDelete"), 60*10);
  1597. }
  1598. DWORD CGetSetOptions::GetDbTimeout()
  1599. {
  1600. return GetProfileLong(_T("DbTimeout"), 5000);
  1601. }
  1602. DWORD CGetSetOptions::GetFunnyTickCountAdjustment()
  1603. {
  1604. return GetProfileLong(_T("FunnyTickCountAdjustment"), 300001);
  1605. }
  1606. DWORD CGetSetOptions::GetMinIdleTimeBeforeTrackFocus()
  1607. {
  1608. return GetProfileLong(_T("MinIdleTimeBeforeTrackFocus"), 100);
  1609. }
  1610. DWORD CGetSetOptions::GetTimeBeforeExpandWindow()
  1611. {
  1612. return GetProfileLong(_T("TimeBeforeExpandWindow"), 250);
  1613. }
  1614. DWORD CGetSetOptions::GetUseGuiThreadInfoForFocus()
  1615. {
  1616. return GetProfileLong(_T("UseGuiThreadInfoForFocus"), 1);
  1617. }
  1618. void CGetSetOptions::SetSearchDescription(BOOL val)
  1619. {
  1620. SetProfileLong(_T("SearchDescription"), val);
  1621. }
  1622. BOOL CGetSetOptions::GetSearchDescription()
  1623. {
  1624. return GetProfileLong(_T("SearchDescription"), 1);
  1625. }
  1626. void CGetSetOptions::SetSearchFullText(BOOL val)
  1627. {
  1628. SetProfileLong(_T("SearchFullText"), val);
  1629. }
  1630. BOOL CGetSetOptions::GetSearchFullText()
  1631. {
  1632. return GetProfileLong(_T("SearchFullText"), 0);
  1633. }
  1634. void CGetSetOptions::SetSearchQuickPaste(BOOL val)
  1635. {
  1636. SetProfileLong(_T("SearchQuickPaste"), val);
  1637. }
  1638. BOOL CGetSetOptions::GetSearchQuickPaste()
  1639. {
  1640. return GetProfileLong(_T("SearchQuickPaste"), 0);
  1641. }
  1642. void CGetSetOptions::SetSimpleTextSearch(BOOL val)
  1643. {
  1644. SetProfileLong(_T("SimpleTextSearch"), val);
  1645. }
  1646. BOOL CGetSetOptions::GetSimpleTextSearch()
  1647. {
  1648. return GetProfileLong(_T("SimpleTextSearch"), 0);
  1649. }
  1650. void CGetSetOptions::SetRegExTextSearch(BOOL val)
  1651. {
  1652. SetProfileLong(_T("RegExTextSearch"), val);
  1653. }
  1654. BOOL CGetSetOptions::GetRegExTextSearch()
  1655. {
  1656. return GetProfileLong(_T("RegExTextSearch"), 0);
  1657. }
  1658. void CGetSetOptions::SetMoveClipsOnGlobal10(BOOL val)
  1659. {
  1660. SetProfileLong(_T("MoveClipsOnGlobal10"), val);
  1661. }
  1662. BOOL CGetSetOptions::GetMoveClipsOnGlobal10()
  1663. {
  1664. return GetProfileLong(_T("MoveClipsOnGlobal10"), 0);
  1665. }
  1666. void CGetSetOptions::SetShowScrollBar(BOOL val)
  1667. {
  1668. m_showScrollBar = val;
  1669. SetProfileLong(_T("ShowScrollBar"), val);
  1670. }
  1671. BOOL CGetSetOptions::GetShowScrollBar()
  1672. {
  1673. return GetProfileLong(_T("ShowScrollBar"), 0);
  1674. }
  1675. void CGetSetOptions::SetPasteAsAdmin(BOOL val)
  1676. {
  1677. SetProfileLong(_T("PasteAsAdmin"), val);
  1678. }
  1679. BOOL CGetSetOptions::GetPasteAsAdmin()
  1680. {
  1681. return GetProfileLong(_T("PasteAsAdmin"), 1);
  1682. }
  1683. void CGetSetOptions::SetRememberDescPos(BOOL val)
  1684. {
  1685. SetProfileLong(_T("RememberDescPos"), val);
  1686. }
  1687. BOOL CGetSetOptions::GetRememberDescPos()
  1688. {
  1689. return GetProfileLong(_T("RememberDescPos"), FALSE);
  1690. }
  1691. void CGetSetOptions::SetSizeDescWindowToContent(BOOL val)
  1692. {
  1693. SetProfileLong(_T("SizeDescWindowToContent"), val);
  1694. }
  1695. BOOL CGetSetOptions::GetSizeDescWindowToContent()
  1696. {
  1697. return GetProfileLong(_T("SizeDescWindowToContent"), TRUE);
  1698. }
  1699. void CGetSetOptions::SetScaleImagesToDescWindow(BOOL val)
  1700. {
  1701. SetProfileLong(_T("ScaleImagesToDescWindow"), val);
  1702. }
  1703. BOOL CGetSetOptions::GetScaleImagesToDescWindow()
  1704. {
  1705. return GetProfileLong(_T("ScaleImagesToDescWindow"), TRUE);
  1706. }
  1707. void CGetSetOptions::SetDescWndPoint(CPoint point)
  1708. {
  1709. SetResolutionProfileLong("DescWndX", point.x);
  1710. SetResolutionProfileLong("DescWndY", point.y);
  1711. }
  1712. void CGetSetOptions::GetDescWndPoint(CPoint &point)
  1713. {
  1714. point.x = GetResolutionProfileLong("DescWndX", 100);
  1715. point.y = GetResolutionProfileLong("DescWndY", 100);
  1716. }
  1717. void CGetSetOptions::GetDescWndSize(CSize &size)
  1718. {
  1719. size.cx = GetResolutionProfileLong("DescWndCX", 300);
  1720. size.cy = GetResolutionProfileLong("DescWndCY", 300);
  1721. if(size.cx <= 0 && size.cy <= 0)
  1722. {
  1723. size.cx = 300;
  1724. size.cy = 300;
  1725. }
  1726. }
  1727. void CGetSetOptions::SetDescWndSize(CSize size)
  1728. {
  1729. SetResolutionProfileLong("DescWndCX", size.cx);
  1730. SetResolutionProfileLong("DescWndCY", size.cy);
  1731. }
  1732. void CGetSetOptions::SetShowInTaskBar(BOOL val)
  1733. {
  1734. SetProfileLong(_T("ShowInTaskBar"), val);
  1735. }
  1736. BOOL CGetSetOptions::GetShowInTaskBar()
  1737. {
  1738. return GetProfileLong(_T("ShowInTaskBar"), FALSE);
  1739. }
  1740. void CGetSetOptions::SetDiffApp(CString val)
  1741. {
  1742. SetProfileString(_T("DiffApp"), val);
  1743. }
  1744. CString CGetSetOptions::GetDiffApp()
  1745. {
  1746. return GetProfileString(_T("DiffApp"), _T(""));
  1747. }
  1748. void CGetSetOptions::SetQRCodeBorderPixels(int val)
  1749. {
  1750. SetProfileLong(_T("QRCodeBorderPixels"), val);
  1751. }
  1752. int CGetSetOptions::GetQRCodeBorderPixels()
  1753. {
  1754. return GetProfileLong(_T("QRCodeBorderPixels"), 30);
  1755. }
  1756. CString CGetSetOptions::GetTranslateUrl()
  1757. {
  1758. return GetProfileString(_T("TranslateUrl"), _T("https://translate.google.com/?tl=en#auto/en/%s"));
  1759. }
  1760. void CGetSetOptions::SetNetworkReadTimeoutMS(int val)
  1761. {
  1762. SetProfileLong(_T("NetworkReadTimeoutMS"), val);
  1763. }
  1764. int CGetSetOptions::GetNetworkReadTimeoutMS()
  1765. {
  1766. return GetProfileLong(_T("NetworkReadTimeoutMS"), 30000);
  1767. }
  1768. void CGetSetOptions::SetRequestFilesUsingIP(int val)
  1769. {
  1770. SetProfileLong(_T("RequestFilesUsingIP"), val);
  1771. }
  1772. int CGetSetOptions::GetRequestFilesUsingIP()
  1773. {
  1774. return GetProfileLong(_T("RequestFilesUsingIP"), 0);
  1775. }
  1776. int CGetSetOptions::ReadRandomFileInterval()
  1777. {
  1778. return GetProfileLong(_T("ReadRandomFileInterval"), 60);
  1779. }
  1780. int CGetSetOptions::ReadRandomFileIdleMin()
  1781. {
  1782. return GetProfileLong(_T("ReadRandomFileIdleMin"), 30);
  1783. }
  1784. BOOL CGetSetOptions::GetShowGroupsInMainList()
  1785. {
  1786. return GetProfileLong(_T("ShowGroupsInMainList"), 0);
  1787. }
  1788. void CGetSetOptions::SetShowGroupsInMainList(BOOL val)
  1789. {
  1790. SetProfileLong(_T("ShowGroupsInMainList"), val);
  1791. }
  1792. void CGetSetOptions::SetGroupDoubleClickTimeMS(int val)
  1793. {
  1794. SetProfileLong(_T("GroupDoubleClickTimeMS"), val);
  1795. }
  1796. int CGetSetOptions::GetGroupDoubleClickTimeMS()
  1797. {
  1798. return GetProfileLong(_T("GroupDoubleClickTimeMS"), 500);
  1799. }
  1800. void CGetSetOptions::SetSaveToGroupTimeoutMS(int val)
  1801. {
  1802. SetProfileLong(_T("SaveToGroupTimeoutMS"), val);
  1803. }
  1804. int CGetSetOptions::GetSaveToGroupTimeoutMS()
  1805. {
  1806. return GetProfileLong(_T("SaveToGroupTimeoutMS"), 1000);
  1807. }
  1808. void CGetSetOptions::SetCopyReasonTimeoutMS(int val)
  1809. {
  1810. SetProfileLong(_T("CopyReasonTimeoutMS"), val);
  1811. }
  1812. int CGetSetOptions::GetCopyReasonTimeoutMS()
  1813. {
  1814. return GetProfileLong(_T("CopyReasonTimeoutMS"), 1000);
  1815. }
  1816. void CGetSetOptions::SetWindowsResumeDelayReOpenDbMS(int val)
  1817. {
  1818. SetProfileLong(_T("WindowsResumeDelayReOpenDbMS"), val);
  1819. }
  1820. int CGetSetOptions::GetWindowsResumeDelayReOpenDbMS()
  1821. {
  1822. return GetProfileLong(_T("WindowsResumeDelayReOpenDbMS"), 2000);
  1823. }
  1824. BOOL CGetSetOptions::GetShowMsgWndOnCopyToGroup()
  1825. {
  1826. return GetProfileLong(_T("ShowMsgWndOnCopyToGroup"), TRUE);
  1827. }
  1828. void CGetSetOptions::SetShowMsgWndOnCopyToGroup(BOOL val)
  1829. {
  1830. SetProfileLong(_T("ShowMsgWndOnCopyToGroup"), val);
  1831. }
  1832. int CGetSetOptions::GetActionShortCutA(DWORD action, int pos)
  1833. {
  1834. CString actionText;
  1835. actionText.Format(_T("QP_ShortCut_%d_%d_A"), action, pos);
  1836. int ret = GetProfileLong(actionText, -1);
  1837. if (ret == -1)
  1838. {
  1839. ret = ActionEnums::GetDefaultShortCutKeyA((ActionEnums::ActionEnumValues)action, pos);
  1840. }
  1841. return ret;
  1842. }
  1843. void CGetSetOptions::SetActionShortCutA(int action, DWORD shortcut, int pos)
  1844. {
  1845. CString actionText;
  1846. actionText.Format(_T("QP_ShortCut_%d_%d_A"), action, pos);
  1847. SetProfileLong(actionText, shortcut);
  1848. }
  1849. int CGetSetOptions::GetActionShortCutB(DWORD action, int pos)
  1850. {
  1851. CString actionText;
  1852. actionText.Format(_T("QP_ShortCut_%d_%d_B"), action, pos);
  1853. int ret = GetProfileLong(actionText, -1);
  1854. if (ret == -1)
  1855. {
  1856. ret = ActionEnums::GetDefaultShortCutKeyB((ActionEnums::ActionEnumValues)action, pos);
  1857. }
  1858. return ret;
  1859. }
  1860. void CGetSetOptions::SetActionShortCutB(int action, DWORD shortcut, int pos)
  1861. {
  1862. CString actionText;
  1863. actionText.Format(_T("QP_ShortCut_%d_%d_B"), action, pos);
  1864. SetProfileLong(actionText, shortcut);
  1865. }
  1866. BOOL CGetSetOptions::GetShowAlwaysOnTopWarning()
  1867. {
  1868. return GetProfileLong(_T("ShowAlwaysOnTopWarning"), TRUE);
  1869. }
  1870. void CGetSetOptions::SetShowAlwaysOnTopWarning(BOOL show)
  1871. {
  1872. m_bShowAlwaysOnTopWarning = show;
  1873. SetProfileLong(_T("ShowAlwaysOnTopWarning"), show);
  1874. }
  1875. BOOL CGetSetOptions::GetUseIPFromAccept()
  1876. {
  1877. return GetProfileLong(_T("UseIPFromAccept"), TRUE);
  1878. }
  1879. void CGetSetOptions::SetUseIPFromAccept(BOOL useAccept)
  1880. {
  1881. SetProfileLong(_T("UseIPFromAccept"), useAccept);
  1882. }
  1883. int CGetSetOptions::GetDragId()
  1884. {
  1885. return GetProfileLong(_T("DragId"), 1);
  1886. }
  1887. void CGetSetOptions::SetDragId(int id)
  1888. {
  1889. SetProfileLong(_T("DragId"), id);
  1890. }
  1891. BOOL CGetSetOptions::GetShowIfClipWasPasted()
  1892. {
  1893. return GetProfileLong(_T("ShowIfClipWasPasted"), TRUE);
  1894. }
  1895. void CGetSetOptions::SetShowIfClipWasPasted(BOOL val)
  1896. {
  1897. SetProfileLong(_T("ShowIfClipWasPasted"), val);
  1898. }
  1899. int CGetSetOptions::GetLastGroupToggle()
  1900. {
  1901. return GetProfileLong(_T("LastGroupToggle"), -2);
  1902. }
  1903. void CGetSetOptions::SetLastGroupToggle(int val)
  1904. {
  1905. SetProfileLong(_T("LastGroupToggle"), val);
  1906. }
  1907. BOOL CGetSetOptions::GetMouseClickHidesDescription()
  1908. {
  1909. return GetProfileLong(_T("MouseClickHidesDescription"), TRUE);
  1910. }
  1911. void CGetSetOptions::SetMouseClickHidesDescription(int val)
  1912. {
  1913. SetProfileLong(_T("MouseClickHidesDescription"), val);
  1914. }
  1915. BOOL CGetSetOptions::GetWrapDescriptionText()
  1916. {
  1917. return GetProfileLong(_T("WrapDescriptionText"), FALSE);
  1918. }
  1919. void CGetSetOptions::SetWrapDescriptionText(int val)
  1920. {
  1921. SetProfileLong(_T("WrapDescriptionText"), val);
  1922. }
  1923. BOOL CGetSetOptions::GetUseUISelectedGroupForLastTenCopies()
  1924. {
  1925. return GetProfileLong(_T("UseUISelectedGroupForLastTenCopies"), FALSE);
  1926. }
  1927. void CGetSetOptions::SetUseUISelectedGroupForLastTenCopies(int val)
  1928. {
  1929. SetProfileLong(_T("UseUISelectedGroupForLastTenCopies"), val);
  1930. }
  1931. int CGetSetOptions::GetDelayRenderLockout()
  1932. {
  1933. return GetProfileLong(_T("DelayRenderLockout"), 1000);
  1934. }
  1935. void CGetSetOptions::SetDelayRenderLockout(int val)
  1936. {
  1937. SetProfileLong(_T("DelayRenderLockout"), val);
  1938. }
  1939. BOOL CGetSetOptions::GetAdjustClipsForCRC()
  1940. {
  1941. return GetProfileLong(_T("AdjustClipsForCRC"), TRUE);
  1942. }
  1943. void CGetSetOptions::SetAdjustClipsForCRC(int val)
  1944. {
  1945. SetProfileLong(_T("AdjustClipsForCRC"), val);
  1946. }
  1947. BOOL CGetSetOptions::GetCheckMd5OnFileTransfers()
  1948. {
  1949. return GetProfileLong(_T("CheckMd5OnFileTransfers"), TRUE);
  1950. }
  1951. void CGetSetOptions::SetCheckMd5OnFileTransfers(int val)
  1952. {
  1953. SetProfileLong(_T("CheckMd5OnFileTransfers"), val);
  1954. }
  1955. int CGetSetOptions::GetBalloonTimeout()
  1956. {
  1957. return GetProfileLong(_T("BalloonTimeout"), 2500);
  1958. }
  1959. void CGetSetOptions::SetBalloonTimeout(int val)
  1960. {
  1961. SetProfileLong(_T("BalloonTimeout"), val);
  1962. }
  1963. void CGetSetOptions::SetCustomSendToList(CString val)
  1964. {
  1965. SetProfileString(_T("CustomSendToList"), val);
  1966. }
  1967. CString CGetSetOptions::GetCustomSendToList()
  1968. {
  1969. return GetProfileString("CustomSendToList", "");
  1970. }
  1971. int CGetSetOptions::GetMaxFileContentsSize()
  1972. {
  1973. return GetProfileLong(_T("MaxFileContentsSize"), 64000000);
  1974. }
  1975. void CGetSetOptions::SetMaxFileContentsSize(int val)
  1976. {
  1977. SetProfileLong(_T("MaxFileContentsSize"), val);
  1978. }
  1979. int CGetSetOptions::GetErrorMsgPopupTimeout()
  1980. {
  1981. return GetProfileLong(_T("ErrorMsgPopupTimeout"), 3500);
  1982. }
  1983. void CGetSetOptions::SetErrorMsgPopupTimeout(int val)
  1984. {
  1985. SetProfileLong(_T("ErrorMsgPopupTimeout"), val);
  1986. }
  1987. void CGetSetOptions::SetRegexFilter(CString val, int pos)
  1988. {
  1989. CString cs;
  1990. cs.Format(_T("RegexFilter_%d"), pos);
  1991. m_regexHelper.SetRegEx(pos, std::wstring(val));
  1992. SetProfileString(cs, val);
  1993. }
  1994. CString CGetSetOptions::GetRegexFilter(int pos)
  1995. {
  1996. CString cs;
  1997. cs.Format(_T("RegexFilter_%d"), pos);
  1998. return GetProfileString(cs, "");
  1999. }
  2000. void CGetSetOptions::SetRegexFilterByProcessName(CString val, int pos)
  2001. {
  2002. CString cs;
  2003. cs.Format(_T("RegexFilterByProcessName_%d"), pos);
  2004. m_regexHelper.SetProcessFilter(pos, val);
  2005. SetProfileString(cs, val);
  2006. }
  2007. CString CGetSetOptions::GetRegexFilterByProcessName(int pos)
  2008. {
  2009. CString cs;
  2010. cs.Format(_T("RegexFilterByProcessName_%d"), pos);
  2011. return GetProfileString(cs, "*");
  2012. }