Skip to content
⌘ NSIS Forum Archive

MessageBox with more buttons

114 posts

DrO#
at the moment no since i don't have the source code on my machine here (i think my attempt at a new version was on the machine at work) so i'll have to track that down tomorrow and see what i can make up to test the thing out). i will add that it appears to work fine for me (though i can't test on an XP install until later). not too sure why it'd fail to display as such if it's working on all other installs (unless the test machine where it fails has something else installed on it which could be breaking the OS hacks)

-daz
loquis#
Found an odd issue with messagebox.

If I have message text with a ':' in it, sometimes the text after the ':' isnt shown, sometimes it is.

Any idea why this might be?
flizebogen#
I've tested the latest version (v.0.98 beta 3) of your plugin.

messagebox::show MB_DEFBUTTON2|MB_TOPMOST "title" "" "Body" "Button1" IDNO

If i see this messagebox and press Escape a sound is played and the messagebox disappears.

messagebox::show MB_DEFBUTTON2|MB_TOPMOST "title" "" "Body" "Button1" "Button2"

If i press Escape on a messagebox without standard buttons the process uses 99 procent cpu resources and stops responding.

Any ideas?

- flizebogen
DrO#
i tried looking into that issue but there's a quirk with the overrides i do and the OS. i can't remember if i managed to resolve the issue or not since it was something i was trying to work on during my lunch breaks at work and i don't have that code to hand. from what i remember if there's no proper close button (with the [x] in the top right being greyed out) will cause the lock up

-daz
flizebogen#
I added a Close button. Like you said this prevented the crash.

Unfortunately i have an other problem:

Below is the output of the example from the latest version. If i execute it on a terminal server within a rdp session. No problems on a workstation.

The Plugin return not the number of the chosen button, it don't display at all and gives this faulty output

Any ideas?

C:\DOKUME~1\ab\LOKALE~1\Temp\3\nsu10.tmp\messagebox.dll
messagebox call 1 returned... MB_DEFBUTTON4|MB_TOPMOST
C:\DOKUME~1\ab\LOKALE~1\Temp\3\nsu10.tmp\messagebox.dll
messagebox call 2 returned... MB_SETFOREGROUND|MB_ICONHAND|MB_DEFBUTTON3
C:\DOKUME~1\ab\LOKALE~1\Temp\3\nsu10.tmp\messagebox.dll
messagebox call 3 returned... MB_ICONHAND|MB_DEFBUTTON2
C:\DOKUME~1\ab\LOKALE~1\Temp\3\nsu10.tmp\messagebox.dll
messagebox call 4 returned... MB_ICONEXCLAMATION|MB_ICONHAND|MB_TOPMOST|MB_DEFBUTTON2|MB_RIGHT
C:\DOKUME~1\ab\LOKALE~1\Temp\3\nsu10.tmp\messagebox.dll
Completed
zbd#
This is a great plugin.

I cant seem to work out why, but every time i try to show a custom messagebox, it adds an extra button on to the end that says, "success"

I can't seem to make it not show.
Any ideas?

Nevermind, worked it out, had to Pop $0 before it
Cheers
Guest#
Great work!!!
I'm using it in a current project of mine. Pressing the escape button when the message box is shown (2 custom buttons in my case) hangs the installer, with the CPU going to 60%...a known issue?

Thanks in advance,
Hrish
aerDNA#
It's a pity that messagebox plugin is no longer developed, because it's great. I encountered only one bug but it's a nasty one: messagebox crashes (it freezes, actually) when Esc is pressed. Seems that it goes into some infinite loop (cpu load is 99%).
eagle3386#
Hey guys,

I'm pretty new to all NSIS-stuff, but I truly enjoy the capabilities of the system! 🙂

Anyway, let's get straight to the point:
1. Awesome plugin, but:
2. Could you, DrO, enable support for .ico-files?

Since I'm only using a single icon for kinda "Xmas welcome-screen", I'd prefer to not generate a DLL, but instead use such an .ico-file.

Thanks in advance,
Martin.. 🙂
aerDNA#
Here's how I do it:

> You need Resource Hacker (http://www.angusj.com/resourcehacker/).


> Put the .ico in the folder where your script is and create a cmd file, e.g. header.cmd. Here's what you should put in it:

@echo off
rem 'Inject' the icons into the header with ResHacker:
"%ProgramFiles%\Resource Hacker\ResHacker.exe" -add "%TEMP%\exehead.tmp", "%TEMP%\exehead.tmp", "%~dps0IconName.ico", icongroup,104,1033
rem If you want to compress the header with upx:
"%ProgramFiles%\UPX\upx.exe" --best "%TEMP%\exehead.tmp"

Icon group 104 will contain icons from your ico file. Add more lines for more icon groups.


> Put this at the end of your script:

!packhdr "$%TEMP%\exehead.tmp" "header.cmd"


> And finally, the MessageBox example:

Messagebox::show MB_TOPMOST "Caption" "0,104" "Text" "Button 1" "Button 2" "Button 3" "Button 4"
# it uses the 1st icon from icongroup 104
eagle3386#
First of all, thank you very much for your guide.

Unfortunately, the sad thing about this solution is the fact that Resource Hacker doesn't work under Vista (at least not x64, which is the one I run).. 🙁
aerDNA#
You could try XN Resource Editor or eXeScope as alternatives. I don't know if they'll work on Vista x64 but even if they do, the problem is they don't support command line operation, at least not to my knowledge. eXeScope documentation says it supports some kind of batch processing based on log files but I haven't tried the program. But if you do find a resource editor that works on your system, what you can do is:

> Instead of that header.cmd, create two new ones:

header1.cmd:
copy "%TEMP%\exehead.tmp" C:\tmphead.tmp

header2.cmd:
copy C:\tmphead.tmp "%TEMP%\exehead.tmp" /Y

> Compile the script with:
!packhdr "$%TEMP%\exehead.tmp" "header1.cmd"

> Edit C:\tmphead.tmp with a resource editor

> Compile again with header2.cmd"


Or settle for a regular messagebox and use MB_USERICON... 🙂
eagle3386#
Originally posted by aerDNA
(...)
Useful suggestions
(...)

Or settle for a regular messagebox and use MB_USERICON... 🙂
Uh! That MB_USERICON shows the same like I did (as a workaround) while waiting for an answer from you (which means I set the app's icon to a different one):
MessageBox::show styles "Ho! Ho! Ho!" "0,103" "   Merry Xmas$\r$\n   to all you geeks! 🙂" IDOK
Though, following your way I can't set my own message box-title.. 🙁

And I used "0,103" instead of your suggested "0,104" (AFAIR the Wiki told me that "3") - maybe you could explain this to me? 🙂
aerDNA#
Or settle for a regular messagebox and use MB_USERICON...
Being sleepy makes me slip. You don't have to settle for a regular mb, you can also use the installer icon with the plugin, exactly the way you did. Icon group 103 always contains the installer icon. 104 was the one I suggested to create for adding an extra, which is unnecessary if you're willing to use the same icon for the installer and the messagebox.
Btw, there's a way to change the title even when using the regular mb. But you don't need that now, or do you?
eagle3386#
Originally posted by aerDNA
Being sleepy makes me slip. You don't have to settle for a regular mb, you can also use the installer icon with the plugin, exactly the way you did.
This sounds somewhat familiar for me.. 😉

Originally posted by aerDNA
Icon group 103 always contains the installer icon. 104 was the one I suggested to create for adding an extra, which is unnecessary if you're willing to use the same icon for the installer and the messagebox.
Thanks for clarifying this for me! 🙂

Originally posted by aerDNA
Btw, there's a way to change the title even when using the regular mb. But you don't need that now, or do you?
I always want to learn more, so if you like, please go on! 🙂
aerDNA#
Here, I've made a script that shows how to change a single MB's caption. My method may not be very elegant but it works, and it allows you to create an animated title. This doesn't really belong to this thread any more, I hope the moderators don't mind...


OutFile "XMAS.exe"
;Icon "xmas.ico"
XPStyle On

!include "WinMessages.nsh"
!define InstCaption "Merry XMAS Wisher 1.0 beta"
!define MBCaption1 " Merry XMAS, human!"
!define MBCaption2 " Live long and prosper!"
Caption "${InstCaption}"

Function .onInit
# If you don't want the blinking caption on the taskbar as well, use .onGUIInit

InitPluginsDir
WriteUninstaller $PLUGINSDIR\MBCaption.exe
MessageBox MB_OK|MB_ICONINFORMATION|MB_TOPMOST "This MessageBox has a normal title."
Exec "$PLUGINSDIR\MBCaption.exe"
MessageBox MB_OK|MB_USERICON|MB_TOPMOST "But this one has a festive title!"
MessageBox MB_OK|MB_ICONINFORMATION|MB_TOPMOST "This is the normal title again."
Abort

FunctionEnd

Section "Blank"
SectionEnd


Function un.onInit

FindWindow $0 "" "${InstCaption}" "" ""
IsWindow $0 0 -1

CaptionLoop:
SendMessage $0 ${WM_SETTEXT} "0" "STR:${MBCaption1}"
Sleep 800
SendMessage $0 ${WM_SETTEXT} "0" "STR:"
Sleep 400
SendMessage $0 ${WM_SETTEXT} "0" "STR:${MBCaption2}"
Sleep 800
SendMessage $0 ${WM_SETTEXT} "0" "STR:"
Sleep 400
FindWindow $1 "" "${InstCaption}" "" ""
IsWindow $1 0 CaptionLoop

Abort
FunctionEnd

Section "un.Blank"
SectionEnd
aerDNA#
Appendix:
The above script is missing one thing: RequestExecutionLevel User. Without it, MBCaption.exe should (re)trigger UAC (Utterly Annoying Component 👎 ).
And as I said, the method is not very elegant. When you don't really need a flashing caption, the proper way to go would be to create a custom MB through Win API. E.g.:
!include "${NSISDIR}\Examples\System\System.nsh"
!define STYLE ${MB_OK}|${MB_ICONINFORMATION}|${MB_TOPMOST}
System::Call 'User32::MessageBox(i $HWNDPARENT, t "The text", t "A caption", i ${STYLE}) i.'
To use a custom icon (including the installer icon), you need MessageBoxIndirect, but it accepts only module handles. Handles returned by LoadImage don't work, that must be why MessageBox plugin can't support ico files.
scully13#
Has anyone ever converted the messagebox plugin into Unicode? If not I would be interested in trying to do so if the source is available somewhere.
DrO#
nope it's not been done since the source was lost. i did begin to reimplement it but my winamp commitments have killed that from happening. but maybe one day i'll get around to it...

-daz
DrO#
have just removed the downloads for this and the wiki page relating to the plug-in has been removed.

i'm never going to get around to re-creating it to make it compatible with current OSes since it's been almost 6 years and i've never found the time.

is also better to remove it to prevent other users trying to use it and then wonder why they have issues - doesn't help it was compiled in a manner which turns out to not be DEP compatible *doh*

🔒

-daz