Click here to Skip to main content
15,887,214 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Moving project to a Unix Platform Pin
David Crow17-Apr-08 6:53
David Crow17-Apr-08 6:53 
GeneralRe: Moving project to a Unix Platform Pin
Andy20218-Apr-08 0:44
Andy20218-Apr-08 0:44 
GeneralMAPIFolderPtr olItemType Pin
pnpfriend17-Apr-08 5:30
pnpfriend17-Apr-08 5:30 
GeneralProgrammatic send copy command (CTRL+C) Pin
yytg17-Apr-08 4:10
yytg17-Apr-08 4:10 
GeneralRe: Programmatic send copy command (CTRL+C) Pin
led mike17-Apr-08 4:24
led mike17-Apr-08 4:24 
QuestionRe: Programmatic send copy command (CTRL+C) Pin
David Crow17-Apr-08 4:26
David Crow17-Apr-08 4:26 
GeneralRe: Programmatic send copy command (CTRL+C) Pin
CPallini17-Apr-08 4:38
mveCPallini17-Apr-08 4:38 
AnswerRe: DoEvents in C++ Pin
Nathan Holt at EMOM17-Apr-08 7:37
Nathan Holt at EMOM17-Apr-08 7:37 
yytg wrote:
I tried to imitate the function DoEvents as so



yytg wrote:
But when I call the functions - it's not working...
How do I do it in C++


I've had a need to implement DoEvents in C++ myself, and wrote something that works. Here is what I came up with.

namespace
{
    void DoEventsPumpMessage()
    {
        CWinThread *pThread = AfxGetThread();
        if( !pThread->PumpMessage() )
        {
            int nResult = (int)AfxGetCurrentMessage()->wParam;  // value from PostQuitMessage
            ::PostQuitMessage(nResult);        // so the main message loop will get it.
            TRACE("DoEvents Received quit message\n");
            CQuitMessageException::Throw();
        }
    }
}

void DoEvents( bool bAtLeastOne )
{
    if( bAtLeastOne )
    {
        DoEventsPumpMessage();
    }

    MSG message;
    while( ::PeekMessage( &message, NULL, 0, 0, PM_NOREMOVE ) )
    {
        DoEventsPumpMessage();
    }
}


Many message loops I've seen just assume there won't be a quit message, but in my case, I really wanted to avoid runaway background threads.

Nathan
QuestionChanging Window Main Frame Caption String Visual C++ Pin
Kwanalouie17-Apr-08 4:02
Kwanalouie17-Apr-08 4:02 
GeneralRe: Changing Window Main Frame Caption String Visual C++ Pin
David Crow17-Apr-08 4:24
David Crow17-Apr-08 4:24 
AnswerRe: Changing Window Main Frame Caption String Visual C++ Pin
Kwanalouie17-Apr-08 5:08
Kwanalouie17-Apr-08 5:08 
GeneralRe: Changing Window Main Frame Caption String Visual C++ Pin
David Crow17-Apr-08 5:19
David Crow17-Apr-08 5:19 
AnswerRe: Changing Window Main Frame Caption String Visual C++ Pin
Kwanalouie17-Apr-08 6:30
Kwanalouie17-Apr-08 6:30 
AnswerRe: Changing Window Main Frame Caption String Visual C++ Pin
Kwanalouie17-Apr-08 6:44
Kwanalouie17-Apr-08 6:44 
GeneralRe: Changing Window Main Frame Caption String Visual C++ Pin
David Crow17-Apr-08 6:52
David Crow17-Apr-08 6:52 
AnswerRe: Changing Window Main Frame Caption String Visual C++ Pin
led mike17-Apr-08 4:27
led mike17-Apr-08 4:27 
GeneralEdit in Flexgrid Pin
sunny_vc17-Apr-08 3:13
sunny_vc17-Apr-08 3:13 
GeneralRe: Edit in Flexgrid [modified] Pin
Eurosid17-Apr-08 4:54
Eurosid17-Apr-08 4:54 
Questionwhat is AFX_OLDPROPSHEETHEADER and GetPropSheetHeader()? Pin
Nikesh Jagtap17-Apr-08 2:59
Nikesh Jagtap17-Apr-08 2:59 
AnswerRe: what is AFX_OLDPROPSHEETHEADER and GetPropSheetHeader()? Pin
Moak17-Apr-08 3:13
Moak17-Apr-08 3:13 
AnswerRe: what is AFX_OLDPROPSHEETHEADER and GetPropSheetHeader()? Pin
David Crow17-Apr-08 3:51
David Crow17-Apr-08 3:51 
GeneralProblems converting from VC++ 4.2 to VC++ 2005 Pin
Paul Hager17-Apr-08 2:36
Paul Hager17-Apr-08 2:36 
GeneralRe: Problems converting from VC++ 4.2 to VC++ 2005 Pin
Maximilien17-Apr-08 2:53
Maximilien17-Apr-08 2:53 
GeneralRe: Problems converting from VC++ 4.2 to VC++ 2005 Pin
Paul Hager17-Apr-08 8:20
Paul Hager17-Apr-08 8:20 
GeneralRe: Problems converting from VC++ 4.2 to VC++ 2005 Pin
Iain Clarke, Warrior Programmer17-Apr-08 3:25
Iain Clarke, Warrior Programmer17-Apr-08 3:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.