Options.cpp 46 KB

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