通过例程分析状态条用法(3)
<6>在类CmainFrame中重载函数OnTimer(),并添加如下代码:
void CMainFrame::OnTimer(UINT nIDEvent)
{
file:// TODO: Add your message handler code here and/or call default
if(nIDEvent==1){
if(str.IsEmpty()) str=str1;
str=str.Right(str.GetLength()-2);
m_wndStatusBar.SetPaneText(1,str);
}
if(nIDEvent==2){
SYSTEMTIME t;
::GetLocalTime(&t);
CString str2;
str2.Format("%d:%d:%d:%d",t.wHour,t.wMinute,t.wSecond,t.wMilliseconds);
m_wndStatusBar.SetPaneText(3,str2);
}
CFrameWnd::OnTimer(nIDEvent);
}
<7>将MainFrm.h中,定义m_wndStatusBar之前的 protected: 改为public:
<8>通过类向导在类CmystatusView中重载WM_MOUSEMOVE,并在实现函数中添加如下代码:
void CMystatusView::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CString str3;
str3.Format("X:%d,Y:%d",point.x,point.y);
((CMainFrame*)AfxGetMainWnd())->m_wndStatusBar.SetPaneText(2,str3);
CView::OnMouseMove(nFlags, point);
}
好了,到这里我们所有的功能就都实现了,快编译运行一下吧!怎么样?还满意吗?
- 上一篇:用Visual C++实现屏幕抓程序
- 下一篇:VC用Ado接口连接和使用数据库