Archive: Disable or remove Windows close button?


Disable or remove Windows close button?
  Odd question:
Is there a way that I can disable the Close button (little 'x' in the upper right-hand corner) of an installer window?

Or, perhaps a way to remove the title bar altogether?

First, I thought perhpas a SendMessage or EnableWindow command might do it, but couldn't find a handle to this control or a command to use to do it.

Next, I thought maybe I could use Resource Hacker to do it, but couldn't find a way to get to that part of the Window.

Can anyone give me a push in the right direction?


Edit the dialog in Resource Hacker and remove the WS_SYSMENU style from IDD 105 (or to remove the whole caption, remove WS_CAPTION).

-Stu


Perhaps I'm doing something wrong as I cannot make this work. Using Resource Hacker, I changed the file ${NSISDIR}\Contrib\UIs\default.exe to remove WS_SYSMENU. I saved the EXE and confirmed the save by viewing the modified date of default.exe. I then just recompile my NSIS script, but nothing changes. Have I missed a step?

2nd qustion:
I found this article about how to disable the close box that I thought I'd try using the system plugin. I found the function on MSDN, so I decided to GetSystemMenu setup an experiment with Windows Notepad using this function:


FindWindow $5 '' 'Untitled - Notepad'
MessageBox MB_OK "handle of Notepad: $5"
System::Call "user32::GetSystemMenu (i r5,i 0) i.r6"
;MessageBox MB_OK "Return value #1: $R1"
MessageBox MB_OK "Result: $6"

But each time I run, my result returns 'error'. Can anyone tell me what I might be doing wrong?

Are you using Modern UI? If so you need to modify modern.exe. Also, when removing the styles, make sure you click the Compile button in Resource Hacker and then File>Save.

-Stu


No, I'm not using MUI. (I wanted to start with baby steps). and yes, I did both compile and save.


Anyone have any idea why my System Plugin call isn't working from above?


disable close:


onGuiInit

push$1
System
::Call "user32::GetSystemMenu(i $HWNDPARENT,i 0) i.s"
>pop $1
System::Call "user32::EnableMenuItem(i $1,i 0xF060,i 1)"
>pop $1
functionEnd
>
nasty hack to remove titlebar: (windows size is a bit off, and you really should do the proper bit-twiddling to remove the required bits and call Redraw window instead of all those ShowWindow calls)

onGuiInit

System
::Call 'user32::SetWindowLong(i $HWNDPARENT,i -16,i 339871820)'
>ShowWindow $HWNDPARENT 0
ShowWindow $HWNDPARENT 2
ShowWindow $HWNDPARENT 0
ShowWindow $HWNDPARENT 1
functionEnd
>

Thanks, Anders!

For some reason, I wasn't getting the handle returned from my GetSystemMenu function, but since your function seems to work, so I'll just go with that. ;)