Question

Hi If any one knows how to use in-place warning message in MFC could you share info. Is there a way to use it or is there any control we can use directly in mfc.

In-Place warning message: A warning message with appropriate icon along with warning message, will be displayed with in the same dialog.

I found some info about in-place message in msdn

InPlace message in msdn glossary

Different messages

Please share information.

Regards

Haranadh

Was it helpful?

Solution

From your comment, it appears that you're referring to this as an in-place message:

   

Ironically, of course, that's labeled as the incorrect example on the MSDN page that you link to. It's specifically recommended that you provide more specific advice, such as securing the projector with a password so that the presentation is not visible to unintended viewers. Putting that aside, however...

This is quite easy to implement in MFC. It's done simply with two STATIC controls, one on the left that displays an icon (in this case, a warning triangle) and the longer one on the right that displays static text (the warning message itself). If you're using the dialog editor to create your window, it's a simple matter of dragging the two controls to the dialog window and arranging them accordingly. There isn't a single control that encapsulates this functionality, but it's silly to expect that there would be, considering that doing it with two separate static controls is already so straightforward.

To load built-in icons such as the warning triangle shown above, you can use the LoadStandardIcon function and specify IDI_WARNING as the icon name. The complete list of values is available here. Obviously you can load any icon of your choosing as well; just add it to your project's resources.

Since you will presumably want to display the warning message only when it's applicable, you will need to programmatically hide and show the two controls depending on action taken by the user in your dialog. The standard ShowWindow member function makes this a trivial task. Call it on the two static controls, passing SW_SHOW as its argument if you want the warning message to be visible. Otherwise, you can specify SW_HIDE to hide the control.

OTHER TIPS

As an alternative to what you are trying to do; you could place your message in a dialog:

int nResult = AfxMessageBox("Save changes to Current Job?", MB_YESNO);

    if (nResult == IDYES)
    {
        OnFileSave();
    } 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top