MFC里面的一些实例应用

下面这个函数作用是读取键盘输入的按键是什么,例如:输入“x”,屏幕会弹出消息对话框“x”

void CMy01MFCtestView::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{

TCHAR ch = (TCHAR)nChar;

CString str;

str.Format(TEXT("%c"), ch);

MessageBox(str);

CView::OnChar(nChar, nRepCnt, nFlags);
}

 

这个是当鼠标左键在窗口点击的时候,会弹出消息对话框显示鼠标左键点击的窗口的坐标值。


void CMy01MFCtestView::OnLButtonDown(UINT nFlags, CPoint point)
{

CString str;

str.Format(TEXT("x=%d,y=%d"), point.x, point.y);

MessageBox(str);

CView::OnLButtonDown(nFlags, point);
}

 

posted @ 2019-08-07 12:03  缄默先生  阅读(334)  评论(0编辑  收藏  举报