我的程序在开始时需要做一些耗时的初始化工作,所以加入了启动窗口,并在启动窗口里加了个进度条,使用定时器,每500毫秒执行一次StepIt,但程序运行时进度条却不工作,不触发定时器,后又分别尝试单独用一个线程执行StepIt或单独用一个线程进行初始化,都达不到效果,不知是怎么回事,请各位大侠帮忙看看.部分代码如下:
/* 启动窗口部分, 是VC自带的那个启动窗口,稍加了改动 */
void CSplashWnd::EnableSplashScreen(BOOL bEnable /*= TRUE*/)
{
c_bShowSplashWnd = bEnable;
}void CSplashWnd::ShowSplashScreen(CWnd* pParentWnd /*= NULL*/)
{
if (!c_bShowSplashWnd || c_pSplashWnd != NULL)
return; // Allocate a new splash screen, and create the window.
c_pSplashWnd = new CSplashWnd;
if (!c_pSplashWnd->Create(pParentWnd))
delete c_pSplashWnd;
else
c_pSplashWnd->UpdateWindow();
}BOOL CSplashWnd::PreTranslateAppMessage(MSG* pMsg)
{
if (c_pSplashWnd == NULL)
return FALSE; // If we get a keyboard or mouse message, hide the splash screen.
if (pMsg->message == WM_CLOSE )
{
c_pSplashWnd->HideSplashScreen();
return TRUE; // message handled here
} return FALSE; // message not handled
}
void CSplashWnd::HideSplashScreen()
{
// Destroy the window, and update the mainframe.
delete m_pctlProgress;
DestroyWindow();
}
/* 在启动窗口建立后,建立进度条控件 */
int CSplashWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CWnd::OnCreate(lpCreateStruct) == -1)
return -1; // Center the window.
CenterWindow(); m_pctlProgress = new CProgressCtrl;
         // 建立进度条
m_pctlProgress->Create( WS_CHILD|WS_VISIBLE|PBS_SMOOTH, 
      CRect(5,165,305,170), this, 
                                 IDC_PROGRESS );
m_pctlProgress->SetRange( 0, 300 );
m_pctlProgress->SetStep( 300 );

//设置定时器
SetTimer( ID_TIMER, 500, NULL ); return 0;
}
/* 响应定时 */
void CSplashWnd::OnTimer(UINT nIDEvent) 
{
// TODO: Add your message handler code here and/or call default m_pctlProgress->StepIt();
}/* 主程序 */
BOOL CSmart114DlgApp::InitInstance()
{ /* 建立并显示启动窗口 */
CSplashWnd::EnableSplashScreen();
CSplashWnd::ShowSplashScreen(); /* 建立主对话框 */
CSmart114DlgDlg dlg;
m_pMainWnd = &dlg; /* 一些耗时的初始化工作 */
InitSysterm(); /* 关闭启动窗口 */
MSG msg;
msg.message = WM_CLOSE;
CSplashWnd::PreTranslateAppMessage( &msg ); /* 显示主对话框 */
int nResponse = dlg.DoModal();
return FALSE;
}