MFC 学习笔记(一)

MFC 学习笔记(一)
MFC Windows 程序编程
自己照着书敲的代码。。。。其中有一些问题,当然附上解决的方法。
//Hello.h的头文件
class CMyApp : public CWinApp
{
public:
    virtual BOOL InitInstance ();
};

class CMainWindow : public CFrameWnd
{
public:
    CMainWindow ();
	

protected:
    afx_msg void OnPaint ();
	afx_msg void OnLButtonDown(UINT nFlags,CPoint point);
    DECLARE_MESSAGE_MAP ()
};


//Hello.cpp的,Copy的同学看清啦!!!!
#include<afxwin.h>
#include"Hello.h"

CMyApp myApp;

BOOL CMyApp ::InitInstance()
{
    m_pMainWnd = new CMainWindow;
    m_pMainWnd->ShowWindow(m_nCmdShow);
    m_pMainWnd->UpdateWindow();

    return TRUE;
}

BEGIN_MESSAGE_MAP (CMainWindow,CFrameWnd)
ON_WM_PAINT()
ON_WM_LBUTTONDOWN()//添加它的消息映射!!!!!
END_MESSAGE_MAP()

CMainWindow::CMainWindow()
{
     Create(NULL,_T("The Hello Application"));

}

void CMainWindow::OnLButtonDown(UINT nFlags,CPoint point)
{    
       CRect rect;
    GetClientRect(&rect);
    CClientDC dc(this);
    //自己选一个吧。。。。。

   /*
   画NIKE商标

    POINT apoint1[4]={120,100,120,200,250,150,500,40};
    POINT apoint2[4]={120,100,20,350,250,200,500,40};
    dc.PolyBezier(apoint1,4);
    dc.PolyBezier(apoint2,4);
   */

    /*    
    画弧
    CRect rect (0,0,200,100);//有它时上面的CRect rect;要注释掉    
    GetClientRect(&rect);
    CClientDC dc(this);
    CPoint point1(0,-500);
    CPoint point2(-500,0);
    dc.Arc(rect,point1,point2);
    */

    /*
    输出分辨率的
    int nPlanes = dc.GetDeviceCaps(PLANES);
    int nBPP = dc.GetDeviceCaps(BITSPIXEL);
    int nColors = (nPlanes*nBPP)*(nPlanes*nBPP);
    TCHAR ch[256];
    wsprintf(ch,"%i",nColors);//转化为字符串类型
    dc.DrawText(ch,-1,&rect,DT_SINGLELINE|DT_CENTER|DT_VCENTER);
   */

   /*
    画X
    dc.MoveTo(rect.left,rect.top);
    dc.LineTo(rect.right,rect.bottom);
    dc.MoveTo(rect.right,rect.top);
    dc.LineTo(rect.left,rect.bottom);
    */
}

void CMainWindow::OnPaint()
{
    CPaintDC dc(this);

    CRect rect; 
    GetClientRect(&rect);
    dc.DrawText(_T("Hello MFC"),-1,&rect,DT_SINGLELINE|DT_CENTER|DT_VCENTER);

}

 


如果在编译的时候出现出现一下问题
 Linking...
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadex
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadex
Debug/Test.exe : fatal error LNK1120: 2 unresolved externals 
执行 link.exe 时出错.
选择菜单选项的 工程->设置-> c/c++ ->分类中选择code generation,相同页面上的Use run-time library:选项
中 选择Debug Multithreaded,最后确定。。应该就不会有问题的了。。








评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值