How do I center the UI and stretch the shape over the entire resolution? NSIS

71 Views Asked by At

I put the MUI_PAGE_COMPONENTS form. Next, for the installer, I set the resolution to 1280 by 720.

!define WIDTH 1280
!define HEIGHT 720

Function .onGUIInit
    GetDlgItem $0 $HWNDPARENT 1000 
    System::Call 'user32::MoveWindow(i $HWNDPARENT, i 0, i 0, i ${WIDTH}, i ${HEIGHT}, i 1)' MoveWindow(i $0, i 0, i 0, i ${WIDTH}, i ${HEIGHT}, i 1)' 
FunctionEnd

But all the UI elements are located in the upper-left corner. Is it possible to center and stretch the form (UI elements) to the entire size of the window? If not, how do I stretch the component box and description box?

screenshot

I searched , but I never found an easy solution. Is it really impossible to manipulate elements of ready-made forms?

2

There are 2 best solutions below

0
Anders On BEST ANSWER

The sane way to change the UI is to use Resource Hacker to modify one of the files in ...\NSIS\Contrib\UIs and apply it with !define MUI_UI myfile.exe.

If you want to move things at run-time you can call MoveWindow or SetWindowPos (SetWindowPos allows you to move without resizing a control). If you do this, remember that some controls are in the inner dialog and some are not.

0
Slappy On

It is possible, and you actually posted a correct solution: All you need is to move/resize the controls individually.**

For example a Next button:

GetDlgItem $0 $HWNDPARENT 1 ; Get the handle to button
System::Call 'user32::MoveWindow(i $HWNDPARENT, i <param> , i <param> , i <param> i <param>  i 1)' MoveWindow(i $0, i <param> , i <param> , i <param> , i <param>, i 1)' 

There is way how to move all controls in a bulk (Windows API does not support that) so iterate over all controls you want to move/resize, get their handles (see NSIS docs) and call the MoveWindow Win API function with appropriate parameters:

https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-movewindow