Options.cpp 63 KB

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