Options.cpp 49 KB

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