Options.cpp 49 KB

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