none
Windows Message Pump - What is it

    Question

  •  

    It's something i've never even really heard of, except sometimes when debugging i get a crazy exception about not pumping, click continue and all is well.

     

    What is the 'messsage pump', what's it for, when do I use it.

     

    Cheers

    Monday, October 22, 2007 4:05 PM

Answers

  • In general, Windows programs are essentially message handlers.  Applications, the OS and hardware all generate windows "messages" that an application listens for and reacts to.

     

    Examples are key clicks (key down & key up), mouse move, paint and dozens of others.

     

    A Win32 message pump typically looks something this and was the heart of win32 programming.:

     

    MSG msg;
    while(GetMessage(&msg, hwnd, 0, 0))
    {
        TranslateMessage(&msg);
        DispatchMessage(&msg);

     

        // do stuff

    }

     

    Today, the C# language tends to abstract the message pump away but you can still get to it.

     

            protected override void WndProc(ref Message m)
            {
                base.WndProc(ref m);

      // do stuff

            }

    Monday, October 22, 2007 8:33 PM

All replies

  • In general, Windows programs are essentially message handlers.  Applications, the OS and hardware all generate windows "messages" that an application listens for and reacts to.

     

    Examples are key clicks (key down & key up), mouse move, paint and dozens of others.

     

    A Win32 message pump typically looks something this and was the heart of win32 programming.:

     

    MSG msg;
    while(GetMessage(&msg, hwnd, 0, 0))
    {
        TranslateMessage(&msg);
        DispatchMessage(&msg);

     

        // do stuff

    }

     

    Today, the C# language tends to abstract the message pump away but you can still get to it.

     

            protected override void WndProc(ref Message m)
            {
                base.WndProc(ref m);

      // do stuff

            }

    Monday, October 22, 2007 8:33 PM
  •  

    C# does not have message loop, message pump.
    In Namespace: System.Windows.Forms, System.Windows.Forms.Application class replace the message loop.
    This class provides static methods and properties to manage an application such as methods to start, stop
    application, process windows messages and properties to get information about an application.
     
    I need a kickstart on C#, correct me if i am wrong.
    1) It does not have InitInstance as in C++
    2) It does not have message mapping as in C++
    3) It does not have COM mapping as in C++
    4) It does not have a pointer called m_pMainWnd pointer to the main app Wnd
     
    In C#, everything is wrap inside, thus you can say that C# is not as flexible as C++.
    Wednesday, April 23, 2008 12:58 AM