Options.cpp 56 KB

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