Click here to Skip to main content
15,910,009 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: focus problem on win2k Pin
Tomasz Sowinski18-Mar-02 2:47
Tomasz Sowinski18-Mar-02 2:47 
GeneralWM_TIMER? - (semi real time) - (I'M VERY NOVICE) - (4 short questions) Pin
Joan M18-Mar-02 0:52
professionalJoan M18-Mar-02 0:52 
GeneralRe: WM_TIMER? - (semi real time) - (I'M VERY NOVICE) - (4 short questions) Pin
Tomasz Sowinski18-Mar-02 1:17
Tomasz Sowinski18-Mar-02 1:17 
GeneralRe: WM_TIMER? - (semi real time) - (I'M VERY NOVICE) - (4 short questions) Pin
Joan M18-Mar-02 4:17
professionalJoan M18-Mar-02 4:17 
GeneralRe: WM_TIMER? - (semi real time) - (I'M VERY NOVICE) - (4 short questions) Pin
Tomasz Sowinski18-Mar-02 4:36
Tomasz Sowinski18-Mar-02 4:36 
GeneralRe: WM_TIMER? - (semi real time) - (I'M VERY NOVICE) - (4 short questions) Pin
C-J Berg18-Mar-02 1:58
C-J Berg18-Mar-02 1:58 
GeneralRe: WM_TIMER? - (semi real time) - (I'M VERY NOVICE) - (4 short questions) Pin
Joan M18-Mar-02 5:36
professionalJoan M18-Mar-02 5:36 
GeneralRe: WM_TIMER? - (semi real time) - (I'M VERY NOVICE) - (4 short questions) Pin
C-J Berg18-Mar-02 6:38
C-J Berg18-Mar-02 6:38 
You can remove WM_TIMER messages like this at the end of your data polling function:

// Look for WM_TIMER messages
MSG msg;
while ( ::PeekMessage(&msg, NULL, WM_TIMER, WM_TIMER, PM_NOREMOVE) )
{
   // m_nTimerID contains holds the ID of your timer... if you're using
   // more than one timer, this removal procedure won't be fool proof.
   if ( msg.wParam == (UINT)m_nTimerID )
   {
      // Remove the message
      ::PeekMessage(&msg, NULL, WM_TIMER, WM_TIMER, PM_REMOVE);
   }
   else break;
};

However, I wouldn't implement it like this, but instead create a worker thread that uses a Waitable Timer object (cf. CreateWaitableTimer in the Platform SDK). This way you needn't worry about removing messages from the queue, and you can change the worker thread's priority if you like. You will need to synchronize access to the variables you will be updating, but it isn't that hard.

HANDLE hWait = ::CreateWaitableTimer(...);
for ( ;; ) {
   ::SetWaitableTimer(...);
   // You might want to use a "Quit" event object as well, created and signaled from the main thread, so you know when to exit the thread. If that's the case, use WaitForMultipleObjects instead.
   DWORD dwWaitRet = ::WaitForSingleObject(hWait,...);
   switch (dwWaitRet)
   {
      // cases...
   }
}
CloseHandle(hWait);
GeneralRe: WM_TIMER? - (semi real time) - (I'M VERY NOVICE) - (4 short questions) Pin
Tomasz Sowinski18-Mar-02 7:17
Tomasz Sowinski18-Mar-02 7:17 
GeneralRe: WM_TIMER? - (semi real time) - (I'M VERY NOVICE) - (4 short questions) Pin
C-J Berg19-Mar-02 1:56
C-J Berg19-Mar-02 1:56 
GeneralRe: WM_TIMER? - (semi real time) - (I'M VERY NOVICE) - (4 short questions) Pin
Tomasz Sowinski19-Mar-02 2:08
Tomasz Sowinski19-Mar-02 2:08 
GeneralRe: WM_TIMER? - (semi real time) - (I'M VERY NOVICE) - (4 short questions) Pin
C-J Berg19-Mar-02 2:37
C-J Berg19-Mar-02 2:37 
GeneralRe: WM_TIMER? - (semi real time) - (I'M VERY NOVICE) - (4 short questions) Pin
Joan M19-Mar-02 23:20
professionalJoan M19-Mar-02 23:20 
GeneralRe: WM_TIMER? - (semi real time) - (I'M VERY NOVICE) - (4 short questions) Pin
JT Anderson18-Mar-02 8:14
JT Anderson18-Mar-02 8:14 
GeneralRegistry Operations Pin
udayakumar18-Mar-02 0:38
udayakumar18-Mar-02 0:38 
GeneralRe: Registry Operations Pin
Tomasz Sowinski18-Mar-02 0:43
Tomasz Sowinski18-Mar-02 0:43 
GeneralRe: Registry Operations Pin
Abhishek Narula18-Mar-02 0:52
Abhishek Narula18-Mar-02 0:52 
GeneralRe: Registry Operations Pin
Abhishek Narula18-Mar-02 1:05
Abhishek Narula18-Mar-02 1:05 
GeneralRe: Registry Operations Pin
udayakumar18-Mar-02 1:38
udayakumar18-Mar-02 1:38 
GeneralDisable audio port Pin
Halid Niyaz18-Mar-02 0:04
Halid Niyaz18-Mar-02 0:04 
GeneralMultiple View Application Pin
Abhishek Narula17-Mar-02 23:40
Abhishek Narula17-Mar-02 23:40 
GeneralRe: Multiple View Application Pin
Tomasz Sowinski18-Mar-02 0:24
Tomasz Sowinski18-Mar-02 0:24 
GeneralRe: Multiple View Application Pin
Abhishek Narula18-Mar-02 0:32
Abhishek Narula18-Mar-02 0:32 
GeneralRe: Multiple View Application Pin
Tomasz Sowinski18-Mar-02 0:40
Tomasz Sowinski18-Mar-02 0:40 
GeneralActive document container & menu icons Pin
C-J Berg17-Mar-02 23:37
C-J Berg17-Mar-02 23:37 

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.