CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    May 1999
    Posts
    3

    How can I capture the window quit message?

    In the following code, I want to capture the window quit or close message. but I cannot get it using the following code. How can I do?

    Thanks.

    void CEx1Dlg::OnStart2()
    {
    // TODO: Add your control notification handler code here
    int i = 0;
    BOOL ret;
    MSG msg;
    while(1)
    {
    ret = ::PeekMessage(&msg, NULL, 0, 0, PM_REMOVE);
    if(ret)
    {
    if((msg.message == WM_QUIT) || (msg.message == WM_DESTROY) || (msg.message == WM_CLOSE))
    {
    AfxMessageBox("Quit message received!");
    break;
    }

    TRACE("MSG :%d\n", msg.message);
    ::TranslateMessage(&msg);
    :ispatchMessage(&msg);
    }
    i++;
    }
    }



  2. #2
    Join Date
    Apr 1999
    Posts
    16

    Re: How can I capture the window quit message?

    Why you capture the message in your OnStart2()
    function,you can override the window's WndProc()
    function,in it you can judge the message.Try it,
    you will find it works.


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