Options.cpp 44 KB

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