资源描述:
《VISUAL C++的操作》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、一.文本.图形处理前景与后景的设计voidCLsdView::OnDraw(CDC*pDC){CLsdDoc*pDoc=GetDocument();ASSERT_VALID(pDoc);//TODO:adddrawcodefornativedatahereRECTrect;GetClientRect(&rect);CBrushbrush(RGB(207,250,5));pDC->FillRect(&rect,&brush);}绘制线.矩形.圆依此编辑矩形,圆ID分别为ID_RECTANGLE,ID_ELLIPSE在其二者中中间加上分隔符(暂时先把计算器给编辑ID为ID_DIALOG1)如图
2、操作分别选中ID_LINE,ID_ELLIPSE,点击AddFunction,在点击EditCode,编辑其中的以下程序:voidCLsdView::OnLine(){//TODO:AddyourcommandhandlercodehereCClientDCdc(this);dc.MoveTo(10,30);dc.LineTo(250,30);}voidCLsdView::OnRectangle(){//TODO:AddyourcommandhandlercodehereCClientDCdc(this);CBrush*BrushOld,BrushNew;BrushNew.CreateSo
3、lidBrush(RGB(250,120,55));BrushOld=dc.SelectObject(&BrushNew);dc.Rectangle(60,60,250,200);dc.SelectObject(BrushOld);BrushNew.DeleteObject();}voidCLsdView::OnEllipse(){//TODO:AddyourcommandhandlercodehereCClientDCdc(this);CBrush*BrushOld,BrushNew;BrushNew.CreateSolidBrush(RGB(20,120,255));BrushOld=
4、dc.SelectObject(&BrushNew);dc.Ellipse(350,255,255,350);dc.SelectObject(BrushOld);BrushNew.DeleteObject();}二.菜单工具栏状态栏设计分别画出学号,班级,清空,其ID分别为ID_XUEHAO,ID_CLASS,ID_DELETE如图操作分别选中ID_XUEHAO,ID_CLASS,ID_DELETE,点击AddFunction,在点击EditCode,编辑以下程序voidCLsdView::OnName(){//TODO:AddyourcommandhandlercodehereCClie
5、ntDCdc(this);dc.TextOut(0,0,"姓名:李思东");}voidCLsdView::OnXuehao(){//TODO:AddyourcommandhandlercodehereCClientDCdc(this);dc.TextOut(120,0,"学号:200606060125");}voidCLsdView::OnClass(){//TODO:AddyourcommandhandlercodehereCClientDCdc(this);dc.TextOut(290,0,"班级:06自动化");}voidCLsdView::OnDelete(){//TODO:Add
6、yourcommandhandlercodehereInvalidate();}还要选中WM_CLOSE,点击AddFunction,在点击EditCode,编辑以下程序voidCMainFrame::OnTimer(UINTnIDEvent){//TODO:Addyourmessagehandlercodehereand/orcalldefaultCTimetime;time=CTime::GetCurrentTime();CStrings=time.Format("%H:%M:%S");m_wndStatusBar.SetPaneText(m_wndStatusBar.CommandT
7、oIndex(ID_INDICATOR_CLOCK),s);CFrameWnd::OnTimer(nIDEvent);}voidCMainFrame::OnClose(){//TODO:Addyourmessagehandlercodehereand/orcalldefaultKillTimer(1);CFrameWnd::OnClose();}三.计算器对话框设计如图编辑“减”“乘”“除”按钮的ID依此为IDC_MIN