Old 15th September 2010, 16:45   #1
miesfeld
Junior Member
 
Join Date: Sep 2010
Posts: 6
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.
miesfeld is offline   Reply With Quote
Old 15th September 2010, 17:02   #2
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
code:
!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
Afrow UK is offline   Reply With Quote
Old 15th September 2010, 22:22   #3
miesfeld
Junior Member
 
Join Date: Sep 2010
Posts: 6
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. ;-(
miesfeld is offline   Reply With Quote
Old 15th September 2010, 22:56   #4
Animaether
Major Dude
 
Join Date: Jun 2001
Posts: 1,173
Quote:
Originally Posted by miesfeld View Post
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."

Quote:
Originally Posted by miesfeld View Post
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

Quote:
Originally Posted by miesfeld View Post
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

Quote:
Originally Posted by miesfeld View Post
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

Quote:
Originally Posted by miesfeld View Post
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.
Animaether is offline   Reply With Quote
Old 16th September 2010, 10:29   #5
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
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
Afrow UK is offline   Reply With Quote
Old 16th September 2010, 12:17   #6
Animaether
Major Dude
 
Join Date: Jun 2001
Posts: 1,173
Quote:
Originally Posted by Afrow UK View Post
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.
PHP Code:
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 :> )
Animaether is offline   Reply With Quote
Old 16th September 2010, 16:00   #7
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
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
Afrow UK 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