![]() |
#1 |
Senior Member
|
MessageBox with more buttons
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? ![]() |
![]() |
![]() |
#2 |
M.I.A.
[NSIS Dev, Mod] Join Date: Oct 2001
Location: Israel
Posts: 11,343
|
As always, it's a built-in Windows API function, you need a plug-in to change it.
NSIS FAQ | NSIS Home Page | Donate $ "I hear and I forget. I see and I remember. I do and I understand." -- Confucius |
![]() |
![]() |
#3 |
Senior Member
|
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 ![]() |
![]() |
![]() |
#4 |
Debian user
(Forum King) Join Date: Jan 2003
Location: Arch land
Posts: 4,918
|
With system plugin? I don't know... too much API calls since we're subclassing
* PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with MATE. * Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with MATE. ![]() |
![]() |
![]() |
#5 |
Senior Member
|
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? |
![]() |
![]() |
#6 |
Debian user
(Forum King) Join Date: Jan 2003
Location: Arch land
Posts: 4,918
|
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. * PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with MATE. * Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with MATE. ![]() |
![]() |
![]() |
#7 |
NSIS MUI Dev
Join Date: Nov 2001
Posts: 3,717
|
I don't think this is possible using the System plug-in. You have to write a new one.
|
![]() |
![]() |
#8 |
Senior Member
|
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...
![]() |
![]() |
![]() |
#9 |
Senior Member
|
![]() ![]() |
![]() |
![]() |
#10 |
Join Date: Sep 2003
Posts: 27,873
|
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 |
![]() |
![]() |
#11 |
Debian user
(Forum King) Join Date: Jan 2003
Location: Arch land
Posts: 4,918
|
Nice
![]() * PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with MATE. * Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with MATE. ![]() |
![]() |
![]() |
#12 |
Senior Member
|
huh
![]() ![]() |
![]() |
![]() |
#13 | |
Join Date: Sep 2003
Posts: 27,873
|
Quote:
![]() 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 ![]() what's the normal buffer limit for the included messagebox? -daz |
|
![]() |
![]() |
#14 |
Join Date: Sep 2003
Posts: 27,873
|
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 |
![]() |
![]() |
#15 |
Senior Member
|
wow!!!
I missed all this replies!!! How could I!!!??? Thanks DrO, gonna test this ![]() |
![]() |
![]() |
#16 | |
Join Date: Sep 2003
Posts: 27,873
|
Quote:
![]() 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 |
|
![]() |
![]() |
#17 |
Senior Member
|
And where's the update?
I looked in the Archive and couldn't find it. |
![]() |
![]() |
#18 | |
Join Date: Sep 2003
Posts: 27,873
|
Quote:
![]() 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 |
|
![]() |
![]() |
#19 |
Senior Member
|
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'? ![]() |
![]() |
![]() |
#20 |
Join Date: Sep 2003
Posts: 27,873
|
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 ![]() enjoy this people -daz |
![]() |
![]() |
#21 | |
Join Date: Sep 2003
Posts: 27,873
|
Quote:
![]() 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 |
|
![]() |
![]() |
#22 |
Senior Member
|
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. |
![]() |
![]() |
#23 | |||
Join Date: Sep 2003
Posts: 27,873
|
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). Quote:
Quote:
Quote:
![]() 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 ![]() 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 ![]() -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 |
|||
![]() |
![]() |
#24 |
Senior Member
|
Great!
I am very glad you liked my ideas ![]() |
![]() |
![]() |
#25 |
Join Date: Sep 2003
Posts: 27,873
|
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 |
![]() |
![]() |
#26 |
Senior Member
|
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 ![]() |
![]() |
![]() |
#27 | |
Join Date: Sep 2003
Posts: 27,873
|
Quote:
-daz |
|
![]() |
![]() |
#28 |
NSIS MUI Dev
Join Date: Nov 2001
Posts: 3,717
|
Can you create an archive page when it's finished?
|
![]() |
![]() |
#29 | |
Join Date: Sep 2003
Posts: 27,873
|
Quote:
![]() |
|
![]() |
![]() |
#30 | |
Join Date: Sep 2003
Posts: 27,873
|
Quote:
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 |
|
![]() |
![]() |
#31 | |
Senior Member
|
Quote:
![]() I attach the thingy. also, what's this "MB_ICONHAND" style? the nsis I use doesn't have it... ![]() |
|
![]() |
![]() |
#32 | |
Join Date: Sep 2003
Posts: 27,873
|
what OS are you using?
(checked the example and it is fine on NT4 and 2k) also is it the last messagebox that is failing? Quote:
-daz |
|
![]() |
![]() |
#33 | |
Join Date: Sep 2003
Posts: 27,873
|
@n0On3 - if you can, can you let me know what the crash error is please (picture?)
I'll have a look at the code tonight (haven't touched it for a few days) and i'll make sure that any potential parts that could cause a crash are catered for. Will try and get a newer version up for tomorrow which should hopefully fix things for you. Adding in parameter checks so that you can't do IDYES "blah" IDYES since it's not good having two 'Yes' buttons ![]() Quote:
![]() -daz |
|
![]() |
![]() |
#34 |
Join Date: Sep 2003
Posts: 27,873
|
added a page into the archive for the Customisable MessageBox plugin (thought a proper name would be good for it instead of 'MessageBox with more buttons'
![]() -daz [p.s. is it fine to just link to here for the downloads since i haven't anywhere to host files ![]() |
![]() |
![]() |
#35 | |
Senior Member
|
Quote:
and is the first messagebox that fails. Strange because it works in another silent installer I made. But in that other it always shows 4 buttons. This is the code: code: |
|
![]() |
![]() |
#36 | |
M.I.A.
[NSIS Dev, Mod] Join Date: Oct 2001
Location: Israel
Posts: 11,343
|
Quote:
NSIS FAQ | NSIS Home Page | Donate $ "I hear and I forget. I see and I remember. I do and I understand." -- Confucius |
|
![]() |
![]() |
#37 |
Join Date: Sep 2003
Posts: 27,873
|
give this version a try - have altered the handling of one or two strings internally so hopefully it won't crash (had not fully checked the module handle for a "" situation).
also included two compiled versions (normal and silent) which work on my machine at least ![]() note: long button text handling is still fudged (got to get full limit checking working still) note 2: just looking at the function call, the "IDCANCEL" should be just IDCANCEL (no "'s around it) if you want the button text to be 'cancel' ![]() @n0On3: will test that later. i tested your file on NT4 and it worked (will check later on my machine under both oses) @kichik: will pm it once it's working fully ![]() -daz |
![]() |
![]() |
#38 |
Senior Member
|
ok, I won't use "IDCANCEL"
![]() please, can some moderator edit my post and make it not soooooooo wide? and... doesn't anybody know when this forum decides to create a second page??? |
![]() |
![]() |
#39 | |
Join Date: Sep 2003
Posts: 27,873
|
Quote:
![]() (also it looks neater without the ""s for the predefined texts i think) tested your file under 98 and 2k - crashed under 98 ![]() found the problem (was only related to silent installers!) so new none crashing version is attached ![]() -daz ps issue is that with the silent installer it does not have a window title and so my code for that was incorrectly handling a "" for the caption (so it was the second messagebox crashing ![]() ![]() |
|
![]() |
![]() |
#40 |
Moderator
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
|
I currently know nothing about win32 programming; you obviously must know quite a bit!
Good work!! -Stu ![]() |
![]() |
![]() |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|