Click here to Skip to main content
12,751,306 members (34,000 online)
Click here to Skip to main content
Add your own
alternative version


22 bookmarked
Posted 22 Feb 2000

A Wrapper for MessageBoxIndirect

, 22 Feb 2000
Rate this:
Please Sign up or sign in to vote.
A class which encapsulates MessageBoxIndirect.
  • Download demo project - 16 Kb
  • Download source files - 2 Kb
  • Sample Image - messagebox.gif


    Sometimes you might wish you could use other icons in a message box apart from the ones Windows gives you, or you might want to have more control over how your message box, specify which language to use, etc. Well, there is a way to do all this using the little-known API call MessageBoxIndirect.

    Here is a class which encapsulates MessageBoxIndirect (actually, it inherits from the MESSAGEBOXPARAMS structure which you pass to MessageBoxIndirect). You can use it like an MFC CDialog, although there are no dependencies on MFC.


    1. Declare a CMessageBox object.
    #include "MessageBox.h"
    CMessageBox box;


    CMessageBox box(hWnd, "My Text", "My Caption", MB_OK);

    2. Initialize it (If you are just displaying a standard Message Box you can skip this step


    3. Call DoModal.

    if(box.DoModal() == MB_OK)
    	// Do something here
    	// Do something else

    That's it! <p>


    This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

    A list of licenses authors might use can be found here


    About the Author

    Peter Kenyon
    Web Developer
    New Zealand New Zealand
    No Biography provided

    You may also be interested in...

    Comments and Discussions

    QuestionSetFont Pin
    Hwewet23-Aug-11 4:39
    memberHwewet23-Aug-11 4:39 
    GeneralBest way to handle help messages... Pin
    James R. Twine23-Feb-00 7:44
    sussJames R. Twine23-Feb-00 7:44 

    General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

    Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

    Permalink | Advertise | Privacy | Terms of Use | Mobile
    Web02 | 2.8.170215.1 | Last Updated 23 Feb 2000
    Article Copyright 2000 by Peter Kenyon
    Everything else Copyright © CodeProject, 1999-2017
    Layout: fixed | fluid