关于SetTimer()和KillTimer()函数的有关问题请问
关于SetTimer()和KillTimer()函数的问题请教
CFMRIWnd是我在一个子线程中创建的一个基于generic CWnd的窗口。我想让这个窗口每隔一秒闪烁字符串。我将SetTimer()函数写在了CFMRIWnd::OnCreate()函数中。
int CFMRIWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
SetTimer(1, 1000, NULL);
return 0;
}
在CFMRIWnd::OnTimer()函数中加入了如下代码:
void CFMRIWnd::OnTimer(UINT nIDEvent)
{
switch(nIDEvent)
{
case 1:
CDC* pDC = GetDC();
pDC-> TextOut(200, 100, chr);
KillTimer(1);
break;
}
}
程序可以通过编译链接,但是在运行时,在我点击触发新建这个窗口的命令的时候总是会出现如下的错误:
Debug Assertion Failed!
Program: D:\...\Debug\fMRITest.exe
File: afxwin2.inl
line: 171
For information on how your program can cause an assertion
failure, see the Visual C++ documentaion on asserts.
(Press Retry to debug the application)
当我单击重试按钮的时候,错误行由171变成了168行。
------解决方案--------------------
_AFXWIN_INLINE void CWnd::SendMessageToDescendants(
UINT message, WPARAM wParam, LPARAM lParam, BOOL bDeep, BOOL bOnlyPerm)
{ ASSERT(::IsWindow(m_hWnd)); CWnd::SendMessageToDescendants(m_hWnd, message, wParam, lParam, bDeep,
bOnlyPerm); }
_AFXWIN_INLINE CWnd* CWnd::GetDescendantWindow(int nID, BOOL bOnlyPerm) const
{ ASSERT(::IsWindow(m_hWnd)); return CWnd::GetDescendantWindow(m_hWnd, nID, bOnlyPerm); }
///////////////////////////
168至171行。
///////////////////////////
不是SetTimer(1, 1000, NULL);问题吧!
你调用过GetDescendantWindow(int nID, BOOL bOnlyPerm)函数ASSERT(::IsWindow(m_hWnd)); 失败
CFMRIWnd是我在一个子线程中创建的一个基于generic CWnd的窗口。我想让这个窗口每隔一秒闪烁字符串。我将SetTimer()函数写在了CFMRIWnd::OnCreate()函数中。
int CFMRIWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
SetTimer(1, 1000, NULL);
return 0;
}
在CFMRIWnd::OnTimer()函数中加入了如下代码:
void CFMRIWnd::OnTimer(UINT nIDEvent)
{
switch(nIDEvent)
{
case 1:
CDC* pDC = GetDC();
pDC-> TextOut(200, 100, chr);
KillTimer(1);
break;
}
}
程序可以通过编译链接,但是在运行时,在我点击触发新建这个窗口的命令的时候总是会出现如下的错误:
Debug Assertion Failed!
Program: D:\...\Debug\fMRITest.exe
File: afxwin2.inl
line: 171
For information on how your program can cause an assertion
failure, see the Visual C++ documentaion on asserts.
(Press Retry to debug the application)
当我单击重试按钮的时候,错误行由171变成了168行。
------解决方案--------------------
_AFXWIN_INLINE void CWnd::SendMessageToDescendants(
UINT message, WPARAM wParam, LPARAM lParam, BOOL bDeep, BOOL bOnlyPerm)
{ ASSERT(::IsWindow(m_hWnd)); CWnd::SendMessageToDescendants(m_hWnd, message, wParam, lParam, bDeep,
bOnlyPerm); }
_AFXWIN_INLINE CWnd* CWnd::GetDescendantWindow(int nID, BOOL bOnlyPerm) const
{ ASSERT(::IsWindow(m_hWnd)); return CWnd::GetDescendantWindow(m_hWnd, nID, bOnlyPerm); }
///////////////////////////
168至171行。
///////////////////////////
不是SetTimer(1, 1000, NULL);问题吧!
你调用过GetDescendantWindow(int nID, BOOL bOnlyPerm)函数ASSERT(::IsWindow(m_hWnd)); 失败