Options.cpp 55 KB

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