|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Announcements
Want a new Job?
Chapters
Services
Feature Zones
|
Note: This is an unedited contribution. If this article is inappropriate,
needs attention or copies someone else's work without reference then please
Report This Article
IntroductionWell I started off in VC++ after programming for sometime in VB (a few months at home). One function that I missed from VB was Why I needed a DoEvent function. Well I am in the midst of developing an interesting personal project,l the idea is a secret ;). So what happened was that I had a tight loop kind of a situation and I didn't want to use a thread because it was un-necessary. That's the time when I did start thinking about DoEvent codeWell now enough of preaching :). Let's get back to the code that will help us in doing this. static void DoEvents( HWND hWnd_i )
{
MSG stMsg = { 0 };
while( PeekMessage( &stMsg, hWnd_i, 0, 0, PM_REMOVE ))
{
TranslateMessage( &stMsg );
DispatchMessage( &stMsg );
}
}
Loop in which this is called is as follows... for( UINT uFileIndex = 0; uFileIndex < uFileCount; ++uFileIndex )
{
UpdateProgressBar( uFileIndex + 1 );
if( !( uFileIndex % LOOP_THRESH_HOLD_FOR_DO_EVENTS ))
{
ResUtils::DoEvents( this->GetSafeHwnd() );
}
}
I defined a Flushing Keyboard and Mouse Input bufferWell this was about static void FlushKeyboardInputBuffer( HWND hWnd_i ) { MSG stMsg = { 0 }; while( PeekMessage( &stMsg, hWnd_i , WM_KEYFIRST, WM_KEYLAST, PM_REMOVE )) ; } static void FlushMouseInputBuffer( HWND hWnd_i ) { MSG stMsg = { 0 }; while( PeekMessage( &stMsg, hWnd_i, WM_MOUSEFIRST, WM_MOUSELAST, PM_REMOVE )) ; }
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| PM_QS_INPUT | Windows 98/Me, Windows 2000/XP: Process mouse and keyboard messages. |
| PM_QS_PAINT | Windows 98/Me, Windows 2000/XP: Process paint messages. |
| PM_QS_POSTMESSAGE | Windows 98/Me, Windows 2000/XP: Process all posted messages, including timers and hotkeys. |
| PM_QS_SENDMESSAGE | Windows 98/Me, Windows 2000/XP: Process all sent messages. |
PeekMessage search MSDN with OnIdle keyword, you will bump into pretty interesting topics.
| You must Sign In to use this message board. | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
|
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 12 Oct 2006 Editor: |
Copyright 2006 by Nibu babu thomas Everything else Copyright © CodeProject, 1999-2008 Web16 | Advertise on the Code Project |