Options.cpp 46 KB

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