Options.cpp 52 KB

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