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?
 
jkrCommented:
*Argh*, even *way* easier:

HICON hiExclamationMark = LoadIcon(NULL,IDI_EXCLAMATION);
0
 
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
0
 
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?
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

 
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
0
 
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.
0
 
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.
0
 
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.




0
 
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"
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.