From ab554ae9399ed8243a7840f14410ca63aa71b8e6 Mon Sep 17 00:00:00 2001 From: anders_k Date: Mon, 27 Jul 2015 18:24:45 +0000 Subject: [PATCH] Use the system link color on our custom link controls git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6589 212acab6-be3b-0410-9dea-997c60f758d6 --- Contrib/InstallOptions/InstallerOptions.cpp | 15 +++++++++++++-- Contrib/nsDialogs/nsDialogs.c | 15 +++++++++++++-- Docs/src/history.but | 2 ++ Source/Platform.h | 3 +++ 4 files changed, 31 insertions(+), 4 deletions(-) diff --git a/Contrib/InstallOptions/InstallerOptions.cpp b/Contrib/InstallOptions/InstallerOptions.cpp index 799a01c0..7534b057 100644 --- a/Contrib/InstallOptions/InstallerOptions.cpp +++ b/Contrib/InstallOptions/InstallerOptions.cpp @@ -209,6 +209,17 @@ void WINAPI mySetWindowText(HWND hWnd, LPCTSTR pszText) SetWindowText(hWnd, pszText); } +static COLORREF GetLinkColor() +{ + COLORREF clr = GetSysColor(COLOR_HOTLIGHT); +#ifndef _WIN64 + // COLOR_HOTLIGHT is Win98/2000+. GetSysColorBrush is the correct way to + // detect valid colors but here we just assume nobody uses black. + if (!clr) clr = RGB(0,0,255); +#endif + return clr; +} + int CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lp, LPARAM pData) { static TCHAR szDir[MAX_PATH]; @@ -552,8 +563,8 @@ int WINAPI ReadSettings(void) { pField->nMinLength = myGetProfileInt(_T("MinLen"), 0); pField->nMaxLength = myGetProfileInt(_T("MaxLen"), 0); - // Text color for LINK control, default is pure blue - pField->hImage = (HANDLE)myGetProfileInt(_T("TxtColor"), RGB(0,0,255)); + // Text color for LINK control, default is the system default link color + pField->hImage = (HANDLE)myGetProfileInt(_T("TxtColor"), GetLinkColor()); pField->nControlID = 1200 + nIdx; if (pField->nType == FIELD_FILEREQUEST || pField->nType == FIELD_DIRREQUEST) diff --git a/Contrib/nsDialogs/nsDialogs.c b/Contrib/nsDialogs/nsDialogs.c index 39a70a9b..7ed84d57 100644 --- a/Contrib/nsDialogs/nsDialogs.c +++ b/Contrib/nsDialogs/nsDialogs.c @@ -20,6 +20,17 @@ HINSTANCE g_hInstance; struct nsDialog g_dialog; extra_parameters* g_pluginParms; +static COLORREF GetLinkColor() +{ + COLORREF clr = GetSysColor(COLOR_HOTLIGHT); +#ifndef _WIN64 + // COLOR_HOTLIGHT is Win98/2000+. GetSysColorBrush is the correct way to + // detect valid colors but here we just assume nobody uses black. + if (!clr) clr = RGB(0,0,255); +#endif + return clr; +} + struct nsControl* NSDFUNC GetControl(HWND hwCtl) { unsigned id = (unsigned) GetProp(hwCtl, NSCONTROL_ID_PROP); @@ -195,9 +206,9 @@ INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara if (hideAccel) xtraDrawStyle |= DT_HIDEPREFIX; - // Use blue unless the user has set another using SetCtlColors + // Use the system color unless the user has set another using SetCtlColors if (!GetWindowLongPtr(lpdis->hwndItem, GWLP_USERDATA)) - SetTextColor(lpdis->hDC, RGB(0,0,255)); + SetTextColor(lpdis->hDC, GetLinkColor()); // Draw the text DrawText(lpdis->hDC, text, -1, &rc, xtraDrawStyle | DT_CENTER | DT_VCENTER | DT_WORDBREAK); diff --git a/Docs/src/history.but b/Docs/src/history.but index e1b0322f..b728089d 100644 --- a/Docs/src/history.but +++ b/Docs/src/history.but @@ -24,6 +24,8 @@ Released on ?, 201? \b Fixed CreateShortcut /NoWorkingDir parsing bug (\W{http://sf.net/p/nsis/bugs/1110/}{bug #1110}) +\b nsDialogs and InstallOptions now use the system link color + \H{v3.0b1} 3.0 Beta 1 Released on October 6th, 2014 diff --git a/Source/Platform.h b/Source/Platform.h index 6ee1a2c1..a6d1df23 100644 --- a/Source/Platform.h +++ b/Source/Platform.h @@ -510,6 +510,9 @@ typedef DWORDLONG ULONGLONG,*PULONGLONG; #ifndef COLOR_WINDOW # define COLOR_WINDOW 5 #endif +#ifndef COLOR_HOTLIGHT +# define COLOR_HOTLIGHT 26 +#endif // resources