Skip to content
⌘ NSIS Forum Archive

nsDialogs and control Z-order

7 posts

CrushBug#

nsDialogs and control Z-order

Greetings. I am trying to add an "Installation Help" link on the MUI 2 Welcome page.

The first problem I had was the Link not showing up as blue and underlined. I fixed that and got the link appearing and functioning with the following code:

Function PageFunction_WelcomeShow
;modify the MUI2 Welcome page to include an installation help link
    ;create the installation help link
    ${NSD_CreateLink} 120u 183u 135u 14u "$(Page_Welcome_Link)"
    ; pop the label HWND off of the stack
    Pop $Link_InstallHelp
    ;welcome page fonts/colors are different from other pages, so force the help link to Blue and the current MUI background color
    SetCtlColors $Link_InstallHelp "0x000080" "${MUI_BGCOLOR}"
    ;font should be Blue now, but it won't be underlined, so we need to fix it.
    CreateFont $Link_InstallHelp_font "$(^Font)" "$(^FontSize)" /UNDERLINE
    SendMessage $Link_InstallHelp ${WM_SETFONT} $Link_InstallHelp_font 0
    GetFunctionAddress $R0 PageFunction_Welcome_LinkClick
    nsDialogs::OnClick $Link_InstallHelp $R0
FunctionEnd ;PageFunction_WelcomeShow 
The only problem I have is that it seems that the MUI Welcome label control extends down and slightly overlaps the link control that I have created.

In other programming languages, I can use a .SendToFront command on a control to fix this, but after much searching and source code dumpster-diving, I haven't been able to figure it out in NSIS and MUI and nsDialogs.

How does one send a control to the front on the MUI2 Welcome page via nsDialogs or with SendMessage? Is there some other solution I can use?
MSG#
Re: nsDialogs and control Z-order

How does one send a control to the front on the MUI2 Welcome page via nsDialogs or with SendMessage? Is there some other solution I can use?
You can call any API command by calling the appropriate DLL function through the system plugin. But it is generally a bad idea to mess with window order, you're much better off calling the getwindowrect and setwindowpos functions to decrease the label size.
CrushBug#
Thanks for the reply. I will see what I can pull off with that.

I still wish there was a SendToFront thing I could pull off, because I know it would solve the problem.
CrushBug#
I have tried this, but I can still see that the top of my Link text is being cut off
Function PageFunction_WelcomeShow
;modify the MUI2 Welcome page to include an installation help link
    ;create the installation help link
    ${NSD_CreateLink} 120u 183u 135u 14u "$(Page_Welcome_Link)"
    ; pop the label HWND off of the stack
    Pop $Link_InstallHelp
    ;welcome page fonts/colors are different from other pages, so force the help link to Blue and the current MUI background color
    SetCtlColors $Link_InstallHelp "0x000080" "${MUI_BGCOLOR}"
    ;font should be Blue now, but it won't be underlined, so we need to fix it.
    CreateFont $Link_InstallHelp_font "$(^Font)" "$(^FontSize)" /UNDERLINE
    SendMessage $Link_InstallHelp ${WM_SETFONT} $Link_InstallHelp_font 0
    ;HACK! - try to set the Link control to the top
!define SWP_NOSIZE 0x0001
!define SWP_NOMOVE 0x0002
!define HWND_TOPMOST -1
    System::Call "User32::SetWindowPos(i, i, i, i, i, i, i) b ($Link_InstallHelp, ${HWND_TOPMOST}, 0, 0, 0, 0, ${SWP_NOSIZE}|${SWP_NOMOVE})"
    GetFunctionAddress $R0 PageFunction_Welcome_LinkClick
    nsDialogs::OnClick $Link_InstallHelp $R0
FunctionEnd ;PageFunction_WelcomeShow 
I have also tried replacing ${SWP_NOSIZE}|${SWP_NOMOVE} with 3 and it still shows as cut off.

I must still be missing something. I will try again later this afternoon.
CrushBug#
Thank you so much Anders; that was it. Here is the final working code. Maybe, once the project is shipped I will write this up for the wiki
Function PageFunction_WelcomeShow
;modify the MUI2 Welcome page to include an installation help link
    ;create the installation help link
    ${NSD_CreateLink} 120u 182u 135u 14u "$(Page_Welcome_Link)"
    ; pop the label HWND off of the stack
    Pop $Link_InstallHelp
    ;welcome page fonts/colors are different from other pages, so force the help link to Blue and the current MUI background color
    SetCtlColors $Link_InstallHelp "0x000080" "${MUI_BGCOLOR}"
    ;font should be Blue now, but it won't be underlined, so we need to fix it.
    CreateFont $Link_InstallHelp_font "$(^Font)" "$(^FontSize)" /UNDERLINE
    SendMessage $Link_InstallHelp ${WM_SETFONT} $Link_InstallHelp_font 0
    ;move these defines to someplace better in your code
!define SWP_NOSIZE 0x0001
!define SWP_NOMOVE 0x0002
!define HWND_TOP 0x0000
    ;set the Link control on top of the Welcome label text
    System::Call "User32::SetWindowPos(i, i, i, i, i, i, i) b ($Link_InstallHelp, ${HWND_TOP}, 0, 0, 0, 0, ${SWP_NOSIZE}|${SWP_NOMOVE})"
    GetFunctionAddress $R0 PageFunction_Welcome_LinkClick
    nsDialogs::OnClick $Link_InstallHelp $R0
FunctionEnd ;PageFunction_WelcomeShow