Old 16th February 2006, 21:53   #1
Comperio
Major Dude
 
Comperio's Avatar
 
Join Date: Jan 2005
Location: Oregon Coast
Posts: 737
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?
Comperio is offline   Reply With Quote
Old 17th February 2006, 08:08   #2
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
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
Afrow UK is offline   Reply With Quote
Old 19th February 2006, 16:01   #3
Comperio
Major Dude
 
Comperio's Avatar
 
Join Date: Jan 2005
Location: Oregon Coast
Posts: 737
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:
code:

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?
Comperio is offline   Reply With Quote
Old 19th February 2006, 16:04   #4
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
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
Afrow UK is offline   Reply With Quote
Old 19th February 2006, 16:05   #5
Comperio
Major Dude
 
Comperio's Avatar
 
Join Date: Jan 2005
Location: Oregon Coast
Posts: 737
No, I'm not using MUI. (I wanted to start with baby steps). and yes, I did both compile and save.
Comperio is offline   Reply With Quote
Old 22nd February 2006, 01:07   #6
Comperio
Major Dude
 
Comperio's Avatar
 
Join Date: Jan 2005
Location: Oregon Coast
Posts: 737
Anyone have any idea why my System Plugin call isn't working from above?
Comperio is offline   Reply With Quote
Old 22nd February 2006, 03:08   #7
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,288
disable close:
PHP Code:
function .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)
PHP Code:
function .onGuiInit
System
::Call 'user32::SetWindowLong(i $HWNDPARENT,i -16,i 339871820)'
ShowWindow $HWNDPARENT 0
ShowWindow $HWNDPARENT 2
ShowWindow $HWNDPARENT 0
ShowWindow $HWNDPARENT 1
functionEnd 

IntOp $PostCount $PostCount + 1

Last edited by Anders; 22nd February 2006 at 03:34.
Anders is offline   Reply With Quote
Old 22nd February 2006, 15:54   #8
Comperio
Major Dude
 
Comperio's Avatar
 
Join Date: Jan 2005
Location: Oregon Coast
Posts: 737
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.
Comperio is offline   Reply With Quote
Old 15th June 2016, 14:16   #9
r2du-soft
Senior Member
 
r2du-soft's Avatar
 
Join Date: Nov 2013
Location: Iran
Posts: 342
Quote:
Originally Posted by Anders View Post
disable close:
PHP Code:
function .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)
PHP Code:
function .onGuiInit
System
::Call 'user32::SetWindowLong(i $HWNDPARENT,i -16,i 339871820)'
ShowWindow $HWNDPARENT 0
ShowWindow $HWNDPARENT 2
ShowWindow $HWNDPARENT 0
ShowWindow $HWNDPARENT 1
functionEnd 

Mr Anders

When i use from:
HTML Code:
function .onGuiInit
System::Call 'user32::SetWindowLong(i $HWNDPARENT,i -16,i 339871820)'
ShowWindow $HWNDPARENT 0
ShowWindow $HWNDPARENT 2
ShowWindow $HWNDPARENT 0
ShowWindow $HWNDPARENT 1
functionEnd
Then i cant move installer position in screen with mouse,i want hide title bar but i want change installer position in screen with mouse...

This method possible?
r2du-soft is offline   Reply With Quote
Old 15th June 2016, 16:08   #10
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,288
Quote:
Originally Posted by r2du-soft View Post
Mr Anders

When i use from:
HTML Code:
function .onGuiInit
System::Call 'user32::SetWindowLong(i $HWNDPARENT,i -16,i 339871820)'
ShowWindow $HWNDPARENT 0
ShowWindow $HWNDPARENT 2
ShowWindow $HWNDPARENT 0
ShowWindow $HWNDPARENT 1
functionEnd
Then i cant move installer position in screen with mouse,i want hide title bar but i want change installer position in screen with mouse...

This method possible?
Are you using the MoveAnywhere plugin?

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 15th June 2016, 17:22   #11
r2du-soft
Senior Member
 
r2du-soft's Avatar
 
Join Date: Nov 2013
Location: Iran
Posts: 342
No i usent that plugin,i search but not found that...
r2du-soft is offline   Reply With Quote
Old 15th June 2016, 21:59   #12
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,288
Quote:
Originally Posted by r2du-soft View Post
No i usent that plugin,i search but not found that...
Why do you think it would be possible without a plug-in? This is non-standard Windows behavior.

Search this forum for MoveAnywhere and I'm sure you'll find it...

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 22nd February 2020, 12:34   #13
r2du-soft
Senior Member
 
r2du-soft's Avatar
 
Join Date: Nov 2013
Location: Iran
Posts: 342
i use from

HTML Code:
function .onGuiInit
System::Call 'user32::SetWindowLong(i $HWNDPARENT,i -16,i 339871820)'
ShowWindow $HWNDPARENT 0
ShowWindow $HWNDPARENT 2
ShowWindow $HWNDPARENT 0
ShowWindow $HWNDPARENT 1
functionEnd 
to remove installer titlebar in custome pages
now i want restore and show deafult (minimize,close,maximize,titlebar) in Section
how can do it?

i use ShowWindow $HWNDPARENT ${SW_SHOW} but not restore!!
r2du-soft is offline   Reply With Quote
Old 24th February 2020, 17:08   #14
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,288
Save the style first
Quote:
var originalstyle
function .onGuiInit
System::Call 'user32::GetWindowLong(i $HWNDPARENT,i -16)i.s
pop $originalstyle
and then you can probably use that to restore instead of using a magic number.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump