CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    May 1999
    Location
    New Jersey, USA
    Posts
    10

    Usage of PeekMessage().....

    I'm trying to use PeekMessage() to search thro' the message queue for a dialog and I want to break-off the PeekMessage() loop on encountering a specific message (e.g , WM_CLOSE). How should I do this..??

    while( PeekMessage())
    {
    if the message is WM_CLOSE, fall off this loop
    }

    //control should come here.....

    Any help is greatly appreciated. Any other better ideas are welcome too.....

    Thanx
    Ram


  2. #2
    Guest

    Re: Usage of PeekMessage().....

    I use th following function for my dialog:

    BOOL WorkingDlg::IsCancelled()
    {
    MSG msg;

    if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
    {

    if (msg.message == WM_QUIT ||
    msg.message == WM_CLOSE ||
    msg.message == WM_DESTROY
    )
    m_bCancel = TRUE;
    TranslateMessage(&msg);// Translates virtual key codes
    DispatchMessage(&msg); // Dispatches message to window
    }

    return m_bCancel;
    }

    This function will be called by other program to see if user clicks the "Cancel" button or close the dialog.
    Hope this will help. Good luck.

    Allen


  3. #3
    Join Date
    May 1999
    Location
    New Jersey, USA
    Posts
    10

    Re: Usage of PeekMessage().....

    That helped. Thanx a lot.


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