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

Thread: mscomm

  1. #1
    Join Date
    Apr 1999
    Posts
    1

    mscomm

    I am using MFC MSComms control to receive data from the serial port. I want a function to receive information from the serial port before it returns (wait for serial port events). I know that in Visual Basic DoEvents() method can be used to yield conrol to the operating system giving it a chance to process serial port events. What is the equivalent process
    in MFC C++.

    Thanks in anticipation
    Farshad.


  2. #2
    Join Date
    Apr 1999
    Posts
    3

    Re: mscomm

    I am not aware of any function in MFC like VB's DoEvents.
    If I understand what it is you want to do, you should probably use a worker thread to read the serial port.

    Another approach is to override CWinApp::OnIdle() or you could (but I wouldn't recommend) create you own message pump.



  3. #3
    Join Date
    Apr 1999
    Posts
    6

    Re: mscomm

    MFC used to have straight analog of DoEvents in Win 16 API: PumpWaitingMessages.
    You can use not documented Afx PumpMessage in Win 32 in the following manner:
    void MyClass::PumpWaitingMessages()
    {
    MSG msg;
    while( PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ))
    {
    // If it is your message go ahead and proceed
    if(( msg.message == WM_CHAR ) && ( msg.wParam == VK_ESCAPE ))
    {
    OnCancel();
    }
    AfxGetApp()->PumpMessage();
    }
    }



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