OnTimer function not activated

Hello,
I'm a student and not very proffessional in programming, but i want to use the OnTimer function. This is working very well in an other class, but in this not. With the debugger i check and the function OnTimer is never activated. But the SetTimer is done (also checked with the debugger)

Maybe you're expert and see the problem in one eye?
Thanks for have a look, Bart

This code is only a test-part, because the problem is around the timer i put away the original code and create a some test code.
I'm using C++ / MFC

CTHREADFUNCTION.h
--------------------
#pragma once

#include "afxmt.h"
#include "SerialCommFunctions.h"
#include "afxwin.h"

class CThreadFunctions : public CDialog
{

protected:
DECLARE_MESSAGE_MAP()

public:
CThreadFunctions(CTCM120LAB *m_pSerialTcmLABTemp, CSerialCommFunctions *m_pSerialCommFunctionsTcmLABTemp, CSerialCommFunctions *m_pSerialCommFunctionsTcmAnalyseTemp);
~CThreadFunctions(void);

void OnTimer(UINT nIDEvent);

void CheckTcmLab();

bool GetTimeOut50ms();
void SetTimeOut50ms(bool bTimeOut50msTemp);

bool bTimeOut50ms;
};

CTHREADFUNCTIONS.cpp
----------------------

#include "StdAfx.h"
#include "threadfunctions.h"

#include <tchar.h>
#include <windows.h>
#include <stdio.h>
#include <string.h>

CThreadFunctions::CThreadFunctions(CTCM120LAB *m_pSerialTcmLABTemp, CSerialCommFunctions *m_pSerialCommFunctionsTcmLABTemp, CSerialCommFunctions *m_pSerialCommFunctionsTcmAnalyseTemp)
{
m_pSerialTcmLAB = m_pSerialTcmLABTemp;
m_pSerialCommFunctionsTcmLAB = m_pSerialCommFunctionsTcmLABTemp;
m_pSerialCommFunctionsTcmAnalyse = m_pSerialCommFunctionsTcmAnalyseTemp;
}

CThreadFunctions::~CThreadFunctions(void)
{
}

BEGIN_MESSAGE_MAP(CThreadFunctions, CDialog)
ON_WM_TIMER()
END_MESSAGE_MAP()

void CThreadFunctions::CheckTcmLab()
{
CString sTemp;
SetTimer(2, 100, 0);
SetTimeOut50ms(false);
while (GetTimeOut50ms() == false)
{}
}

void CThreadFunctions::OnTimer(UINT nIDEvent)
{
switch (nIDEvent)
{
case 2:
{
CThreadFunctions::SetTimeOut50ms = (true);
}
break;
default:
break;
}
CDialog::OnTimer(nIDEvent);
}
[2475 byte] By [Bartvandiepen] at [2007-11-19 7:28:51]
# 1 Re: OnTimer function not activated
Well, your app is single threaded - and the while loop in CheckTcmLab() will block your main thread, so WM_TIMER (and other) messages will never be processed.
Also, note that your code contains strange things like CThreadFunctions::SetTimeOut50ms = (true); - that won't even compile.
gstercken at 2007-11-11 0:27:24 >
# 2 Re: OnTimer function not activated
in addition to what gstercken already mentioned: It is almost a must for your application to enter the "idle" state, in which it does nothing special. This will allow windows to process all the messages it sends to your program and you often do not handle by yourself, i. e. redrawing the window.

So just make every function ending after the job is done. Try to avoid endless loops.

Marc
Marc from D at 2007-11-11 0:28:24 >