Options.cpp 56 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330
  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. if(GetIsWindowsApp())
  1026. bDefault = TRUE;
  1027. return GetProfileLong("DisableRecieve", bDefault);
  1028. }
  1029. void CGetSetOptions::SetDisableRecieve(BOOL bVal)
  1030. {
  1031. SetProfileLong("DisableRecieve", bVal);
  1032. }
  1033. BOOL CGetSetOptions::GetFont(LOGFONT &font)
  1034. {
  1035. if(m_bFromIni && !m_bInConversion)
  1036. {
  1037. GetProfileFont("DisplayFont", font);
  1038. //Return true if there is a font name
  1039. //other wise load the default font below
  1040. if(font.lfFaceName[0] != 0)
  1041. {
  1042. return TRUE;
  1043. }
  1044. }
  1045. else
  1046. {
  1047. DWORD dwLength = 0;
  1048. #ifdef _UNICODE
  1049. LPVOID lpVoid = GetProfileData("DisplayFont3", dwLength);
  1050. #else
  1051. LPVOID lpVoid = GetProfileData("DisplayFont", dwLength);
  1052. #endif
  1053. if(lpVoid)
  1054. {
  1055. if(sizeof(font) == dwLength)
  1056. {
  1057. memcpy(&font, lpVoid, dwLength);
  1058. delete[] lpVoid;
  1059. lpVoid = NULL;
  1060. return TRUE;
  1061. }
  1062. else
  1063. {
  1064. ASSERT(!"invalid font struct size");
  1065. }
  1066. delete[] lpVoid;
  1067. lpVoid = NULL;
  1068. }
  1069. }
  1070. ZeroMemory(&font, sizeof(font));
  1071. font.lfHeight = -theApp.m_metrics.PointsToPixels(8);
  1072. font.lfWeight = 400;
  1073. font.lfCharSet = 1;
  1074. STRCPY(font.lfFaceName, _T("Arial Unicode MS"));
  1075. return TRUE;
  1076. }
  1077. void CGetSetOptions::SetFont(LOGFONT &font)
  1078. {
  1079. if(m_bFromIni)
  1080. {
  1081. SetProfileFont("DisplayFont", font);
  1082. }
  1083. else
  1084. {
  1085. #ifdef _UNICODE
  1086. CString csParam = "DisplayFont3";
  1087. #else
  1088. CString csParam = "DisplayFont";
  1089. #endif
  1090. SetProfileData(csParam, &font, sizeof(LOGFONT));
  1091. }
  1092. }
  1093. void CGetSetOptions::SetDrawThumbnail(long bDraw)
  1094. {
  1095. SetProfileLong("DrawThumbnail", bDraw);
  1096. m_bDrawThumbnail = bDraw;
  1097. }
  1098. BOOL CGetSetOptions::GetDrawThumbnail()
  1099. {
  1100. BOOL bDrawThumbnails = TRUE;
  1101. return GetProfileLong("DrawThumbnail", bDrawThumbnails);
  1102. }
  1103. void CGetSetOptions::SetExtraNetworkPassword(CString csPassword)
  1104. {
  1105. SetProfileString("NetworkExtraPassword", csPassword);
  1106. }
  1107. CString CGetSetOptions::GetExtraNetworkPassword(bool bFillArray)
  1108. {
  1109. CString cs = GetProfileString("NetworkExtraPassword", "");
  1110. if(bFillArray)
  1111. {
  1112. m_csNetworkPasswordArray.RemoveAll();
  1113. TCHAR seps[] = _T(",");
  1114. TCHAR *token;
  1115. TCHAR *pString = cs.GetBuffer(cs.GetLength());
  1116. /* Establish string and get the first token: */
  1117. token = STRTOK(pString, seps);
  1118. while(token != NULL)
  1119. {
  1120. CString cs(token);
  1121. cs.TrimLeft();
  1122. cs.TrimRight();
  1123. m_csNetworkPasswordArray.Add(cs);
  1124. // Get next token
  1125. token = STRTOK(NULL, seps);
  1126. }
  1127. cs.ReleaseBuffer();
  1128. }
  1129. return cs;
  1130. }
  1131. void CGetSetOptions::SetNetworkPassword(CString csPassword)
  1132. {
  1133. CTextConvert Con;
  1134. Con.ConvertToUTF8(csPassword, m_csPassword);
  1135. SetProfileString("NetworkStringPassword", csPassword);
  1136. }
  1137. CStringA CGetSetOptions::GetNetworkPassword()
  1138. {
  1139. CString cs = GetProfileString("NetworkStringPassword", "LetMeIn");
  1140. CTextConvert Con;
  1141. CStringA csReturn;
  1142. Con.ConvertToUTF8(cs, csReturn);
  1143. return csReturn;
  1144. }
  1145. void CGetSetOptions::SetDrawRTF(long bDraw)
  1146. {
  1147. SetProfileLong("DrawRTF", bDraw);
  1148. m_bDrawRTF = bDraw;
  1149. }
  1150. BOOL CGetSetOptions::GetDrawRTF()
  1151. {
  1152. return GetProfileLong("DrawRTF", FALSE);
  1153. }
  1154. void CGetSetOptions::SetMultiPasteReverse(BOOL bVal)
  1155. {
  1156. SetProfileLong("MultiPasteReverse", bVal);
  1157. m_bMultiPasteReverse = bVal;
  1158. }
  1159. BOOL CGetSetOptions::GetMultiPasteReverse()
  1160. {
  1161. return GetProfileLong("MultiPasteReverse", TRUE);
  1162. }
  1163. void CGetSetOptions::SetPlaySoundOnCopy(CString cs)
  1164. {
  1165. m_csPlaySoundOnCopy = cs;
  1166. SetProfileString("PlaySoundOnCopy", cs);
  1167. }
  1168. CString CGetSetOptions::GetPlaySoundOnCopy()
  1169. {
  1170. return GetProfileString("PlaySoundOnCopy", "");
  1171. }
  1172. void CGetSetOptions::SetSendPasteAfterSelection(BOOL bVal)
  1173. {
  1174. m_bSendPasteMessageAfterSelection = bVal;
  1175. SetProfileLong("SendPasteMessageAfterSelection", bVal);
  1176. }
  1177. BOOL CGetSetOptions::GetSendPasteAfterSelection()
  1178. {
  1179. return GetProfileLong("SendPasteMessageAfterSelection", TRUE);
  1180. }
  1181. void CGetSetOptions::SetFindAsYouType(BOOL bVal)
  1182. {
  1183. m_bFindAsYouType = bVal;
  1184. SetProfileLong("FindAsYouType", bVal);
  1185. }
  1186. BOOL CGetSetOptions::GetFindAsYouType()
  1187. {
  1188. return GetProfileLong("FindAsYouType", TRUE);
  1189. }
  1190. void CGetSetOptions::SetEnsureEntireWindowCanBeSeen(BOOL bVal)
  1191. {
  1192. m_bEnsureEntireWindowCanBeSeen = bVal;
  1193. SetProfileLong("EnsureEntireWindowCanBeSeen", bVal);
  1194. }
  1195. BOOL CGetSetOptions::GetEnsureEntireWindowCanBeSeen()
  1196. {
  1197. return GetProfileLong("EnsureEntireWindowCanBeSeen", TRUE);
  1198. }
  1199. void CGetSetOptions::SetShowAllClipsInMainList(BOOL bVal)
  1200. {
  1201. m_bShowAllClipsInMainList = bVal;
  1202. SetProfileLong("ShowAllClipsInMainList", bVal);
  1203. }
  1204. BOOL CGetSetOptions::GetShowAllClipsInMainList()
  1205. {
  1206. return GetProfileLong("ShowAllClipsInMainList", TRUE);
  1207. }
  1208. long CGetSetOptions::GetMaxClipSizeInBytes()
  1209. {
  1210. return GetProfileLong("MaxClipSizeInBytes", 0);
  1211. }
  1212. void CGetSetOptions::SetMaxClipSizeInBytes(long lSize)
  1213. {
  1214. m_lMaxClipSizeInBytes = lSize;
  1215. SetProfileLong("MaxClipSizeInBytes", lSize);
  1216. }
  1217. CString CGetSetOptions::GetLanguageFile()
  1218. {
  1219. return GetProfileString("LanguageFile", "");
  1220. }
  1221. void CGetSetOptions::SetLanguageFile(CString csLanguage)
  1222. {
  1223. SetProfileString("LanguageFile", csLanguage);
  1224. }
  1225. ULONG CGetSetOptions::GetSaveClipDelay()
  1226. {
  1227. return (ULONG)GetProfileLong("SaveClipDelay", 500);
  1228. }
  1229. void CGetSetOptions::SetSaveClipDelay(DWORD dwDelay)
  1230. {
  1231. m_dwSaveClipDelay = dwDelay;
  1232. SetProfileLong("SaveClipDelay", dwDelay);
  1233. }
  1234. long CGetSetOptions::GetProcessDrawClipboardDelay()
  1235. {
  1236. return GetProfileLong("ProcessDrawClipboardDelay", 100);
  1237. }
  1238. void CGetSetOptions::SetProcessDrawClipboardDelay(long lDelay)
  1239. {
  1240. m_lProcessDrawClipboardDelay = lDelay;
  1241. SetProfileLong("ProcessDrawClipboardDelay", lDelay);
  1242. }
  1243. BOOL CGetSetOptions::GetEnableDebugLogging()
  1244. {
  1245. return GetProfileLong("EnableDebugLogging", FALSE);
  1246. }
  1247. void CGetSetOptions::SetEnableDebugLogging(BOOL bEnable)
  1248. {
  1249. m_bEnableDebugLogging = bEnable;
  1250. SetProfileLong("EnableDebugLogging", bEnable);
  1251. }
  1252. BOOL CGetSetOptions::GetEnsureConnectToClipboard()
  1253. {
  1254. return GetProfileLong("EnsureConnected", TRUE);
  1255. }
  1256. void CGetSetOptions::SetEnsureConnectToClipboard(BOOL bSet)
  1257. {
  1258. m_bEnsureConnectToClipboard = bSet;
  1259. SetProfileLong("EnsureConnected", bSet);
  1260. }
  1261. BOOL CGetSetOptions::GetPromptWhenDeletingClips()
  1262. {
  1263. return GetProfileLong("PromptWhenDeletingClips", TRUE);
  1264. }
  1265. void CGetSetOptions::SetPromptWhenDeletingClips(BOOL bSet)
  1266. {
  1267. SetProfileLong("PromptWhenDeletingClips", bSet);
  1268. }
  1269. CString CGetSetOptions::GetLastImportDir()
  1270. {
  1271. return GetProfileString("LastImportDir", "");
  1272. }
  1273. void CGetSetOptions::SetLastImportDir(CString csDir)
  1274. {
  1275. SetProfileString("LastImportDir", csDir);
  1276. }
  1277. CString CGetSetOptions::GetLastExportDir()
  1278. {
  1279. return GetProfileString("LastExportDir", "");
  1280. }
  1281. void CGetSetOptions::SetLastExportDir(CString csDir)
  1282. {
  1283. SetProfileString("LastExportDir", csDir);
  1284. }
  1285. BOOL CGetSetOptions::GetUpdateDescWhenSavingClip()
  1286. {
  1287. return GetProfileLong("UpdateDescWhenSaving", TRUE);
  1288. }
  1289. void CGetSetOptions::SetUpdateDescWhenSavingClip(BOOL bSet)
  1290. {
  1291. SetProfileLong("UpdateDescWhenSaving", bSet);
  1292. }
  1293. CString CGetSetOptions::GetPath(long lPathID)
  1294. {
  1295. CString csDir = CGetSetOptions::GetExeFileName();
  1296. csDir = GetFilePath(csDir);
  1297. FIX_CSTRING_PATH(csDir);
  1298. //U3_APP_DATA_PATH - <U3_DEVICE_PATH>\System\Apps\{app_unique_id}\Data
  1299. //U3_HOST_EXEC_PATH - %APPDATA%\U3\{device_serial_number}\{app_unique_id}\Exec
  1300. //U3_DEVICE_EXEC_PATH - <U3_DEVICE_PATH>\System\Apps\{app_unique_id}\Exec
  1301. switch(lPathID)
  1302. {
  1303. case PATH_HELP:
  1304. csDir += "Help\\";
  1305. break;
  1306. case PATH_LANGUAGE:
  1307. csDir += "language\\";
  1308. break;
  1309. case PATH_THEMES:
  1310. csDir += "Themes\\";
  1311. break;
  1312. case PATH_LOG_FILE:if(CGetSetOptions::GetIsPortableDitto() == false)
  1313. csDir = GetAppDataPath();
  1314. break;
  1315. case PATH_UPDATE_FILE:
  1316. //same path as the executable
  1317. break;
  1318. case PATH_DATABASE:
  1319. break;
  1320. case PATH_INI:
  1321. break;
  1322. case PATH_U3_HWND_INI:
  1323. break;
  1324. case PATH_ADDINS:
  1325. csDir += "Addins\\";
  1326. break;
  1327. case PATH_REMOTE_FILES:
  1328. if (CGetSetOptions::GetIsPortableDitto() == false)
  1329. {
  1330. csDir = GetTempFilePath();
  1331. }
  1332. csDir += "ReceivedFiles\\";
  1333. break;
  1334. case PATH_DRAG_FILES:
  1335. if (CGetSetOptions::GetIsPortableDitto() == false)
  1336. {
  1337. csDir = GetTempFilePath();
  1338. }
  1339. csDir += "DragFiles\\";
  1340. break;
  1341. case PATH_CLIP_DIFF:
  1342. if (CGetSetOptions::GetIsPortableDitto() == false)
  1343. {
  1344. csDir = GetTempFilePath();
  1345. }
  1346. csDir += _T("ClipCompare\\");
  1347. break;
  1348. }
  1349. CreateDirectory(csDir, NULL);
  1350. return csDir;
  1351. }
  1352. void CGetSetOptions::WriteU3Hwnd(HWND hWnd)
  1353. {
  1354. CString csIniFile = GetPath(PATH_U3_HWND_INI);
  1355. csIniFile += _T("DittohWnd.ini");
  1356. WritePrivateProfileInt(_T("Ditto"), _T("MainhWnd"), (int)hWnd, csIniFile);
  1357. }
  1358. long CGetSetOptions::GetDittoRestoreClipboardDelay()
  1359. {
  1360. return GetProfileLong("RestoreClipboardDelay", 750);
  1361. }
  1362. void CGetSetOptions::SetDittoRestoreClipboardDelay(long lDelay)
  1363. {
  1364. SetProfileLong("RestoreClipboardDelay", lDelay);
  1365. }
  1366. void CGetSetOptions::GetCopyBufferItem(int nPos, CCopyBufferItem &Item)
  1367. {
  1368. Item.m_lCopyHotKey = GetProfileLong(StrF(_T("CopyBufferCopyHotKey_%d"), nPos), 0);
  1369. Item.m_lPasteHotKey = GetProfileLong(StrF(_T("CopyBufferPasteHotKey_%d"), nPos), 0);
  1370. Item.m_lCutHotKey = GetProfileLong(StrF(_T("CopyBufferCutHotKey_%d"), nPos), 0);
  1371. Item.m_bPlaySoundOnCopy = GetProfileLong(StrF(_T("CopyBufferPlaySound_%d"), nPos), 0);
  1372. }
  1373. void CGetSetOptions::SetCopyBufferItem(int nPos, CCopyBufferItem &Item)
  1374. {
  1375. SetProfileLong(StrF(_T("CopyBufferCopyHotKey_%d"), nPos), Item.m_lCopyHotKey);
  1376. SetProfileLong(StrF(_T("CopyBufferPasteHotKey_%d"), nPos), Item.m_lPasteHotKey);
  1377. SetProfileLong(StrF(_T("CopyBufferCutHotKey_%d"), nPos), Item.m_lCutHotKey);
  1378. SetProfileLong(StrF(_T("CopyBufferPlaySound_%d"), nPos), Item.m_bPlaySoundOnCopy);
  1379. }
  1380. CString CGetSetOptions::GetMultiPasteSeparator(bool bConvertToLineFeeds)
  1381. {
  1382. CString csSep = GetProfileString(_T("MultiPasteSeparator"), _T("[LF]"));
  1383. if(bConvertToLineFeeds)
  1384. {
  1385. CString csLineFeed(_T("\r\n"));
  1386. csSep.Replace(_T("[LF]"), csLineFeed);
  1387. csSep.Replace(_T("[lf]"), csLineFeed);
  1388. }
  1389. return csSep;
  1390. }
  1391. void CGetSetOptions::SetMultiPasteSeparator(CString csSep)
  1392. {
  1393. SetProfileString(_T("MultiPasteSeparator"), csSep);
  1394. }
  1395. BOOL CGetSetOptions::GetSetCurrentDirectory()
  1396. {
  1397. if(m_portable)
  1398. {
  1399. CString csExePath = GetFilePath(GetExeFileName());
  1400. FIX_CSTRING_PATH(csExePath);
  1401. ::SetCurrentDirectory(csExePath);
  1402. }
  1403. return m_portable == true;
  1404. }
  1405. bool CGetSetOptions::GetIsPortableDitto()
  1406. {
  1407. return m_portable;
  1408. }
  1409. bool CGetSetOptions::GetIsWindowsApp()
  1410. {
  1411. return m_windowsApp;
  1412. }
  1413. CString CGetSetOptions::GetPasteString(CString csAppName)
  1414. {
  1415. CString csString = GetProfileString(csAppName, _T(""), _T("PasteStrings"));
  1416. if(csString.IsEmpty())
  1417. return GetDefaultPasteString();
  1418. return csString;
  1419. }
  1420. CString CGetSetOptions::GetDefaultPasteString()
  1421. {
  1422. //ascii value for v
  1423. //for other language keyboards v gets converted to something else so send the base ascii value
  1424. return GetProfileString(_T("DefaultPasteString"), _T("^{VKEY86}"));
  1425. }
  1426. CString CGetSetOptions::GetCopyString(CString csAppName)
  1427. {
  1428. CString csString = GetProfileString(csAppName, _T(""), _T("CopyStrings"));
  1429. if(csString.IsEmpty())
  1430. return GetDefaultCopyString();
  1431. return csString;
  1432. }
  1433. CString CGetSetOptions::GetDefaultCopyString()
  1434. {
  1435. //ascii value for c
  1436. //for other language keyboards c gets converted to something else so send the base ascii value
  1437. return GetProfileString(_T("DefaultCopyString"), _T("^{VKEY67}"));
  1438. }
  1439. CString CGetSetOptions::GetCutString(CString csAppName)
  1440. {
  1441. CString csString = GetProfileString(csAppName, _T(""), _T("CutStrings"));
  1442. if(csString.IsEmpty())
  1443. return GetDefaultCutString();
  1444. return csString;
  1445. }
  1446. CString CGetSetOptions::GetDefaultCutString()
  1447. {
  1448. //ascii value for x
  1449. //for other language keyboards x gets converted to something else so send the base ascii value
  1450. return GetProfileString(_T("DefaultCutString"), _T("^{VKEY88}"));
  1451. }
  1452. BOOL CGetSetOptions::GetEditWordWrap()
  1453. {
  1454. return GetProfileLong(_T("EditWordWrap"), TRUE);
  1455. }
  1456. void CGetSetOptions::SetEditWordWrap(BOOL bSet)
  1457. {
  1458. SetProfileLong(_T("EditWordWrap"), bSet);
  1459. }
  1460. bool CGetSetOptions::GetAllowFriends()
  1461. {
  1462. return (GetProfileLong("AllowFriends", TRUE) == TRUE);
  1463. }
  1464. long CGetSetOptions::GetAutoMaxDelay()
  1465. {
  1466. return GetProfileLong(_T("AutoMaxDelaySeconds"), 2);
  1467. }
  1468. void CGetSetOptions::SetAutoMaxDelay(long lDelay)
  1469. {
  1470. SetProfileLong(_T("AutoMaxDelaySeconds"), lDelay);
  1471. }
  1472. void CGetSetOptions::SetTheme(CString csTheme)
  1473. {
  1474. SetProfileString(_T("Theme"), csTheme);
  1475. }
  1476. CString CGetSetOptions::GetTheme()
  1477. {
  1478. return GetProfileString(_T("Theme"), "");
  1479. }
  1480. long CGetSetOptions::GetKeyStateWaitTimerCount()
  1481. {
  1482. return GetProfileLong(_T("KeyStateWaitTimerCount"), 20);
  1483. }
  1484. long CGetSetOptions::GetKeyStatePasteDelay()
  1485. {
  1486. return GetProfileLong(_T("KeyStatePasteDelay"), 200);
  1487. }
  1488. DWORD CGetSetOptions::GetDittoHotKey()
  1489. {
  1490. return (DWORD)GetProfileLong(_T("DittoHotKey"), 704);
  1491. }
  1492. DWORD CGetSetOptions::SendKeysDelay()
  1493. {
  1494. return (DWORD)GetProfileLong(_T("SendKeysDelay"), 50);
  1495. }
  1496. DWORD CGetSetOptions::WaitForActiveWndTimeout()
  1497. {
  1498. return (DWORD)GetProfileLong(_T("WaitForActiveWndTimeout"), 100);
  1499. }
  1500. DWORD CGetSetOptions::FocusChangedDelay()
  1501. {
  1502. return (DWORD)GetProfileLong(_T("FocusChangedDelay"), 100);
  1503. }
  1504. DWORD CGetSetOptions::FocusWndTimerTimeout()
  1505. {
  1506. return (DWORD)GetProfileLong(_T("FocusWndTimerTimeout"), 2000);
  1507. }
  1508. BOOL CGetSetOptions::GetConnectedToClipboard()
  1509. {
  1510. return GetProfileLong("ConnectedToClipboard", TRUE);
  1511. }
  1512. void CGetSetOptions::SetConnectedToClipboard(BOOL val)
  1513. {
  1514. SetProfileLong("ConnectedToClipboard", val);
  1515. }
  1516. DWORD CGetSetOptions::GetTextOnlyRestoreDelay()
  1517. {
  1518. return (DWORD)GetProfileLong(_T("TextOnlyRestoreDelay"), 2000);
  1519. }
  1520. DWORD CGetSetOptions::GetTextOnlyPasteDelay()
  1521. {
  1522. return (DWORD)GetProfileLong(_T("TextOnlyPasteDelay"), 0);
  1523. }
  1524. BOOL CGetSetOptions::GetSetFocusToApp(CString csAppName)
  1525. {
  1526. CString focusCheck;
  1527. focusCheck = "SetFocus_";
  1528. focusCheck += csAppName;
  1529. return GetProfileLong(focusCheck, FALSE);
  1530. }
  1531. DWORD CGetSetOptions::SelectedIndex()
  1532. {
  1533. return (DWORD)GetProfileLong(_T("SelectedIndex"), 0);
  1534. }
  1535. void CGetSetOptions::SetCopyAppInclude(CString csAppName)
  1536. {
  1537. SetProfileString(_T("CopyAppInclude"), csAppName);
  1538. }
  1539. CString CGetSetOptions::GetCopyAppInclude()
  1540. {
  1541. CString includeApp = GetProfileString(_T("CopyAppInclude"), "*");
  1542. if(includeApp == "")
  1543. {
  1544. includeApp = "*";
  1545. }
  1546. return includeApp;
  1547. }
  1548. void CGetSetOptions::SetCopyAppExclude(CString csAppName)
  1549. {
  1550. SetProfileString(_T("CopyAppExclude"), csAppName);
  1551. }
  1552. CString CGetSetOptions::GetCopyAppExclude()
  1553. {
  1554. return GetProfileString(_T("CopyAppExclude"), "");
  1555. }
  1556. CString CGetSetOptions::GetCopyAppSeparator()
  1557. {
  1558. return GetProfileString(_T("CopyAppSeparator"), ";");
  1559. }
  1560. DWORD CGetSetOptions::GetNoFormatsRetryDelay()
  1561. {
  1562. return GetProfileLong(_T("NoFormatsRetryDelay"), 200);
  1563. }
  1564. DWORD CGetSetOptions::GetMainDeletesDeleteCount()
  1565. {
  1566. return GetProfileLong(_T("MainDeletesDeleteCount"), 100);
  1567. }
  1568. DWORD CGetSetOptions::GetIdleSecondsBeforeDelete()
  1569. {
  1570. return GetProfileLong(_T("IdleSecondsBeforeDelete"), 60*10);
  1571. }
  1572. DWORD CGetSetOptions::GetDbTimeout()
  1573. {
  1574. return GetProfileLong(_T("DbTimeout"), 5000);
  1575. }
  1576. DWORD CGetSetOptions::GetFunnyTickCountAdjustment()
  1577. {
  1578. return GetProfileLong(_T("FunnyTickCountAdjustment"), 300001);
  1579. }
  1580. DWORD CGetSetOptions::GetMinIdleTimeBeforeTrackFocus()
  1581. {
  1582. return GetProfileLong(_T("MinIdleTimeBeforeTrackFocus"), 100);
  1583. }
  1584. DWORD CGetSetOptions::GetTimeBeforeExpandWindow()
  1585. {
  1586. return GetProfileLong(_T("TimeBeforeExpandWindow"), 250);
  1587. }
  1588. DWORD CGetSetOptions::GetUseGuiThreadInfoForFocus()
  1589. {
  1590. return GetProfileLong(_T("UseGuiThreadInfoForFocus"), 1);
  1591. }
  1592. void CGetSetOptions::SetSearchDescription(BOOL val)
  1593. {
  1594. SetProfileLong(_T("SearchDescription"), val);
  1595. }
  1596. BOOL CGetSetOptions::GetSearchDescription()
  1597. {
  1598. return GetProfileLong(_T("SearchDescription"), 1);
  1599. }
  1600. void CGetSetOptions::SetSearchFullText(BOOL val)
  1601. {
  1602. SetProfileLong(_T("SearchFullText"), val);
  1603. }
  1604. BOOL CGetSetOptions::GetSearchFullText()
  1605. {
  1606. return GetProfileLong(_T("SearchFullText"), 0);
  1607. }
  1608. void CGetSetOptions::SetSearchQuickPaste(BOOL val)
  1609. {
  1610. SetProfileLong(_T("SearchQuickPaste"), val);
  1611. }
  1612. BOOL CGetSetOptions::GetSearchQuickPaste()
  1613. {
  1614. return GetProfileLong(_T("SearchQuickPaste"), 0);
  1615. }
  1616. void CGetSetOptions::SetSimpleTextSearch(BOOL val)
  1617. {
  1618. SetProfileLong(_T("SimpleTextSearch"), val);
  1619. }
  1620. BOOL CGetSetOptions::GetSimpleTextSearch()
  1621. {
  1622. return GetProfileLong(_T("SimpleTextSearch"), 0);
  1623. }
  1624. void CGetSetOptions::SetRegExTextSearch(BOOL val)
  1625. {
  1626. SetProfileLong(_T("RegExTextSearch"), val);
  1627. }
  1628. BOOL CGetSetOptions::GetRegExTextSearch()
  1629. {
  1630. return GetProfileLong(_T("RegExTextSearch"), 0);
  1631. }
  1632. void CGetSetOptions::SetMoveClipsOnGlobal10(BOOL val)
  1633. {
  1634. SetProfileLong(_T("MoveClipsOnGlobal10"), val);
  1635. }
  1636. BOOL CGetSetOptions::GetMoveClipsOnGlobal10()
  1637. {
  1638. return GetProfileLong(_T("MoveClipsOnGlobal10"), 0);
  1639. }
  1640. void CGetSetOptions::SetShowScrollBar(BOOL val)
  1641. {
  1642. m_showScrollBar = val;
  1643. SetProfileLong(_T("ShowScrollBar"), val);
  1644. }
  1645. BOOL CGetSetOptions::GetShowScrollBar()
  1646. {
  1647. return GetProfileLong(_T("ShowScrollBar"), 0);
  1648. }
  1649. void CGetSetOptions::SetPasteAsAdmin(BOOL val)
  1650. {
  1651. SetProfileLong(_T("PasteAsAdmin"), val);
  1652. }
  1653. BOOL CGetSetOptions::GetPasteAsAdmin()
  1654. {
  1655. return GetProfileLong(_T("PasteAsAdmin"), 1);
  1656. }
  1657. void CGetSetOptions::SetRememberDescPos(BOOL val)
  1658. {
  1659. SetProfileLong(_T("RememberDescPos"), val);
  1660. }
  1661. BOOL CGetSetOptions::GetRememberDescPos()
  1662. {
  1663. return GetProfileLong(_T("RememberDescPos"), FALSE);
  1664. }
  1665. void CGetSetOptions::SetSizeDescWindowToContent(BOOL val)
  1666. {
  1667. SetProfileLong(_T("SizeDescWindowToContent"), val);
  1668. }
  1669. BOOL CGetSetOptions::GetSizeDescWindowToContent()
  1670. {
  1671. return GetProfileLong(_T("SizeDescWindowToContent"), TRUE);
  1672. }
  1673. void CGetSetOptions::SetScaleImagesToDescWindow(BOOL val)
  1674. {
  1675. SetProfileLong(_T("ScaleImagesToDescWindow"), val);
  1676. }
  1677. BOOL CGetSetOptions::GetScaleImagesToDescWindow()
  1678. {
  1679. return GetProfileLong(_T("ScaleImagesToDescWindow"), TRUE);
  1680. }
  1681. void CGetSetOptions::SetDescWndPoint(CPoint point)
  1682. {
  1683. SetResolutionProfileLong("DescWndX", point.x);
  1684. SetResolutionProfileLong("DescWndY", point.y);
  1685. }
  1686. void CGetSetOptions::GetDescWndPoint(CPoint &point)
  1687. {
  1688. point.x = GetResolutionProfileLong("DescWndX", 100);
  1689. point.y = GetResolutionProfileLong("DescWndY", 100);
  1690. }
  1691. void CGetSetOptions::GetDescWndSize(CSize &size)
  1692. {
  1693. size.cx = GetResolutionProfileLong("DescWndCX", 300);
  1694. size.cy = GetResolutionProfileLong("DescWndCY", 300);
  1695. if(size.cx <= 0 && size.cy <= 0)
  1696. {
  1697. size.cx = 300;
  1698. size.cy = 300;
  1699. }
  1700. }
  1701. void CGetSetOptions::SetDescWndSize(CSize size)
  1702. {
  1703. SetResolutionProfileLong("DescWndCX", size.cx);
  1704. SetResolutionProfileLong("DescWndCY", size.cy);
  1705. }
  1706. void CGetSetOptions::SetShowInTaskBar(BOOL val)
  1707. {
  1708. SetProfileLong(_T("ShowInTaskBar"), val);
  1709. }
  1710. BOOL CGetSetOptions::GetShowInTaskBar()
  1711. {
  1712. return GetProfileLong(_T("ShowInTaskBar"), FALSE);
  1713. }
  1714. void CGetSetOptions::SetDiffApp(CString val)
  1715. {
  1716. SetProfileString(_T("DiffApp"), val);
  1717. }
  1718. CString CGetSetOptions::GetDiffApp()
  1719. {
  1720. return GetProfileString(_T("DiffApp"), _T(""));
  1721. }
  1722. void CGetSetOptions::SetQRCodeBorderPixels(int val)
  1723. {
  1724. SetProfileLong(_T("QRCodeBorderPixels"), val);
  1725. }
  1726. int CGetSetOptions::GetQRCodeBorderPixels()
  1727. {
  1728. return GetProfileLong(_T("QRCodeBorderPixels"), 30);
  1729. }
  1730. CString CGetSetOptions::GetTranslateUrl()
  1731. {
  1732. return GetProfileString(_T("TranslateUrl"), _T("https://translate.google.com/?tl=en#auto/en/%s"));
  1733. }
  1734. void CGetSetOptions::SetNetworkReadTimeoutMS(int val)
  1735. {
  1736. SetProfileLong(_T("NetworkReadTimeoutMS"), val);
  1737. }
  1738. int CGetSetOptions::GetNetworkReadTimeoutMS()
  1739. {
  1740. return GetProfileLong(_T("NetworkReadTimeoutMS"), 30000);
  1741. }
  1742. void CGetSetOptions::SetRequestFilesUsingIP(int val)
  1743. {
  1744. SetProfileLong(_T("RequestFilesUsingIP"), val);
  1745. }
  1746. int CGetSetOptions::GetRequestFilesUsingIP()
  1747. {
  1748. return GetProfileLong(_T("RequestFilesUsingIP"), 0);
  1749. }
  1750. int CGetSetOptions::ReadRandomFileInterval()
  1751. {
  1752. return GetProfileLong(_T("ReadRandomFileInterval"), 60);
  1753. }
  1754. int CGetSetOptions::ReadRandomFileIdleMin()
  1755. {
  1756. return GetProfileLong(_T("ReadRandomFileIdleMin"), 30);
  1757. }
  1758. BOOL CGetSetOptions::GetShowGroupsInMainList()
  1759. {
  1760. return GetProfileLong(_T("ShowGroupsInMainList"), 0);
  1761. }
  1762. void CGetSetOptions::SetShowGroupsInMainList(BOOL val)
  1763. {
  1764. SetProfileLong(_T("ShowGroupsInMainList"), val);
  1765. }
  1766. void CGetSetOptions::SetGroupDoubleClickTimeMS(int val)
  1767. {
  1768. SetProfileLong(_T("GroupDoubleClickTimeMS"), val);
  1769. }
  1770. int CGetSetOptions::GetGroupDoubleClickTimeMS()
  1771. {
  1772. return GetProfileLong(_T("GroupDoubleClickTimeMS"), 500);
  1773. }
  1774. void CGetSetOptions::SetSaveToGroupTimeoutMS(int val)
  1775. {
  1776. SetProfileLong(_T("SaveToGroupTimeoutMS"), val);
  1777. }
  1778. int CGetSetOptions::GetSaveToGroupTimeoutMS()
  1779. {
  1780. return GetProfileLong(_T("SaveToGroupTimeoutMS"), 1000);
  1781. }
  1782. void CGetSetOptions::SetCopyReasonTimeoutMS(int val)
  1783. {
  1784. SetProfileLong(_T("CopyReasonTimeoutMS"), val);
  1785. }
  1786. int CGetSetOptions::GetCopyReasonTimeoutMS()
  1787. {
  1788. return GetProfileLong(_T("CopyReasonTimeoutMS"), 1000);
  1789. }
  1790. void CGetSetOptions::SetWindowsResumeDelayReOpenDbMS(int val)
  1791. {
  1792. SetProfileLong(_T("WindowsResumeDelayReOpenDbMS"), val);
  1793. }
  1794. int CGetSetOptions::GetWindowsResumeDelayReOpenDbMS()
  1795. {
  1796. return GetProfileLong(_T("WindowsResumeDelayReOpenDbMS"), 2000);
  1797. }
  1798. BOOL CGetSetOptions::GetShowMsgWndOnCopyToGroup()
  1799. {
  1800. return GetProfileLong(_T("ShowMsgWndOnCopyToGroup"), TRUE);
  1801. }
  1802. void CGetSetOptions::SetShowMsgWndOnCopyToGroup(BOOL val)
  1803. {
  1804. SetProfileLong(_T("ShowMsgWndOnCopyToGroup"), val);
  1805. }
  1806. int CGetSetOptions::GetActionShortCutA(DWORD action, int pos)
  1807. {
  1808. CString actionText;
  1809. actionText.Format(_T("QP_ShortCut_%d_%d_A"), action, pos);
  1810. int ret = GetProfileLong(actionText, -1);
  1811. if (ret == -1)
  1812. {
  1813. ret = ActionEnums::GetDefaultShortCutKeyA((ActionEnums::ActionEnumValues)action, pos);
  1814. }
  1815. return ret;
  1816. }
  1817. void CGetSetOptions::SetActionShortCutA(int action, DWORD shortcut, int pos)
  1818. {
  1819. CString actionText;
  1820. actionText.Format(_T("QP_ShortCut_%d_%d_A"), action, pos);
  1821. SetProfileLong(actionText, shortcut);
  1822. }
  1823. int CGetSetOptions::GetActionShortCutB(DWORD action, int pos)
  1824. {
  1825. CString actionText;
  1826. actionText.Format(_T("QP_ShortCut_%d_%d_B"), action, pos);
  1827. int ret = GetProfileLong(actionText, -1);
  1828. if (ret == -1)
  1829. {
  1830. ret = ActionEnums::GetDefaultShortCutKeyB((ActionEnums::ActionEnumValues)action, pos);
  1831. }
  1832. return ret;
  1833. }
  1834. void CGetSetOptions::SetActionShortCutB(int action, DWORD shortcut, int pos)
  1835. {
  1836. CString actionText;
  1837. actionText.Format(_T("QP_ShortCut_%d_%d_B"), action, pos);
  1838. SetProfileLong(actionText, shortcut);
  1839. }
  1840. BOOL CGetSetOptions::GetShowAlwaysOnTopWarning()
  1841. {
  1842. return GetProfileLong(_T("ShowAlwaysOnTopWarning"), TRUE);
  1843. }
  1844. void CGetSetOptions::SetShowAlwaysOnTopWarning(BOOL show)
  1845. {
  1846. m_bShowAlwaysOnTopWarning = show;
  1847. SetProfileLong(_T("ShowAlwaysOnTopWarning"), show);
  1848. }
  1849. BOOL CGetSetOptions::GetUseIPFromAccept()
  1850. {
  1851. return GetProfileLong(_T("UseIPFromAccept"), TRUE);
  1852. }
  1853. void CGetSetOptions::SetUseIPFromAccept(BOOL useAccept)
  1854. {
  1855. SetProfileLong(_T("UseIPFromAccept"), useAccept);
  1856. }
  1857. int CGetSetOptions::GetDragId()
  1858. {
  1859. return GetProfileLong(_T("DragId"), 1);
  1860. }
  1861. void CGetSetOptions::SetDragId(int id)
  1862. {
  1863. SetProfileLong(_T("DragId"), id);
  1864. }
  1865. BOOL CGetSetOptions::GetShowIfClipWasPasted()
  1866. {
  1867. return GetProfileLong(_T("ShowIfClipWasPasted"), TRUE);
  1868. }
  1869. void CGetSetOptions::SetShowIfClipWasPasted(BOOL val)
  1870. {
  1871. SetProfileLong(_T("ShowIfClipWasPasted"), val);
  1872. }
  1873. int CGetSetOptions::GetLastGroupToggle()
  1874. {
  1875. return GetProfileLong(_T("LastGroupToggle"), -2);
  1876. }
  1877. void CGetSetOptions::SetLastGroupToggle(int val)
  1878. {
  1879. SetProfileLong(_T("LastGroupToggle"), val);
  1880. }
  1881. BOOL CGetSetOptions::GetMouseClickHidesDescription()
  1882. {
  1883. return GetProfileLong(_T("MouseClickHidesDescription"), TRUE);
  1884. }
  1885. void CGetSetOptions::SetMouseClickHidesDescription(int val)
  1886. {
  1887. SetProfileLong(_T("MouseClickHidesDescription"), val);
  1888. }
  1889. BOOL CGetSetOptions::GetWrapDescriptionText()
  1890. {
  1891. return GetProfileLong(_T("WrapDescriptionText"), FALSE);
  1892. }
  1893. void CGetSetOptions::SetWrapDescriptionText(int val)
  1894. {
  1895. SetProfileLong(_T("WrapDescriptionText"), val);
  1896. }