MsgWaitForMultipleObjectsEx and win32gui

2004-08-06
2004-08-10
  • Rafal Dzbek

    Rafal Dzbek - 2004-08-06

    I use overlapped I/O in my MFC/WTL application. The application has only one main thread. To be able trap I/O events I must call MsgWaitForMultipleObjectsEx instead of Get/PeekMessage.

    Is there any way to override kind of win32guis PumpMessage function, which makes possible dispatch on windows system objects like events objects?

    Here is code snippet how it works in MFC application:

    BOOL
    CComServ32App::DoPumpMessage(DWORD)
      {
      DWORD dwWakeMask=QS_ALLINPUT;
      DWORD dwFlags=MWMO_ALERTABLE;
      const HANDLE handles[]={my_hConnectEvent, };
      enum {nCount= NELEMS(handles), };
      assert(nCount < MAXIMUM_WAIT_OBJECTS);

      DWORD dwWait=MsgWaitForMultipleObjectsEx(nCount,handles, INFINITE, wWakeMask, dwFlags);

      switch (dwWait)
        {
        // The wait conditions are satisfied by a completed connect
        // operation.
        case 0:
          {
          // If an operation is pending, get the result of the connect operation.
          ...
            BOOL fSuccess = GetOverlappedResult(
              hPipe,     // pipe handle
              &my_oConnect, // OVERLAPPED structure
              &cbRet,    // bytes transferred
              FALSE);    // does not wait
    case WAIT_OBJECT_0 + nCount:
          //regular windows message - forward to GetMessage/DispatchMessage
          ...
    case WAIT_IO_COMPLETION:
          ...

     
    • John Torjo

      John Torjo - 2004-08-10

      I've only once or twice used MsgWaitForMultipleObjects.

      Anyway, I think if you really want ;), you can do it.

      The place to do it is method:

      signal window_base::wait( std::vector<signal> signals, unsigned int timeout_ms);

      (you'll find it in source file win32gui/src/window.cpp, line 192).

      You can manually modify the source file, and re-build the library.

      Note: if you succeed, please let me know, and I'll add an extra function for this. If you need any help, you can contact me directly - john@torjo.com

      p.s. don't forget to get the latest win32gui (1.3).

       

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks