applied patch #2004129 - nsDialogs: Hand cursor for link

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@5698 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
kichik 2008-08-15 17:36:36 +00:00
parent ff40110eba
commit aed07bb8d3
4 changed files with 41 additions and 15 deletions

View file

@ -17,6 +17,7 @@ enum nsControlType
NSCTL_RICHEDIT, NSCTL_RICHEDIT,
NSCTL_RICHEDIT2, NSCTL_RICHEDIT2,
NSCTL_STATIC, NSCTL_STATIC,
NSCTL_LINK,
NSCTL_TREE NSCTL_TREE
}; };
@ -44,6 +45,7 @@ struct nsControl
enum nsControlType type; enum nsControlType type;
char userData[USERDATA_SIZE]; char userData[USERDATA_SIZE];
struct nsControlCallbacks callbacks; struct nsControlCallbacks callbacks;
WNDPROC oldWndProc;
}; };
struct nsDialog struct nsDialog

View file

@ -57,6 +57,22 @@ BOOL CALLBACK ParentProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
return res; return res;
} }
LRESULT CALLBACK LinkWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
struct nsControl* ctl = GetControl(hwnd);
if(ctl == NULL)
return 0;
if(message == WM_SETCURSOR)
{
SetCursor(LoadCursor(NULL, IDC_HAND));
return TRUE;
}
return CallWindowProc(ctl->oldWndProc, hwnd, message, wParam, lParam);
}
BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{ {
switch (uMsg) switch (uMsg)
@ -70,7 +86,7 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
if (ctl == NULL) if (ctl == NULL)
break; break;
if (HIWORD(wParam) == BN_CLICKED && ctl->type == NSCTL_BUTTON) if (HIWORD(wParam) == BN_CLICKED && (ctl->type == NSCTL_BUTTON || ctl->type == NSCTL_LINK))
{ {
if (ctl->callbacks.onClick) if (ctl->callbacks.onClick)
{ {
@ -82,34 +98,34 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{ {
if (ctl->callbacks.onChange) if (ctl->callbacks.onChange)
{ {
pushint((int) hwCtl); pushint((int) hwCtl);
g_pluginParms->ExecuteCodeSegment(ctl->callbacks.onChange - 1, 0); g_pluginParms->ExecuteCodeSegment(ctl->callbacks.onChange - 1, 0);
} }
} }
else if (HIWORD(wParam) == LBN_SELCHANGE && ctl->type == NSCTL_LISTBOX) else if (HIWORD(wParam) == LBN_SELCHANGE && ctl->type == NSCTL_LISTBOX)
{ {
if (ctl->callbacks.onChange) if (ctl->callbacks.onChange)
{ {
pushint((int) hwCtl); pushint((int) hwCtl);
g_pluginParms->ExecuteCodeSegment(ctl->callbacks.onChange - 1, 0); g_pluginParms->ExecuteCodeSegment(ctl->callbacks.onChange - 1, 0);
} }
} }
else if ((HIWORD(wParam) == CBN_EDITUPDATE || HIWORD(wParam) == CBN_SELCHANGE) else if ((HIWORD(wParam) == CBN_EDITUPDATE || HIWORD(wParam) == CBN_SELCHANGE)
&& ctl->type == NSCTL_COMBOBOX) && ctl->type == NSCTL_COMBOBOX)
{ {
if (ctl->callbacks.onChange) if (ctl->callbacks.onChange)
{ {
pushint((int) hwCtl); pushint((int) hwCtl);
g_pluginParms->ExecuteCodeSegment(ctl->callbacks.onChange - 1, 0); g_pluginParms->ExecuteCodeSegment(ctl->callbacks.onChange - 1, 0);
} }
} }
else if (HIWORD(wParam) == STN_CLICKED && ctl->type == NSCTL_STATIC) else if (HIWORD(wParam) == STN_CLICKED && ctl->type == NSCTL_STATIC)
{ {
if (ctl->callbacks.onClick) if (ctl->callbacks.onClick)
{ {
pushint((int) hwCtl); pushint((int) hwCtl);
g_pluginParms->ExecuteCodeSegment(ctl->callbacks.onClick - 1, 0); g_pluginParms->ExecuteCodeSegment(ctl->callbacks.onClick - 1, 0);
} }
} }
break; break;
@ -315,6 +331,8 @@ void __declspec(dllexport) CreateControl(HWND hwndParent, int string_size, char
g_dialog.controls[id].type = NSCTL_RICHEDIT2; g_dialog.controls[id].type = NSCTL_RICHEDIT2;
else if (!lstrcmpi(className, "STATIC")) else if (!lstrcmpi(className, "STATIC"))
g_dialog.controls[id].type = NSCTL_STATIC; g_dialog.controls[id].type = NSCTL_STATIC;
else if (!lstrcmpi(className, "LINK"))
g_dialog.controls[id].type = NSCTL_LINK;
else else
g_dialog.controls[id].type = NSCTL_UNKNOWN; g_dialog.controls[id].type = NSCTL_UNKNOWN;
@ -326,7 +344,7 @@ void __declspec(dllexport) CreateControl(HWND hwndParent, int string_size, char
hwItem = CreateWindowEx( hwItem = CreateWindowEx(
exStyle, exStyle,
className, lstrcmpi(className, "LINK") ? className : "BUTTON",
text, text,
style, style,
x, y, width, height, x, y, width, height,
@ -345,6 +363,11 @@ void __declspec(dllexport) CreateControl(HWND hwndParent, int string_size, char
SendMessage(hwItem, WM_SETFONT, SendMessage(g_dialog.hwParent, WM_GETFONT, 0, 0), TRUE); SendMessage(hwItem, WM_SETFONT, SendMessage(g_dialog.hwParent, WM_GETFONT, 0, 0), TRUE);
// set the WndProc for the link control
if(g_dialog.controls[id].type == NSCTL_LINK)
g_dialog.controls[id].oldWndProc = (WNDPROC) SetWindowLong(hwItem, GWL_WNDPROC, (long) LinkWndProc);
// push back result // push back result
pushint((int) hwItem); pushint((int) hwItem);

View file

@ -200,7 +200,7 @@ Header file for creating custom installer pages with nsDialogs
!define __NSD_BrowseButton_STYLE ${DEFAULT_STYLES}|${WS_TABSTOP} !define __NSD_BrowseButton_STYLE ${DEFAULT_STYLES}|${WS_TABSTOP}
!define __NSD_BrowseButton_EXSTYLE 0 !define __NSD_BrowseButton_EXSTYLE 0
!define __NSD_Link_CLASS BUTTON !define __NSD_Link_CLASS LINK
!define __NSD_Link_STYLE ${DEFAULT_STYLES}|${WS_TABSTOP}|${BS_OWNERDRAW} !define __NSD_Link_STYLE ${DEFAULT_STYLES}|${WS_TABSTOP}|${BS_OWNERDRAW}
!define __NSD_Link_EXSTYLE 0 !define __NSD_Link_EXSTYLE 0

View file

@ -34,6 +34,7 @@ void NSDFUNC ConvertStyleToRTL(enum nsControlType type, LPDWORD style, LPDWORD e
switch (type) switch (type)
{ {
case NSCTL_LINK:
case NSCTL_BUTTON: case NSCTL_BUTTON:
*style ^= BS_LEFTTEXT | BS_RIGHT | BS_LEFT; *style ^= BS_LEFTTEXT | BS_RIGHT | BS_LEFT;