|
|

楼主 |
发表于 2004-11-30 15:56:00
|
显示全部楼层
Re:请教:mfc的消息循环在哪里?
int CGame::Run()
{
MSG msg;
HACCEL hAccel=NULL;
while( TRUE )
{
if( PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) )
{
if( 0 == GetMessage(&msg, NULL, 0, 0 ) )
{
return (int)msg.wParam;
}
if( 0 == TranslateAccelerator( m_hWnd, hAccel, &msg ) && 0 == IsDialogMessage(m_hOptionsDlg,&msg) )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}
}
else
{
if( m_bActive )
{
ReadInput();
if(FAILED(this->UpdateFrame()))
{
MessageBox( m_hWnd, TEXT("Displaying the next frame failed. ")
TEXT("The Game Demo will now exit. "), TEXT("Game Demo"),
MB_ICONERROR | MB_OK );
return FALSE;
}
}
else
{
WaitMessage();
m_lastTime = timeGetTime();//获得当前系统时间
}
}
}
}
那么这个函数要用到mfc程序里面的话,该放在什么地方呢? |
|