資源描述:
《VISUAL C++的操作》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫(kù)。
1、一.文本.圖形處理前景與后景的設(shè)計(jì)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在其二者中中間加上分隔符(暫時(shí)先把計(jì)算器給編輯ID為ID_DIALOG1)如圖
2、操作分別選中ID_LINE,ID_ELLIPSE,點(diǎn)擊AddFunction,在點(diǎn)擊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();}二.菜單工具欄狀態(tài)欄設(shè)計(jì)分別畫出學(xué)號(hào),班級(jí),清空,其ID分別為ID_XUEHAO,ID_CLASS,ID_DELETE如圖操作分別選中ID_XUEHAO,ID_CLASS,ID_DELETE,點(diǎn)擊AddFunction,在點(diǎn)擊EditCode,編輯以下程序voidCLsdView::OnName(){//TODO:AddyourcommandhandlercodehereCClie
5、ntDCdc(this);dc.TextOut(0,0,"姓名:李思東");}voidCLsdView::OnXuehao(){//TODO:AddyourcommandhandlercodehereCClientDCdc(this);dc.TextOut(120,0,"學(xué)號(hào):200606060125");}voidCLsdView::OnClass(){//TODO:AddyourcommandhandlercodehereCClientDCdc(this);dc.TextOut(290,0,"班級(jí):06自動(dòng)化");}voidCLsdView::OnDelete(){//TODO:Add
6、yourcommandhandlercodehereInvalidate();}還要選中WM_CLOSE,點(diǎn)擊AddFunction,在點(diǎn)擊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();}三.計(jì)算器對(duì)話框設(shè)計(jì)如圖編輯“減”“乘”“除”按鈕的ID依此為IDC_MIN