Using the exclamation icon from AfxMessageBox in my own message box

I have created my own dialog that will serve as a custom message box.  But I need to steal the exclamation image from the standard message box.  I took a screen shot, pasted into paint, and make a .bmp file that contains only the triangular exclamation point image (and the white box around it).  The problem is this white box.  I need to put this bitmap on my dialog, on a button, a picture box, or a CStatic.  I don't really care which control, to be honest.  But I can't seem to get rid of that white box around the bitmap.  Any thoughts?
clintMonAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

DanRollinsCommented:
Make it into an icon instead.  You can usually put an ICON resource in the same places you can put a BMP... just use the Resource Editor to set the white part as the background color.

-- Dan
clintMonAuthor Commented:
OK.  In my res folder in my project, i need to have the exclamation point image saved as an icon (an .ico extension).  How do I make my exclamation point image into an .ico file?
DanRollinsCommented:
You don't need an .ico file -- you can create one from scratch

1) Open PBrush and create a 32x32 color image
2) Press Ctrl+A and Ctrl+C  (copy the entire thing to the clipboard)
3) In VC++ IDE, click the Resources tab.  
4) Locate "<yourProject> resources"
5) right-click it and select "Insert..."
6) Select "Icon" and click [New]
7) Press Ctrl+V  (paste the 32x32 bitmap from the clipboard)

You might be all done... by default, anything that was white in the bitmap will be mapped to that blue-greenish color that (in the Icon Editor) means "the transparent background"

Close the icon editor window.  If you want, you can "rename" the icon to give it a different ID (other than IDI_ICON1) by right-clicking it in the tree and selecting Properties.  If you really want to own a lovely .ICO file, you can right-click it in the tree and select "Export..."

There is lots of additional info in the online help for the resource editor that comes with Visual C++

-- Dan
Amazon Web Services

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

jkrCommented:
>>But I need to steal the exclamation image from the standard message box

Why not just loading it from the DLL it resides in using 'LoadIcon()'? That also prevents copyright issues.
jkrCommented:
*Argh*, even *way* easier:

HICON hiExclamationMark = LoadIcon(NULL,IDI_EXCLAMATION);

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jkrCommented:
BTW, if that is really a message box, why aren't you using

MessageBox(NULL,"Test text","Caption",MB_ICONEXCLAMATION | MB_OK);

in the 1st place.
clintMonAuthor Commented:
Thanks jkr, et al.  Worked like a charm.   I knew there had to be a cinch way to do this, even though C++ sometimes makes mountains out of molehills.

My exact WORKING code, for anyone else who wants to know, is:

// put a picture control (CStatic) on the dialog;

// associate a variable with it:
CStatic      m_picture;

//In OnInitDialog(), get an icon handle to the desired image (in my case, this was the exclamation point icon on the standard windows message box)
HICON hiExclamationMark = LoadIcon(NULL,IDI_EXCLAMATION);      

//load icon into the desired control (in my case, the picture control (CStatic))
m_picture.SetIcon(hiExclamationMark);      

That's it.




clintMonAuthor Commented:
One more thing:

>> BTW, if that is really a message box, why aren't you using MessageBox(NULL,"Test text","Caption",MB_ICONEXCLAMATION | MB_OK); in the 1st place?

Because I needed to change the text on the dialog's buttons (from "Yes", "No", or "OK", "Cancel", to "Delete" and "Convert"
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.