I am looking for a way to make a MessageBox with the buttons "yes", "yes to all", "no" and "no to all".
I searched, and checked documentation but still don't know how to do it.
anyone? 😉
MessageBox with more buttons
114 posts
As always, it's a built-in Windows API function, you need a plug-in to change it.
A brand new plugin, or a trick with the system plugin?
I think you meant a brand new plugin but since I saw many nice tricks with that system plugin, maybe I can find a workaround 🙄
If I can't find a workaround, users will have to click 'yes' to all 😉
I think you meant a brand new plugin but since I saw many nice tricks with that system plugin, maybe I can find a workaround 🙄
If I can't find a workaround, users will have to click 'yes' to all 😉
With system plugin? I don't know... too much API calls since we're subclassing
mmm.... I was playing with messagboxes and saw that I can't use two sets of buttons at once, so the max buttons is three (abor, retry, ignore or yes, no, cancel), but there's a MB_DEFBUTTON4 for making default the 4th button. I am missing something?
Lobo, are you saying that using system plugin for this would be difficult but possible?
Lobo, are you saying that using system plugin for this would be difficult but possible?
actually...in VB you are using the same MsgBox but you edit
the strings, you know: "OK", "CANCEL" with stuff you like.
Is subclassing. I think Nsis have one, maybe the developers can put some test code so we can convert it to system plugin syntax.
the strings, you know: "OK", "CANCEL" with stuff you like.
Is subclassing. I think Nsis have one, maybe the developers can put some test code so we can convert it to system plugin syntax.
I don't think this is possible using the System plug-in. You have to write a new one.
System allows to do everething needed to create custom dialog, but NSIS somehow brokes all the dialogs created at the scripting thread. And the system couldn't create a new thread for it... 🙁


