diff --git a/Contrib/nsDialogs/defs.h b/Contrib/nsDialogs/defs.h index e322644d..306fa7f9 100644 --- a/Contrib/nsDialogs/defs.h +++ b/Contrib/nsDialogs/defs.h @@ -17,6 +17,7 @@ enum nsControlType NSCTL_RICHEDIT, NSCTL_RICHEDIT2, NSCTL_STATIC, + NSCTL_LINK, NSCTL_TREE }; @@ -44,6 +45,7 @@ struct nsControl enum nsControlType type; char userData[USERDATA_SIZE]; struct nsControlCallbacks callbacks; + WNDPROC oldWndProc; }; struct nsDialog diff --git a/Contrib/nsDialogs/nsDialogs.c b/Contrib/nsDialogs/nsDialogs.c index 17c5ccf2..9c68dd59 100644 --- a/Contrib/nsDialogs/nsDialogs.c +++ b/Contrib/nsDialogs/nsDialogs.c @@ -57,6 +57,22 @@ BOOL CALLBACK ParentProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) 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) { switch (uMsg) @@ -70,7 +86,7 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) if (ctl == NULL) 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) { @@ -82,34 +98,34 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { if (ctl->callbacks.onChange) { - pushint((int) hwCtl); - g_pluginParms->ExecuteCodeSegment(ctl->callbacks.onChange - 1, 0); - } + pushint((int) hwCtl); + g_pluginParms->ExecuteCodeSegment(ctl->callbacks.onChange - 1, 0); + } } else if (HIWORD(wParam) == LBN_SELCHANGE && ctl->type == NSCTL_LISTBOX) { if (ctl->callbacks.onChange) { - pushint((int) hwCtl); - g_pluginParms->ExecuteCodeSegment(ctl->callbacks.onChange - 1, 0); - } + pushint((int) hwCtl); + g_pluginParms->ExecuteCodeSegment(ctl->callbacks.onChange - 1, 0); + } } else if ((HIWORD(wParam) == CBN_EDITUPDATE || HIWORD(wParam) == CBN_SELCHANGE) && ctl->type == NSCTL_COMBOBOX) { if (ctl->callbacks.onChange) { - pushint((int) hwCtl); - g_pluginParms->ExecuteCodeSegment(ctl->callbacks.onChange - 1, 0); - } + pushint((int) hwCtl); + g_pluginParms->ExecuteCodeSegment(ctl->callbacks.onChange - 1, 0); + } } else if (HIWORD(wParam) == STN_CLICKED && ctl->type == NSCTL_STATIC) { if (ctl->callbacks.onClick) { - pushint((int) hwCtl); - g_pluginParms->ExecuteCodeSegment(ctl->callbacks.onClick - 1, 0); - } + pushint((int) hwCtl); + g_pluginParms->ExecuteCodeSegment(ctl->callbacks.onClick - 1, 0); + } } break; @@ -315,6 +331,8 @@ void __declspec(dllexport) CreateControl(HWND hwndParent, int string_size, char g_dialog.controls[id].type = NSCTL_RICHEDIT2; else if (!lstrcmpi(className, "STATIC")) g_dialog.controls[id].type = NSCTL_STATIC; + else if (!lstrcmpi(className, "LINK")) + g_dialog.controls[id].type = NSCTL_LINK; else g_dialog.controls[id].type = NSCTL_UNKNOWN; @@ -326,7 +344,7 @@ void __declspec(dllexport) CreateControl(HWND hwndParent, int string_size, char hwItem = CreateWindowEx( exStyle, - className, + lstrcmpi(className, "LINK") ? className : "BUTTON", text, style, 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); + // 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 pushint((int) hwItem); diff --git a/Contrib/nsDialogs/nsDialogs.nsh b/Contrib/nsDialogs/nsDialogs.nsh index 62315e87..6902836c 100644 --- a/Contrib/nsDialogs/nsDialogs.nsh +++ b/Contrib/nsDialogs/nsDialogs.nsh @@ -200,7 +200,7 @@ Header file for creating custom installer pages with nsDialogs !define __NSD_BrowseButton_STYLE ${DEFAULT_STYLES}|${WS_TABSTOP} !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_EXSTYLE 0 diff --git a/Contrib/nsDialogs/rtl.c b/Contrib/nsDialogs/rtl.c index a2474289..e1a30dfb 100644 --- a/Contrib/nsDialogs/rtl.c +++ b/Contrib/nsDialogs/rtl.c @@ -34,6 +34,7 @@ void NSDFUNC ConvertStyleToRTL(enum nsControlType type, LPDWORD style, LPDWORD e switch (type) { + case NSCTL_LINK: case NSCTL_BUTTON: *style ^= BS_LEFTTEXT | BS_RIGHT | BS_LEFT;