From ae3e2cff8911b71ef184ff4fb0ef0fb4000b8b88 Mon Sep 17 00:00:00 2001 From: kichik Date: Fri, 18 Jan 2008 13:45:25 +0000 Subject: [PATCH] applied patch #1871856 - nsDialogs: support for keyboard cues for link control git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@5482 212acab6-be3b-0410-9dea-997c60f758d6 --- Contrib/nsDialogs/nsDialogs.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/Contrib/nsDialogs/nsDialogs.c b/Contrib/nsDialogs/nsDialogs.c index daf22b73..635f1e78 100644 --- a/Contrib/nsDialogs/nsDialogs.c +++ b/Contrib/nsDialogs/nsDialogs.c @@ -5,6 +5,14 @@ #include "input.h" #include "rtl.h" +#ifndef ODS_NOACCEL +#define ODS_NOACCEL 0x0100 +#define ODS_NOFOCUSRECT 0x0200 +#endif +#ifndef DT_HIDEPREFIX +#define DT_HIDEPREFIX 0x00100000 +#endif + HINSTANCE g_hInstance; struct nsDialog g_dialog; extra_parameters* g_pluginParms; @@ -115,6 +123,13 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) RECT rc; char text[1024]; + // http://blogs.msdn.com/oldnewthing/archive/2005/05/03/414317.aspx#414357 + // says we should call SystemParametersInfo(SPI_GETKEYBOARDCUES,...) to make + // sure, does not seem to be required, might be a win2k bug, or it might + // only apply to menus + BOOL hideFocus = (lpdis->itemState & ODS_NOFOCUSRECT); + BOOL hideAccel = (lpdis->itemState & ODS_NOACCEL); + struct nsControl* ctl = GetControl(lpdis->hwndItem); if (ctl == NULL) break; @@ -141,20 +156,23 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) if (lpdis->itemAction & ODA_DRAWENTIRE) { + DWORD xtraDrawStyle = (g_dialog.rtl ? DT_RTLREADING : 0); + if (hideAccel) + xtraDrawStyle |= DT_HIDEPREFIX; + // Get TxtColor unless the user has set another using SetCtlColors if (!GetWindowLong(lpdis->hwndItem, GWL_USERDATA)) SetTextColor(lpdis->hDC, RGB(0,0,255)); // Draw the text - DrawText(lpdis->hDC, text, -1, &rc, DT_CENTER | DT_VCENTER | DT_WORDBREAK | (g_dialog.rtl ? DT_RTLREADING : 0)); + DrawText(lpdis->hDC, text, -1, &rc, xtraDrawStyle | DT_CENTER | DT_VCENTER | DT_WORDBREAK); } // Draw the focus rect if needed if (((lpdis->itemState & ODS_FOCUS) && (lpdis->itemAction & ODA_DRAWENTIRE)) || (lpdis->itemAction & ODA_FOCUS)) { - // NB: when not in DRAWENTIRE mode, this will actually toggle the focus - // rectangle since it's drawn in a XOR way - DrawFocusRect(lpdis->hDC, &rc); + if (!hideFocus) + DrawFocusRect(lpdis->hDC, &rc); } return TRUE;