Try this (isn't complete yet but it shows the basics i hope 😉 )
It allows you to set the title and caption as a normal messagebox but you can define the number of buttons to include and also the text for the 4 buttons on the messagebox (the 4th is the 'help' button).
Has a few problems still in handling the number of buttons and some of the standard styles of a messagebox but it works eg MB_HELP.
note: if a button text isn't associated for a button then in most cases the button text will be cleared - haven't put checking of that in yet 😞 .
Example is basic but should give you an idea of things so far (more complete info will come soon). I will alter the way of setting the button text so that you just pass in what you want to change
eg
with a yes|no|cancel then you can pass only the text needed for the 'no' to change it to yes|blah|cancel.
Feedback welcome
Daz
ps when using the 'help' button nothing happens at the moment - thinking of playing with it to act as a full button eventually if things work out
It allows you to set the title and caption as a normal messagebox but you can define the number of buttons to include and also the text for the 4 buttons on the messagebox (the 4th is the 'help' button).
Has a few problems still in handling the number of buttons and some of the standard styles of a messagebox but it works eg MB_HELP.
note: if a button text isn't associated for a button then in most cases the button text will be cleared - haven't put checking of that in yet 😞 .
Example is basic but should give you an idea of things so far (more complete info will come soon). I will alter the way of setting the button text so that you just pass in what you want to change
eg
with a yes|no|cancel then you can pass only the text needed for the 'no' to change it to yes|blah|cancel.
Feedback welcome
Daz
ps when using the 'help' button nothing happens at the moment - thinking of playing with it to act as a full button eventually if things work out
Nice 😉 Thanks dude...
huh 🙂 Windows Hooks 😉 Nice idea!
Originally posted by brainsuckerthat's what i thought to 😁
huh 🙂 Windows Hooks 😉 Nice idea!
found it when i was playing with hooks to get all visible windows to dock to the edge of the desktop and found that i could catch a messagebox being created, so i can get its hwnd 🙂
will upload the new version when i get on the other work machine in a bit. changed a few bits so that now the 'help' button will react as a proper button (apart from a few cases still 🙁 ) and fixed some bugs and stuff.
what's the normal buffer limit for the included messagebox?
-daz
update
latest version attached
now you can set only the button text you want to otherwise the existing text will be kept. also it doesn't matter which way round you pass in the button order 😎
done a number of internal changes so that now there is a functional 'forth' button on the dialog so it is possible to do "yes", "yes to all", "no" and "no to all" and have the option working.
setting the number of buttons to -1 allows the normal button states to be set and the text can still be set for the buttons.
still are a few issues ie using MB_HELP to get the forth button will not always close for a few mode combinations when using '-1'.
enjoy
daz
latest version attached
now you can set only the button text you want to otherwise the existing text will be kept. also it doesn't matter which way round you pass in the button order 😎
done a number of internal changes so that now there is a functional 'forth' button on the dialog so it is possible to do "yes", "yes to all", "no" and "no to all" and have the option working.
setting the number of buttons to -1 allows the normal button states to be set and the text can still be set for the buttons.
still are a few issues ie using MB_HELP to get the forth button will not always close for a few mode combinations when using '-1'.
enjoy
daz
wow!!!
I missed all this replies!!!
How could I!!!???
Thanks DrO, gonna test this 🙂
I missed all this replies!!!
How could I!!!???
Thanks DrO, gonna test this 🙂
Originally posted by n0On3don't worry about it 😉
wow!!!
I missed all this replies!!!
How could I!!!???
Thanks DrO, gonna test this 🙂
done a few more bits on it so that the 'help' button will always work as a full button whatever style is passed in and some more bug fixes/changes
also trying to get custom icon setting working for the messagebox as well - thought it might be useful 😁
-daz
And where's the update?
I looked in the Archive and couldn't find it.
I looked in the Archive and couldn't find it.
I looked in the Archive and couldn't find it.latest version is now attached (with readme explaining how to use it that makes sense i hope 😁 )
only real feature missing now is the ability to set the icon shown by the messagebox to be a user defined icon (ran out of time last night).
wahtever mode you use now, the button texts will always be altered correctly and the 'help' button will always close the messagebox whatever the style used (wasa glaring issue in the last release)
has anyone tried it with a language other than english yet? i'm interested to see how it works with other languages.
also would the ability to alter the button sizes on the messagebox so that the text passed in will fit correctly be a good to implement?
(noted that NT has small buttons so the example may not appear correctly 🙁 )
enjoy
-daz
ps will put a copy into the archive soon once i've got the user icon part working
thanks for posting 🙂
I haven't used any other languages than english.
and yes, auto-resize buttons seems nice
thanks for working in this plugin 👍
Note: thanks for writing my name in the text files, can you write 'n0On3' instead of 'n0on3'? 😉
I haven't used any other languages than english.
and yes, auto-resize buttons seems nice
thanks for working in this plugin 👍
Note: thanks for writing my name in the text files, can you write 'n0On3' instead of 'n0on3'? 😉
At last user icon support works!!
Attached is now the latest version including a few typo fixes for the readme file.
@n0On3 - sorry for getting it wrong, it was 2:30am when i was writing that file 😉
note: if using the user icon option and the icon does not exist then a blank space will be seen where the icon goes - likely to happen with the second test messagebox in the example script (at least on NT, i found 2k was fine).
I will setup a archive page for this in a bit and when i get the chance to tonight i will work on the resizing of the text buttons so that the text will always fit 😎 (may take a while with other things on at the moment)
enjoy this people
-daz
Attached is now the latest version including a few typo fixes for the readme file.
@n0On3 - sorry for getting it wrong, it was 2:30am when i was writing that file 😉
note: if using the user icon option and the icon does not exist then a blank space will be seen where the icon goes - likely to happen with the second test messagebox in the example script (at least on NT, i found 2k was fine).
I will setup a archive page for this in a bit and when i get the chance to tonight i will work on the resizing of the text buttons so that the text will always fit 😎 (may take a while with other things on at the moment)
enjoy this people
-daz
auto-resize buttons seems nicewell it's implemented now so when you set the button text if you want it then the button will be resized to the text (and a bit more either side for a nicer look 😉)
eg
"/but1 /trim install me now"
still a few little issues such as getting the sizing to work correctly when the text is just too big for the button.
also the messagebox will max out at 80% of the screen size (not fully supported yet and may add a little extra when this limit is reached...)
-daz
thanks 🙂
I wanted to say that I find the command a bit confusing:
I can pass which styles I want to use(like MB_OKCANCEL) but if I want to use them I have to pass "-1", but if i also pass "/but3 c" then the style is overwritten.
I also don't understand the hwnd. I thought these messageboxes will always be created from the installer, or is this plugin doing something more?
I tried to think a simpler format. Describing the window from up to down:
MessageBox::Show "window title" "icon.dll,3" "window text" 4 "IDYES" "yes to all" "IDNO" "no to all"
I used IDYES for telling that I want a 'yes' style in the first button and IDNO for having a no in the third. And I think that making it always return the number of the button instead of No = 9 is easier to understand.
I also think that if somebody uses a long text for a button, he will always want it resized, so the /trim switch can be avoided.
just some suggestions 😉
PS: maybe with this format you can pass things that can't be done, like this: MessageBox::Show "window title" "" "window text" 2 "IDNO" "IDYES" and you can't have a first button with a 'no' and the second be a 'yes'. If this is the case you can make the script refuse to compile and say that it has to be 'yes' and 'no' instead.
I wanted to say that I find the command a bit confusing:
I can pass which styles I want to use(like MB_OKCANCEL) but if I want to use them I have to pass "-1", but if i also pass "/but3 c" then the style is overwritten.
I also don't understand the hwnd. I thought these messageboxes will always be created from the installer, or is this plugin doing something more?
I tried to think a simpler format. Describing the window from up to down:
MessageBox::Show "window title" "icon.dll,3" "window text" 4 "IDYES" "yes to all" "IDNO" "no to all"
I used IDYES for telling that I want a 'yes' style in the first button and IDNO for having a no in the third. And I think that making it always return the number of the button instead of No = 9 is easier to understand.
I also think that if somebody uses a long text for a button, he will always want it resized, so the /trim switch can be avoided.
just some suggestions 😉
PS: maybe with this format you can pass things that can't be done, like this: MessageBox::Show "window title" "" "window text" 2 "IDNO" "IDYES" and you can't have a first button with a 'no' and the second be a 'yes'. If this is the case you can make the script refuse to compile and say that it has to be 'yes' and 'no' instead.
suggestions are good 😉
thought it was getting a bit confusing too for the parameters (was going to overhaul how they are passed anyway for v1.0).
i like that idea and it's not to difficult to change the existing code to do it as well. also the "icon.dll,3" is better for the whole icon thing since "0,3" could be used to get the resource from the installer.
about the '-1' thing, the idea was that with it the function will return what the messagebox returns but with the ability if needed to alter the button text if wanted (late night programming that 🙂). so if the forth is 'no' then it will return 9 since that is the button's id.
can understand the confusion about it so i will map the return to 1,2,etc in all cases now (does make it more consistant) and will drop the -1 option.
"IDYES" "yes to all" "IDNO" "no to all" part - i like that idea and it isn't hard to put it in as things are since i can just set internally set the button text to 'yes' when a 'IDYES' is passed for example.
i can see what you're getting at about the IDNO can't be first but i think that if the return value is going to be mapped to the button number then it should not matter which way round the buttons are - just my thought on it.
hope that clarifies a few bits.
thanks for the suggestions n0On3 🙂, always good to have a different view point on things. will get on with this tonight and get a test version uploaded tomorrow.
-daz
ps just had a thought, if doing "IDYES" "yes to all" "IDNO" "no to all" then it's possible to drop the number of buttons specification. instead it can be worked out from the number of button texts passed in
thought it was getting a bit confusing too for the parameters (was going to overhaul how they are passed anyway for v1.0).
I thought these messageboxes will always be created from the installer, or is this plugin doing something more?when you pass a 0 for the parameter then it will use the installer as the owner. the reason it is in there is basically from the initial development phase of the plugin (since i ported the basics of what i had from another program) and was going to drop it anyway
I also think that if somebody uses a long text for a button, he will always want it resized, so the /trim switch can be avoided.was going to drop it too - since that part isn't finished yet i was using the /trim to allow me to test the feature for specific button positions (without hard coding tests into the code) to make sure that the messagebox would resize and move subsequent buttons correctly.
MessageBox::Show "window title" "icon.dll,3" "window text" 4 "IDYES" "yes to all" "IDNO" "no to all"nice 🙂
i like that idea and it's not to difficult to change the existing code to do it as well. also the "icon.dll,3" is better for the whole icon thing since "0,3" could be used to get the resource from the installer.
about the '-1' thing, the idea was that with it the function will return what the messagebox returns but with the ability if needed to alter the button text if wanted (late night programming that 🙂). so if the forth is 'no' then it will return 9 since that is the button's id.
can understand the confusion about it so i will map the return to 1,2,etc in all cases now (does make it more consistant) and will drop the -1 option.
"IDYES" "yes to all" "IDNO" "no to all" part - i like that idea and it isn't hard to put it in as things are since i can just set internally set the button text to 'yes' when a 'IDYES' is passed for example.
i can see what you're getting at about the IDNO can't be first but i think that if the return value is going to be mapped to the button number then it should not matter which way round the buttons are - just my thought on it.
hope that clarifies a few bits.
thanks for the suggestions n0On3 🙂, always good to have a different view point on things. will get on with this tonight and get a test version uploaded tomorrow.
-daz
ps just had a thought, if doing "IDYES" "yes to all" "IDNO" "no to all" then it's possible to drop the number of buttons specification. instead it can be worked out from the number of button texts passed in
Great!
I am very glad you liked my ideas 🙂
I am very glad you liked my ideas 🙂
latest test version
changed the calling syntax of the function to be simpler and hopefully make more sense 😉
now the number of buttons to show is all based on the number of button strings passed with default button texts used when you pass the defines
e.g. IDYES => 'Yes' IDCANCEL => 'Cancel' (see the readme for the supported options)
buttons are resized in all cases (more logical) and the resizing is more gradual especially when the text is near to the existing button width.
the handling of long button texts when the messagebox width is exceeded (that's the 80% of the screen limit) is not done yet.
also the MB_DEFBUTTON? style will not work for resized buttons (defaults to the first button but i have the fix worked out for it).
-daz
changed the calling syntax of the function to be simpler and hopefully make more sense 😉
now the number of buttons to show is all based on the number of button strings passed with default button texts used when you pass the defines
e.g. IDYES => 'Yes' IDCANCEL => 'Cancel' (see the readme for the supported options)
buttons are resized in all cases (more logical) and the resizing is more gradual especially when the text is near to the existing button width.
the handling of long button texts when the messagebox width is exceeded (that's the 80% of the screen limit) is not done yet.
also the MB_DEFBUTTON? style will not work for resized buttons (defaults to the first button but i have the fix worked out for it).
-daz
yes, this plugin works great 🙂
I found that I can't use the installer icon when the installer is set to silent:
SilentInstall "Silent"
great plugin, thanks 🙂
I found that I can't use the installer icon when the installer is set to silent:
SilentInstall "Silent"
great plugin, thanks 🙂
I found that I can't use the installer icon when the installer is set to silentwill have a look at that tonight, thanks for pointing it out (and will have a go at the few other bits left to do).
-daz
Can you create an archive page when it's finished?
Can you create an archive page when it's finished?Will do that once i've got the last few bits fixed (and got the code readable 😉 )
I found that I can't use the installer icon when the installer is set to silenthad a check of the code and the icon part works fine in a silent installer.
i did notice that in the example with v0.98 beta, the last messagebox did not have the icon set, instead it has a "" where the icon part goes.
working on the button widths at the moment for the 80% limit being reached. also fixed the default button issue - just needed to prevent a message being sent to the messagebox 🧟
should have the new version with the button adjustment fully done by tomorrow i hope
-daz