Options.cpp 56 KB

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