Options.cpp 64 KB

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