miesfeld
15th September 2010 17:45 UTC
Completely disable cancel
For a one type of install, once it gets past a certain point in the pages, I want to prevent the user from canceling. They need to finish the install and then do an uninstall if they want to change something.
I know there are a number of ways of doing this, like using the onUserAbort function, or getting the window handle of the Cancel button and disabling it, etc..
But, I'd like to have the appearance that the MUI_PAGE_INSTFILES and MUI_UNPAGE_INSTFILES in MUI 2 have where the Cancel button, the title bar Close button and the System Menu Close item are all disabled. However, the Next and Back buttons should be enabled.
I've been searching, but I can't seem to find how that is done. Is there a simple way of doing this?
Or, do I have to write a custom Show function for every standard page and disable everything manually?
Thanks.
Afrow UK
15th September 2010 18:02 UTC
!define SC_CLOSE 0xF060
!define MF_GRAYED 0x1
; Disable Close (X) button.
System::Call user32::GetSystemMenu(i$HWNDPARENT,i0)i.R0
System::Call user32::EnableMenuItem(iR0,i${SC_CLOSE},i${MF_GRAYED})
; Disable Cancel button.
GetDlgItem $R0 $HWNDPARENT 2
EnableWindow $R0 0
Note that NSIS will disable/re-enable both when you enter/leave the InstFiles page.
Stu
miesfeld
15th September 2010 23:22 UTC
Okay, thanks. That works, I found some similar code. And, I just created a function that I call on each page I need to use it.
Even after I read the doc, I don't quit understand this:
; Disable Close (X) button.
System::Call user32::GetSystemMenu(i$HWNDPARENT,i0)i.R0
System::Call user32::EnableMenuItem(iR0,i${SC_CLOSE},i${MF_GRAYED})
I understand Windows programming and mostly the above makes sense. What I don't understand is the: i.R0
I know that is where the result of GetSystemMenu goes, as an int, but what is the dot? The '.' And why don't you use $R0? Same thing in the call to EnableMenuItem() There is iR0. Don't you need a space after the i? And, again, why isn't $R0 used instead of just R0?
The reason I ask, is that when I copy some of these System::Call examples, they work. But when I try to write my own code it fails. ;-(
Animaether
15th September 2010 23:56 UTC
Originally posted by miesfeld
Even after I read the doc, I don't quit understand this:
; Disable Close (X) button.
System::Call user32::GetSystemMenu(i$HWNDPARENT,i0)i.R0
System::Call user32::EnableMenuItem(iR0,i${SC_CLOSE},i${MF_GRAYED})
I understand Windows programming and mostly the above makes sense. What I don't understand is the: i.R0
I know that is where the result of GetSystemMenu goes, as an int, but what is the dot?
The format of the System plugin parameter feeding / output is:
<type><inval/var><outvar>
In this case, as you want the output from the function, there is no input value/variable, so the . (dot) is used to indicate such. Otherwise, if you wrote "iR0", the System plugin would think you're trying to input the value of $R0.. which makes no sense in this case.
The System docs state it as follows:
"Either one of source or destination can also be a dot ('.') if it is not needed."
Originally posted by miesfeld
And why don't you use $R0?
Because you're indicating to the System plugin that it should store the result of the function in the -variable- $R0. If you wrote that as i$R0, you'd be telling it to store the result of the function in whatever the -value- of $R0 is. I'm pretty sure that doesn't even work :)
Originally posted by miesfeld
Same thing in the call to EnableMenuItem() There is iR0.
In that case, he could have used i$R0 (or 'i $R0', see below), as it's an input value. Matter of personal preference, perhaps :)
Originally posted by miesfeld
Don't you need a space after the i?
Nope - System pretty much ignores that space after the parameter type. It can be easier to read when you do use the space, though.
There is even a whole 'nother syntax form you can use.. I hardly ever see it used these days, though, so probably best to stay away from it. Here's an example using it, just for reference... look for the System::Call lines.
http://nsis.sourceforge.net/Windows_...Mass_Installer
Originally posted by miesfeld
The reason I ask, is that when I copy some of these System::Call examples, they work. But when I try to write my own code it fails. ;-(
Welcome to the world of the System plugin. Few here have mastered it.. I sure as heck haven't yet :) Just keep poking about at it, check out more examples (plenty in the forums), and never be afraid to ask for assistance.
Afrow UK
16th September 2010 11:29 UTC
I tend not to use spaces in my System plug-in calls when possible so that I do not have to use quotes. As soon as you introduce a space you must use quotes.
Stu
Animaether
16th September 2010 13:17 UTC
Originally posted by Afrow UK
I tend not to use spaces in my System plug-in calls when possible so that I do not have to use quotes. As soon as you introduce a space you must use quotes.
You mean spaces in parameter values (e.g. for strings.. but those always need quotes..)? The spaces between the parameter type and in/out value/variable(s) shouldn't change anything, though?
i.e.
System
::Call "user32::MessageBox(i$HWNDPARENT, t'NSIS System Plug-in', t'Test', i0)"
>System::Call "user32::MessageBox(i $HWNDPARENT, t 'NSIS System Plug-in', t 'Test', i 0)"
are functionally entirely the same afaik ( but I did say I haven't mastered the System plugin yet :> )
Afrow UK
16th September 2010 17:00 UTC
In NSIS you only need quotes to make a string with spaces a single token. If there are no spaces then you don't need quotes. In my two System calls there are no spaces and therefore I do not need any quotes. I guess thinking about it it's just to stop the syntax highlighter in Notepad2 picking up my System code as just another string in quotes.
Stu