CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Nov 2011
    Location
    India
    Posts
    333

    Auto-close MSG box - Without Button and Title

    Hi,

    I referred Auto-close message box.

    But i like to view the message box with out title bar and buttons. Is possible?
    Regards,

    SaraswathiSrinath

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Auto-close MSG box - Without Button and Title

    Sure, modify the code to remove the title style and hide the buttons.

  3. #3
    Join Date
    Nov 2011
    Location
    India
    Posts
    333

    Re: Auto-close MSG box - Without Button and Title

    Quote Originally Posted by Arjay View Post
    Sure, modify the code to remove the title style and hide the buttons.
    set its Border value to None or set Title bars value to false makes empty dialog box.

    Dialog Frame, Child, Popup, and Overlapped characteristics have title bar.
    Its value like WS_DLGFRAME, WS_CHILE, WS_POPUP, WS_OVERLAPPED.

    NONE Style sets empty title bar. but i don't know how to set.
    Regards,

    SaraswathiSrinath

  4. #4
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Auto-close MSG box - Without Button and Title

    Just create a test program with a regular dialog box and mess with the styles until you get it right. Then make the changes to your program.

    To find which styles, do a search in bing or google for "Modal dialog in MFC without a title bar"

  5. #5
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,234

    Re: Auto-close MSG box - Without Button and Title

    I would like to suggest a more reliable method for customizing a message box:
    1. before calling ::MessageBox, set a CBT Hook.
    2. in the CBT hook procedure, catch the creation of the message box and subclass it (replace the default dialog procedure with your own, application-defined procedure);
    3. in the application-defined dialog procedure, handle the messages you want for customizing it (for example, handle WM_INITDIALOG for modifying the styles, adding and/or removing child controls, setting a timer for auto-close, and so on.

    You can find an example using raw-WinAPI in this Codeguru article: Fancy Custom MessageBox.

    If using MFC, download, have a look and eventually adapt according to your own needs the demo application from this article: AfxMessageBox with Auto-close

    Here is an example of how can remove the caption and hide "OK" button:
    Code:
    LRESULT CAutoMessageBox::OnInitDialog(WPARAM wParam, LPARAM lParam)
    {
        // Remove caption
        ModifyStyle(WS_CAPTION, 0);
        // hide "OK" button
        GetDlgItem(IDOK)->ShowWindow(SW_HIDE);
        // other: set timer for auto-close, resize, and so on.
        // ...
        // ...
     
        return TRUE;
    }
    No sweat!
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured