Old 12th September 2003, 09:37   #1
n0On3
Senior Member
 
n0On3's Avatar
 
Join Date: Jan 2001
Location: Barcelona
Posts: 314
Send a message via ICQ to n0On3
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?
n0On3 is offline  
Old 12th September 2003, 10:02   #2
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
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
kichik is offline  
Old 12th September 2003, 23:05   #3
n0On3
Senior Member
 
n0On3's Avatar
 
Join Date: Jan 2001
Location: Barcelona
Posts: 314
Send a message via ICQ to n0On3
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
n0On3 is offline  
Old 12th September 2003, 23:23   #4
Joel
Debian user
(Forum King)
 
Joel's Avatar
 
Join Date: Jan 2003
Location: Arch land
Posts: 4,917
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.
Joel is offline  
Old 13th September 2003, 00:31   #5
n0On3
Senior Member
 
n0On3's Avatar
 
Join Date: Jan 2001
Location: Barcelona
Posts: 314
Send a message via ICQ to n0On3
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?
n0On3 is offline  
Old 14th September 2003, 02:50   #6
Joel
Debian user
(Forum King)
 
Joel's Avatar
 
Join Date: Jan 2003
Location: Arch land
Posts: 4,917
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.
Joel is offline  
Old 14th September 2003, 10:07   #7
Joost Verburg
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.
Joost Verburg is offline  
Old 14th September 2003, 21:28   #8
brainsucker
Senior Member
 
brainsucker's Avatar
 
Join Date: Sep 2002
Location: Minsk, Belarus
Posts: 190
Send a message via ICQ to brainsucker
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...
brainsucker is offline  
Old 15th September 2003, 10:31   #9
n0On3
Senior Member
 
n0On3's Avatar
 
Join Date: Jan 2001
Location: Barcelona
Posts: 314
Send a message via ICQ to n0On3


n0On3 is offline  
Old 18th September 2003, 15:18   #10
DrO
 
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
DrO is offline  
Old 18th September 2003, 19:09   #11
Joel
Debian user
(Forum King)
 
Joel's Avatar
 
Join Date: Jan 2003
Location: Arch land
Posts: 4,917
Nice Thanks dude...


* 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.
Joel is offline  
Old 18th September 2003, 21:17   #12
brainsucker
Senior Member
 
brainsucker's Avatar
 
Join Date: Sep 2002
Location: Minsk, Belarus
Posts: 190
Send a message via ICQ to brainsucker
huh Windows Hooks Nice idea!
brainsucker is offline  
Old 19th September 2003, 12:44   #13
DrO
 
Join Date: Sep 2003
Posts: 27,873
Quote:
Originally posted by brainsucker
huh Windows Hooks Nice idea!
that's what i thought to

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
DrO is offline  
Old 19th September 2003, 14:18   #14
DrO
 
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
DrO is offline  
Old 19th September 2003, 22:51   #15
n0On3
Senior Member
 
n0On3's Avatar
 
Join Date: Jan 2001
Location: Barcelona
Posts: 314
Send a message via ICQ to n0On3
wow!!!

I missed all this replies!!!

How could I!!!???

Thanks DrO, gonna test this
n0On3 is offline  
Old 21st September 2003, 11:39   #16
DrO
 
Join Date: Sep 2003
Posts: 27,873
Quote:
Originally posted by n0On3
wow!!!

I missed all this replies!!!

How could I!!!???

Thanks DrO, gonna test this
don't worry about it

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
DrO is offline  
Old 21st September 2003, 20:31   #17
n0On3
Senior Member
 
n0On3's Avatar
 
Join Date: Jan 2001
Location: Barcelona
Posts: 314
Send a message via ICQ to n0On3
And where's the update?

I looked in the Archive and couldn't find it.
n0On3 is offline  
Old 22nd September 2003, 12:41   #18
DrO
 
Join Date: Sep 2003
Posts: 27,873
Quote:
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
DrO is offline  
Old 23rd September 2003, 03:45   #19
n0On3
Senior Member
 
n0On3's Avatar
 
Join Date: Jan 2001
Location: Barcelona
Posts: 314
Send a message via ICQ to n0On3
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'?
n0On3 is offline  
Old 23rd September 2003, 14:21   #20
DrO
 
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 (may take a while with other things on at the moment)

enjoy this people

-daz
DrO is offline  
Old 24th September 2003, 14:52   #21
DrO
 
Join Date: Sep 2003
Posts: 27,873
Quote:
auto-resize buttons seems nice
well 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
DrO is offline  
Old 24th September 2003, 17:35   #22
n0On3
Senior Member
 
n0On3's Avatar
 
Join Date: Jan 2001
Location: Barcelona
Posts: 314
Send a message via ICQ to n0On3
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.
n0On3 is offline  
Old 25th September 2003, 12:51   #23
DrO
 
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:
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

Quote:
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.
Quote:
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
DrO is offline  
Old 25th September 2003, 15:16   #24
n0On3
Senior Member
 
n0On3's Avatar
 
Join Date: Jan 2001
Location: Barcelona
Posts: 314
Send a message via ICQ to n0On3
Great!

I am very glad you liked my ideas
n0On3 is offline  
Old 26th September 2003, 12:31   #25
DrO
 
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
DrO is offline  
Old 29th September 2003, 02:41   #26
n0On3
Senior Member
 
n0On3's Avatar
 
Join Date: Jan 2001
Location: Barcelona
Posts: 314
Send a message via ICQ to n0On3
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
n0On3 is offline  
Old 29th September 2003, 10:41   #27
DrO
 
Join Date: Sep 2003
Posts: 27,873
Quote:
I found that I can't use the installer icon when the installer is set to silent
will 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
DrO is offline  
Old 29th September 2003, 10:49   #28
Joost Verburg
NSIS MUI Dev
 
Join Date: Nov 2001
Posts: 3,717
Can you create an archive page when it's finished?
Joost Verburg is offline  
Old 29th September 2003, 11:52   #29
DrO
 
Join Date: Sep 2003
Posts: 27,873
Quote:
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 )
DrO is offline  
Old 30th September 2003, 10:42   #30
DrO
 
Join Date: Sep 2003
Posts: 27,873
Quote:
I found that I can't use the installer icon when the installer is set to silent
had 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
DrO is offline  
Old 3rd October 2003, 10:50   #31
n0On3
Senior Member
 
n0On3's Avatar
 
Join Date: Jan 2001
Location: Barcelona
Posts: 314
Send a message via ICQ to n0On3
Quote:
Originally posted by DrO
[B]had a check of the code and the icon part works fine in a silent installer.
You mean that you could use the icon when silent installer in the messagebox? I used your example and now, not only it's not showed but even crashes

I attach the thingy.



also, what's this "MB_ICONHAND" style? the nsis I use doesn't have it...
Attached Files
File Type: zip crash.zip (23.9 KB, 662 views)
n0On3 is offline  
Old 3rd October 2003, 11:39   #32
DrO
 
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:
messagebox::show MB_TOPMOST|MB_DEFBUTTON2|MB_RIGHT "look at me a title" \
"" \
"and for a messagebox that will show an icon... )$\n" "ah go on if you dare" IDYES IDYES2
with the second line, to get the installer icon it should be "0,103" instead of "" - typo on my part (was trying to get that test version done beofre i left for work)

-daz
DrO is offline  
Old 3rd October 2003, 15:43   #33
DrO
 
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:
also, what's this "MB_ICONHAND" style? the nsis I use doesn't have it...
magic that is it is just the stop sign icon but using a different name (throw back to Windows 3.x before 95 came along and they altered the defined names that's all, check here)

-daz
DrO is offline  
Old 3rd October 2003, 19:10   #34
DrO
 
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 ]
DrO is offline  
Old 4th October 2003, 07:03   #35
n0On3
Senior Member
 
n0On3's Avatar
 
Join Date: Jan 2001
Location: Barcelona
Posts: 314
Send a message via ICQ to n0On3
Quote:
Originally posted by DrO
[B]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?
sorry, I left that info. I use win98se. Does the compiled exe work in your 2k?

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:
MessageBox::Show MB_ICONQUESTION "Can't Move, Copy instead?" "" \
`We can't move through different drives.$\nBut we can copy and \
delete if no errors` "Copy && Delete" "Copy" "IDCANCEL"

Attached Images
File Type: png crash.png (7.1 KB, 633 views)
n0On3 is offline  
Old 4th October 2003, 12:05   #36
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
Quote:
Originally posted by DrO
[p.s. is it fine to just link to here for the downloads since i haven't anywhere to host files ]
It can be put on the Archive too. Just e-mail the file to an Archive admin and we'll upload it.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline  
Old 4th October 2003, 13:57   #37
DrO
 
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
DrO is offline  
Old 4th October 2003, 15:32   #38
n0On3
Senior Member
 
n0On3's Avatar
 
Join Date: Jan 2001
Location: Barcelona
Posts: 314
Send a message via ICQ to n0On3
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???
n0On3 is offline  
Old 5th October 2003, 11:51   #39
DrO
 
Join Date: Sep 2003
Posts: 27,873
Quote:
Originally posted by n0On3
ok, I won't use "IDCANCEL"
ignore what i said about that, was half asleep at work and not remembering that the "" are stripped before being passed to the plugin
(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 ) - i just can't code at times
DrO is offline  
Old 5th October 2003, 12:30   #40
Afrow UK
Moderator
 
Afrow UK's Avatar
 
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
Afrow UK is offline  
Closed Thread
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