在VC++中利用消息制作启动封面
2008-11-13 19:29:45 来源:WEB开发网(4)在CMainFrame类的OnCreate函数中添加SetTimer函数,并添加显示启动封面的程序代码.修改后的OnCreate函数清单如下:
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
//开始显示启动封面;
SetTimer(1,5,NULL);//添加ID号为1 的WM_TIMER事件,响应频率不宜过大;
splash = new CSplashDlg();
//可以添加播放WAV声音的代码;
//sndPlaySound("welcome.wav",SND_ASYNC);
//PlaySound("welcome.wav",NULL,SND_ASYNC);
splash->Create(IDD_DIALOG1);
splash->ShowWindow(SW_SHOW);
splash->UpdateWindow();
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbarn");
return -1; // fail to create
}
if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status barn");
return -1; // fail to create
}
// TODO: Delete these three lines if you don't want the toolbar to
// be dockable
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBar);
//应用程序窗口居中显示;
CenterWindow();
return 0;
}
编译,链接后运行应用程序,显示添加的启动封面.(该程序在VC++ 6.0 中以成功的通过)
更多精彩
赞助商链接