News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Custom MessageBox Button Text

Started by dedndave, August 16, 2011, 11:16:09 PM

Previous topic - Next topic

dedndave

i wanted something a little different
i suppose it isn't that hard to just write a dialog box, but....



i followed a little code by J Brown, circa 2002, written in C
http://www.catch22.net/tuts/custom-messagebox

here we go - i found the original thread where Erol pointed us to it   :P
http://www.masm32.com/board/index.php?topic=13745.msg108004#msg108004

i am going to play some more to see if i can change the icon
if so, you can select the MessageBox parameter icon to pick the sound you want
then, pick a different icon, as desired

hutch--

Dave,

The icon is easy, use MessageBoxIndirect().
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

dedndave

i noticed that function, Hutch
but i didn't see a way to "disconnect" the sound from the icon
i suppose you could try MB_ICONQUESTION in the style member to elimiate the sound
then, try setting the MB_USERICON flag to specify an icon
seems like there might be a confilct, there   :P

what i noticed about using a CBT hook was that you got the handle to the dialog window in wParam
should be able to do a lot with that
SetWindowLong, if nothing else
that seems to apply to a title bar icon, though

after a certain point, you may as well make your own dialog box   :bg

the code posted is small enough to make it worth while

ToutEnMasm


If really you want a special messagebox,the better way is to made it.
Source code could be just pick up on  sample:
http://www.masm32.com/board/index.php?topic=17217.msg144170#msg144170

after that,you have the choice to made it classic (using system resource) or not.


hutch--

Dave,

It takes the same style as an ordinary message box but you specify a resource icon instead. Then use the button combination you want and if you have code to do it, change the text then.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

dedndave

ok - after mashing all the buttons   :P

much to my surprise, all the standard message box icons are associated with a sound
of course, there has to be one selected in your current theme to hear them all - lol

;MB_ICONSTOP         10h  Critical Stop
;MB_ICONERROR        10h
;MB_ICONHAND         10h
;
;MB_ICONQUESTION     20h  Question
;
;MB_ICONEXCLAMATION  30h  Exclamation
;MB_ICONWARNING      30h
;
;MB_ICONINFORMATION  40h  Program Error
;MB_ICONASTERISK     40h


in my version of XP, the standard theme has no sound selected for Question
so, i thought that icon selection had no sound associated with it
i created a temporary theme with all the sounds fired up to test them

now, as for MessageBoxIndirect...
in addition to the standard MB_ICON* selection constants, they allow the use of MB_USERICON in the dwStyle member
if you select MB_USERICON with one of the standard icons, both are ignored and no icon is displayed
you can select MB_USERICON, set hInstance to NULL, and use one of the system icons
if you use MB_USERICON, no sound is associated with the MessageBox
in other words, if you want a sound and a different icon, you'd have to use PlaySound or a similar function

you can play themed sounds by using SND_ALIAS for the PlaySound fdwSound parameter
and you have to use a pointer to a theme-name string that matches those in the registry for the pszSound parm
        INVOKE  PlaySound,chr$('SystemAsterisk'),NULL,SND_ALIAS

a partial list - i am sure there are others...
AppGPFault
CCSelect
Close
CriticalBatteryAlarm
DeviceConnect
DeviceDisconnect
DeviceFail
LowBatteryAlarm
MailBeep
Maximize
MenuCommand
MenuPopup
Minimize
Open
PrintComplete
RestoreDown
RestoreUp
ShowBand
SystemAsterisk
SystemExclamation
SystemExit
SystemHand
SystemNotification
SystemQuestion
SystemStart
WindowsLogoff
WindowsLogon

dedndave

i do still have one question
some of you guys with non-English versions of windows can help me out   :P

with MessageBoxIndirect, you can specify a language
the documentation is a little unclear about exactly what LANG_NEUTRAL (0) means
i am guessing that means generic English
here is a test program to find out....

EDIT
it is the language on the buttons that i am interested in...

ToutEnMasm


Ok,
The text of the buttons are in french for me.

dedndave

thanks Yves   :U

i see that PlaySound will also play a few of the system sounds by way of ID using SND_ALIAS_ID
;SND_ALIAS_SYSTEMEXCLAMATION  SystemExclamation
;SND_ALIAS_SYSTEMASTERISK     SystemAsterisk
;SND_ALIAS_SYSTEMQUESTION     SystemQuestion
;SND_ALIAS_SYSTEMDEFAULT      SystemDefault
;SND_ALIAS_SYSTEMEXIT         SystemExit
;SND_ALIAS_SYSTEMHAND         SystemHand
;SND_ALIAS_SYSTEMSTART        SystemStart
;SND_ALIAS_SYSTEMWELCOME      SystemWelcome


dedndave

thanks Erol
that looks similar to mine
we must have used the same guy as reference   :P

i am trying to learn some of the finer points about MessageBoxIndirect
making kind of a "super MB wrapper"

dedndave

ok - another question   :bg

MessageBoxIndirect - MSGBOXPARAMS Structure

lpszIcon - LPCTSTR

Identifies an icon resource. This parameter can be either a null-terminated
string or an integer resource identifier passed to the MAKEINTRESOURCE macro.


i am trying to figure out how a "string" might identify an icon, other than if it were a file name


baltoro

...Assume that I'm totally WRONG about this,...but,...
The LPCTSTR type in C++ is just a pointer to a string constant. In assembly, you can ignore the constant, and, yes,...it's the address of the file name. Using the MAKEINTRESOURCE macro is easier,...you just provide the assigned identifier from your resource file. What i don't know is,...can you INVOKE a C++ language macro from your assembly langusge program ???

If you read: LoadIcon Function, there is a list of predefined system icons and their ID values.
Baltoro

dedndave

oh yah - i am aware of the standard icons
MAKEINTRESOURCE is totally a C thing - not necessary in ASM
in C, all it does is cast a 16-bit integer as a 32-bit integer

i am just trying to make a flexible message box routine
i am combining the custom buttons in the original post with MessageBoxIndirect
put the whole thing in a wrapper and make it as easy to use as is practical   :lol

i still have a few wrinkles to work out, but....

Gunner

If I click the possibly button, what happens?
~Rob (Gunner)
- IE Zone Editor
- Gunners File Type Editor
http://www.gunnerinc.com