CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8

Thread: Message Box

  1. #1
    Join Date
    Jul 2008
    Posts
    50

    Message Box

    I would like to create a message box that appear for a few seconds and closed by itself without the users interfering. How am I going about doing that?

    Thanks in advance.

  2. #2
    Join Date
    Sep 2008
    Posts
    11

    Re: Message Box

    One way is to create your own dialog as a message box.
    In OnInitdialog start a timer, initialize the timer.
    handle OnTimer, which will be called when timer is over where dialog will destroy itself.

  3. #3
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,125

    Re: Message Box

    That is the most common approach and is quite effective. Just make sure you properly handle the possibility that the user may close the dialog BEFORE the timer expires!!!!!
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  4. #4
    Join Date
    Dec 2006
    Location
    New York Brooklyn
    Posts
    120

    Re: Message Box

    or use a normal MessageBox and PostMessage the Enter Key

    HWND hwnd= FindWindow(messagebox_classname_IDK, NULL);
    PostMessage(hwnd, WM_KEYDOWN, VK_ENTER, 0);

    use Winspector Spy or Micrsoft Spy++
    make the messagebox trigger then look at the messages to find the classname
    Last edited by sspoke; October 9th, 2008 at 10:27 PM.

  5. #5
    Join Date
    Jan 2008
    Posts
    178

    Re: Message Box

    Why don't you use the well-known MS sample ?!
    This has been answered thousands of times for 18 years on google groups...

  6. #6
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,125

    Re: Message Box

    Quote Originally Posted by sspoke
    or use a normal MessageBox and PostMessage the Enter Key

    HWND hwnd= FindWindow(messagebox_classname_IDK, NULL);
    PostMessage(hwnd, WM_KEYDOWN, VK_ENTER, 0);

    use Winspector Spy or Micrsoft Spy++
    make the messagebox trigger then look at the messages to find the classname
    1) Please use code tags!!!!!

    2) You STILL need a timer to execute this code.

    3) the race condition I mentioned earlier may occur.

    4) It is a more complicated solution that neccessary.

    5) It is more tightly bound to the platform API's than necessary.
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  7. #7
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: Message Box

    Quote Originally Posted by sspoke
    or use a normal MessageBox and PostMessage the Enter Key

    HWND hwnd= FindWindow(messagebox_classname_IDK, NULL);
    PostMessage(hwnd, WM_KEYDOWN, VK_ENTER, 0);

    use Winspector Spy or Micrsoft Spy++
    make the messagebox trigger then look at the messages to find the classname
    How does that keep the message box open for a certain period of time?

  8. #8
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: Message Box

    Just to continue fred100's post: How to create a timed message box
    Victor Nijegorodov

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