在看了孙鑫的 《C++深入详解》 后,终于能写出个人的第一个MFC程序了,虽然是模仿孙鑫的例程,不过个人非常有成就感呵,希望能早日写出一个功能完整的程序;
 #include<windows.h>
#include<windows.h>
 #include<stdio.h>
#include<stdio.h>
 #include<cmath>
#include<cmath>
 #include<iostream>
#include<iostream>
 using namespace std;
using namespace std;


 LRESULT CALLBACK WinSunProc(
LRESULT CALLBACK WinSunProc(
 HWND hwnd,      // handle to window
                            HWND hwnd,      // handle to window
 UINT uMsg,      // message identifier
                            UINT uMsg,      // message identifier
 WPARAM wParam,  // first message parameter
                            WPARAM wParam,  // first message parameter
 LPARAM lParam   // second message parameter
                            LPARAM lParam   // second message parameter
 );
                            );

 int WINAPI WinMain(
int WINAPI WinMain(
 HINSTANCE hInstance,      // handle to current instance
                   HINSTANCE hInstance,      // handle to current instance
 HINSTANCE hPrevInstance,  // handle to previous instance
                   HINSTANCE hPrevInstance,  // handle to previous instance
 LPSTR lpCmdLine,          // command line
                   LPSTR lpCmdLine,          // command line
 int nCmdShow              // show state
                   int nCmdShow              // show state
 )
                   )


 {
{
 WNDCLASS wndcls;
    WNDCLASS wndcls;
 wndcls.cbClsExtra=0;
    wndcls.cbClsExtra=0;
 wndcls.cbWndExtra=0;
    wndcls.cbWndExtra=0;
 wndcls.hbrBackground=(HBRUSH)GetStockObject(WHITE_PEN);
    wndcls.hbrBackground=(HBRUSH)GetStockObject(WHITE_PEN);
 wndcls.hCursor=LoadCursor(NULL,IDC_CROSS);
    wndcls.hCursor=LoadCursor(NULL,IDC_CROSS);
 wndcls.hIcon=LoadIcon(NULL,IDI_ERROR);
    wndcls.hIcon=LoadIcon(NULL,IDI_ERROR);
 wndcls.hInstance=hInstance;
    wndcls.hInstance=hInstance;
 wndcls.lpfnWndProc=WinSunProc;
    wndcls.lpfnWndProc=WinSunProc;
 wndcls.lpszClassName="abilitytao";
    wndcls.lpszClassName="abilitytao";
 wndcls.lpszMenuName=NULL;
    wndcls.lpszMenuName=NULL;
 wndcls.style=CS_HREDRAW | CS_VREDRAW;
    wndcls.style=CS_HREDRAW | CS_VREDRAW;
 RegisterClass(&wndcls);
    RegisterClass(&wndcls);
 
    
 HWND hwnd;
    HWND hwnd;
 hwnd=CreateWindow("abilitytao","欢迎来到MFC世界",WS_OVERLAPPEDWINDOW,
    hwnd=CreateWindow("abilitytao","欢迎来到MFC世界",WS_OVERLAPPEDWINDOW,
 0,0,600,400,NULL,NULL,hInstance,NULL);
        0,0,600,400,NULL,NULL,hInstance,NULL);
 
    
 ShowWindow(hwnd,SW_SHOWNORMAL);
    ShowWindow(hwnd,SW_SHOWNORMAL);
 UpdateWindow(hwnd);
    UpdateWindow(hwnd);
 
    
 MSG msg;
    MSG msg;
 while(GetMessage(&msg,NULL,0,0))
    while(GetMessage(&msg,NULL,0,0))

 
     {
{
 TranslateMessage(&msg);
        TranslateMessage(&msg);
 DispatchMessage(&msg);
        DispatchMessage(&msg);
 }
    }
 return msg.wParam;
    return msg.wParam;
 }
}

 LRESULT CALLBACK WinSunProc(
LRESULT CALLBACK WinSunProc(
 HWND hwnd,      // handle to window
                            HWND hwnd,      // handle to window
 UINT uMsg,      // message identifier
                            UINT uMsg,      // message identifier
 WPARAM wParam,  // first message parameter
                            WPARAM wParam,  // first message parameter
 LPARAM lParam   // second message parameter
                            LPARAM lParam   // second message parameter
 )
                            )


 {
{
 switch(uMsg)
    switch(uMsg)

 
     {
{
 case WM_CHAR:
    case WM_CHAR:
 char szChar[20];
        char szChar[20];
 sprintf(szChar,"char code is %d",wParam);
        sprintf(szChar,"char code is %d",wParam);
 MessageBox(hwnd,szChar,"char",0);
        MessageBox(hwnd,szChar,"char",0);
 break;
        break;
 case WM_LBUTTONDOWN:
    case WM_LBUTTONDOWN:
 MessageBox(hwnd,"mouse clicked","message",0);
        MessageBox(hwnd,"mouse clicked","message",0);
 HDC hdc;
        HDC hdc;
 hdc=GetDC(hwnd);
        hdc=GetDC(hwnd);
 //ReleaseDC(hwnd,hdc);
        //ReleaseDC(hwnd,hdc);
 break;
        break;
 case WM_PAINT:
    case WM_PAINT:
 HDC hDC;
        HDC hDC;
 PAINTSTRUCT ps;
        PAINTSTRUCT ps;
 hDC=BeginPaint(hwnd,&ps);
        hDC=BeginPaint(hwnd,&ps);
 TextOut(hDC,260,100,"hello,MFC",strlen("hello,MFC"));
        TextOut(hDC,260,100,"hello,MFC",strlen("hello,MFC"));
 TextOut(hDC,350,120,"by  -abilitytao",strlen("by  -abilitytao"));
        TextOut(hDC,350,120,"by  -abilitytao",strlen("by  -abilitytao"));
 EndPaint(hwnd,&ps);
        EndPaint(hwnd,&ps);
 break;
        break;
 case WM_CLOSE:
    case WM_CLOSE:
 if(IDYES==MessageBox(hwnd,"真的要退出吗?","提示",MB_YESNO))
        if(IDYES==MessageBox(hwnd,"真的要退出吗?","提示",MB_YESNO))

 
         {
{
 DestroyWindow(hwnd);
            DestroyWindow(hwnd);
 }
        }
 break;
        break;
 case WM_DESTROY:
    case WM_DESTROY:
 PostQuitMessage(0);
        PostQuitMessage(0);
 break;
        break;
 default:
    default:
 return DefWindowProc(hwnd,uMsg,wParam,lParam);
        return DefWindowProc(hwnd,uMsg,wParam,lParam);
 }
    }
 return 0;
    return 0;
 }
}
感谢那些在我学习过程中给我指点和建议的人!