Archive: Modal MessageBox


Modal MessageBox
Guys,

Is there an option to make a MessageBox modal? MB_TOPMOST doesn't seem to do the trick. I have a question box that I want to be centre/top and unable to do anything until answered.

Is this possible with NSIS?

Thanks


I'm not sure what your problem is. The MessageBox instruction produces a modal message box which until a selection is made, halts code execution. Where are you showing one?

Stu


I want one similar to a modal box like mfc produces so it takes focus. Not just installation halt but doesn't allow anything else to be done too until question answered. Like if you click outside of the box, the computer will ding.


why do you want to hurt your users?


I don't, it was more if it was possible :-)


To make a Messagebox modal you have to pass the parent window handle instead of NULL.

You can do this by

!include "${NSISDIR}\Examples\System\System.nsh"
!define STYLE ${MB_OK}|${MB_ICONINFORMATION}
System::Call 'User32::MessageBox(i $HWNDPARENT, t "The text", t "A caption", i ${STYLE}) i.'

(Shameless copy from a post from aerDNA in the MessageBox with more buttons thread)

Hmm, and this is exactly what the NSIS MessageBox is doing, so what is your question?


jweinraub I very much doubt this is possible with Windows as is. Have you ever seen this done before in an installation wizard?

Stu


I've seen it done before in some applications that throw an error (and I don't mean the UAC prompt).. so it can be done, but it sure is annoying(!)


I don't recall if I ever seen an installation program do it, but I have seen Windows programs do it.


Techically that example is modal to the parent window, not the desktop. I believe a true modal dialogue won't let you do anything else until that has been answered...

But I don't plan on doing anything that will make our customers annoyed it was just a curiosity question.


Originally posted by jweinraub
Techically that example is modal to the parent window, not the desktop.
Yes, you're right.
I didn't understand what you are trying to do at first.

Originally posted by jweinraub
I believe a true modal dialogue won't let you do anything else until that has been answered...
As far as I know, a modal dialog is only modal to it's parent window, not to windows from other programs.
http://en.wikipedia.org/wiki/Modal_window

To make something you want, you will have to do something like the Windows XP shutdown dialogbox:
Make a screendump, show it on top of everything, and place your dialogbox on top of that.
See http://www.codeproject.com/KB/dotnet/DimmerForm.aspx for an example (.NET)

But as said before, I don't think that is something you want to do to your users...