Options.cpp 55 KB

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