MFC學習第三節:在視窗內點選左鍵畫圓,新增選單使圓增大。
阿新 • • 發佈:2019-01-25
1.在view.h中定義CString str;
2.在void CHhView::OnDraw(CDC* pDC)中定義int x=10,y=10;
3.建立函式void CHhView::OnLButtonDown(UINT nFlags, CPoint point)新增右鍵功能,在函式外定義r=10;
4.在resources中的menu中建立一個‘新增’選單,併為此選單新增函式。
2.在void CHhView::OnDraw(CDC* pDC)中定義int x=10,y=10;
3.建立函式void CHhView::OnLButtonDown(UINT nFlags, CPoint point)新增右鍵功能,在函式外定義r=10;
4.在resources中的menu中建立一個‘新增’選單,併為此選單新增函式。
void CHhView::OnLButtonDown(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default str.Format("%d,%d",point.x,point.y); CDC *pDC=GetDC(); pDC->Ellipse(point.x-r,point.y-r,point.x+r,point.y+r); CView::OnLButtonDown(nFlags, point); } void CHhView::OnMenuitem32771() { // TODO: Add your command handler code here r+=10; }