Click here to Skip to main content
15,895,142 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Memory leak Pin
Zac Howland29-Jun-06 3:56
Zac Howland29-Jun-06 3:56 
GeneralRe: Memory leak Pin
pierre_ribery29-Jun-06 4:07
pierre_ribery29-Jun-06 4:07 
GeneralRe: Memory leak Pin
Zac Howland29-Jun-06 5:11
Zac Howland29-Jun-06 5:11 
AnswerRe: Memory leak [modified] Pin
Viorel.29-Jun-06 4:10
Viorel.29-Jun-06 4:10 
GeneralRe: Memory leak Pin
pierre_ribery29-Jun-06 20:47
pierre_ribery29-Jun-06 20:47 
QuestionTimer in user class Pin
jsumm29-Jun-06 2:42
jsumm29-Jun-06 2:42 
AnswerRe: Timer in user class Pin
Cedric Moonen29-Jun-06 3:09
Cedric Moonen29-Jun-06 3:09 
GeneralRe: Timer in user class Pin
jsumm29-Jun-06 4:22
jsumm29-Jun-06 4:22 
Thank you for your help.

I've found a timer tutorial an I'm trying to develop a Multimedia Timer.
Here the source in my user class.

void CALLBACK TimerFunction(UINT wTimerID, UINT msg, DWORD dwUser, DWORD dw1, DWORD dw2)
{
// This is used only to call MMTimerHandler
// Typically, this function is static member of CTimersDlg
CMyClass* obj = (CMyClass*) dwUser;
obj->MMTimerHandler(wTimerID);
}
//----------------------------------------------------------------------------------------

void CMyClass::StartTimer()
{
m_nTimeout = 2000;

TIMECAPS tc;
timeGetDevCaps(&tc, sizeof(TIMECAPS));
DWORD resolution = min(max(tc.wPeriodMin, 0), tc.wPeriodMax);
timeBeginPeriod(resolution);

// create the timer
m_idEvent = timeSetEvent(
m_nTimeout,
resolution,
::TimerFunction,
(DWORD)this,
TIME_PERIODIC);
}
//----------------------------------------------------------------------------------------

void CMyClass::StopTimer()
{
// destroy the timer
timeKillEvent(m_idEvent);

// reset the timer
timeEndPeriod (m_nTimeout);
}
//----------------------------------------------------------------------------------------

void CMyClass::MMTimerHandler(UINT nIDEvent) // called every elTime milliseconds
{
// do what you want to do, but quickly
static int a = 0;
CString str;
str.Format("Timer-Event %d", a++);
m_pTargetDlg->SetState(str);
}
//----------------------------------------------------------------------------------------

It's done in the way you expained, I think. But when the last line of code is done in the MMTimerHandler function (it calls the following Methode in a Dialog class)

void CTestDlg::SetState(CString strState)
{
m_strStatus = strState;
UpdateData(FALSE);
}

it crashes with a Debug Assertion Failed!- Error.
File wincore.cpp
Line 879

Any idea why?

Juergen
GeneralRe: Timer in user class Pin
Cedric Moonen29-Jun-06 4:31
Cedric Moonen29-Jun-06 4:31 
GeneralRe: Timer in user class Pin
jsumm29-Jun-06 5:15
jsumm29-Jun-06 5:15 
GeneralRe: Timer in user class Pin
Cedric Moonen29-Jun-06 5:30
Cedric Moonen29-Jun-06 5:30 
QuestionOPC Server Pin
Sanjay6429-Jun-06 2:31
Sanjay6429-Jun-06 2:31 
Questionproblem with mouse_event() Pin
V_shr29-Jun-06 2:20
V_shr29-Jun-06 2:20 
AnswerRe: problem with mouse_event() Pin
Justin Tay29-Jun-06 2:47
Justin Tay29-Jun-06 2:47 
GeneralRe: problem with mouse_event() Pin
V_shr29-Jun-06 3:33
V_shr29-Jun-06 3:33 
GeneralRe: problem with mouse_event() Pin
Justin Tay29-Jun-06 3:41
Justin Tay29-Jun-06 3:41 
GeneralRe: problem with mouse_event() Pin
V_shr29-Jun-06 3:50
V_shr29-Jun-06 3:50 
Questionneed help for serial port hooking Pin
fionashrek0329-Jun-06 1:39
fionashrek0329-Jun-06 1:39 
AnswerRe: need help for serial port hooking Pin
David Crow29-Jun-06 2:44
David Crow29-Jun-06 2:44 
Questiontool tip like dialog Pin
Tara1429-Jun-06 1:24
Tara1429-Jun-06 1:24 
AnswerRe: tool tip like dialog Pin
Viorel.29-Jun-06 1:50
Viorel.29-Jun-06 1:50 
GeneralRe: tool tip like dialog Pin
Tara1429-Jun-06 2:25
Tara1429-Jun-06 2:25 
AnswerRe: tool tip like dialog Pin
Rage29-Jun-06 1:51
professionalRage29-Jun-06 1:51 
QuestionRegistry key for installed components. Pin
Aryan S29-Jun-06 1:21
Aryan S29-Jun-06 1:21 
AnswerRe: Registry key for installed components. Pin
Blake Miller30-Jun-06 10:36
Blake Miller30-Jun-06 10:36 

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.