reza khademi
reza khademi

Reputation: 5

Issue with Changing Form Size in NSIS: Part of the Form Not Rendering on Smaller Displays

I am developing an installer using NSIS (Nullsoft Scriptable Install System) and encountering an issue. My goal is to change the size of the form in my application, but when the form size exceeds the user's screen resolution, part of the form does not render correctly.

Problem:

When I use the SetWindowPos function to change the size of the form, if the form size is larger than the screen resolution, it seems that parts of the form outside the screen area are not being rendered at all.

For example, if the user's screen resolution is set to 800x600, after using the provided code, the form does not resize to 900x800 as intended. Instead, 100 pixels are not rendered from one side and 200 pixels from the other side of the form.

Code:

Here is the NSIS code I am using:

System::Call 'user32::SetWindowPos(i$HWNDPARENT,i,i,i,i 900,i 800,i 0x16)'
System::Call 'user32::SetWindowLong(i $HWNDPARENT,i -16,i 339871820)'

Issue I Am Facing:

1-Part of the Form Not Rendering: When I set the form size to be larger than the screen resolution, it appears that parts of the form outside the display area are not being rendered at all.

2-Size and Position Settings: Even though I am using SetWindowPos and ensuring that the parameters are set correctly, the issue persists.

Question:

Is there a solution to ensure that all parts of the form, even those outside the visible screen area, are rendered correctly? Should I change any specific settings or parameters in NSIS to address this issue?

Upvotes: 0

Views: 68

Answers (1)

reza khademi
reza khademi

Reputation: 5

After further investigation, I managed to solve the issue, but I am not sure if it is the definitive and correct solution or not.

All default styles of the NSIS form have a code equal to -1798698932. If the style named {WS_POPUPWINDOW} is removed, the final code becomes 339871820. In the previous explanation, we applied this style, but this caused an issue where part of the program's form wouldn't load (as explained earlier).

To resolve this issue, in order to remove the Title Bar (without problems such as the form not loading properly), {WS_POPUPWINDOW} should be removed and replaced with {WS_POPUP}.

The following code can be used to perform this action:

System::Call 'user32::SetWindowPos(i$HWNDPARENT,i,i,i,i 900,i 800,i 0x16)'
System::Call 'user32::SetWindowLong(i $HWNDPARENT,i -16,i -1807611828)'

Complete code:

;-----------------
!include "MUI2.nsh"
!include "x64.nsh"
!include "WinMessages.nsh"
;-----------------

;-----------------
Var nsDialogs
Var BTN_QUIT
;-----------------

;-----------------
Page Custom Custom_Page_Show
;-----------------


Function Custom_Page_Show
;-----------------
MoveAnywhere::Hook
;-----------------
;FIX
System::Call 'user32::SetWindowLong(i $HWNDPARENT,i -16,i -1807611828)'
;-----------------
System::Call 'user32::SetWindowPos(i$HWNDPARENT,i,i,i,i 1400,i 1024,i 0x16)'

nsDialogs::Create 1044
Pop $nsDialogs
SetCtlColors $nsDialogs 0x000000 0xfafafa
System::Call 'USER32::MoveWindow(p$nsDialogs,i0,i0,i 1400,i 1024,i1)'
;-----------------

;-----------------
${NSD_CreateButton} 100 17 100 29 "QUIT"
Pop $BTN_QUIT
CreateFont $0 "Myriad Pro" 20 700
SendMessage $BTN_QUIT ${WM_SETFONT} $0 1
SetCtlColors $BTN_QUIT 0xffffff 0x015f72
${NSD_OnClick} $BTN_QUIT BTN_QUIT_Click
;-----------------

;-----------------
${NSD_CreateButton} 1200 17 100 29 "CLOSE"
Pop $BTN_QUIT
CreateFont $0 "Myriad Pro" 20 700
SendMessage $BTN_QUIT ${WM_SETFONT} $0 1
SetCtlColors $BTN_QUIT 0xffffff 0x015f72
${NSD_OnClick} $BTN_QUIT BTN_QUIT_Click
;-----------------

;-----------------
nsDialogs::Show
;-----------------
FunctionEnd


Function BTN_QUIT_Click
;-----------------
MessageBox MB_OK|MB_ICONSTOP|MB_TOPMOST|MB_SETFOREGROUND "Bye!!"
SendMessage $HWNDPARENT ${WM_CLOSE} 0 0
Quit
;-----------------
FunctionEnd



Section

SectionEnd

Upvotes: 0

Related Questions