Options.cpp 45 KB

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