2011年6月20日 星期一

Visual Studio 2010 入門



使用Visual Studio 2010 產生一視窗


建立一空白專案

新增.cpp 檔,填入下列程式碼

#include                                                                           //載入 afxwin標頭檔

class MyApp : public CWinApp //繼承 CWinApp
{
public:
BOOL InitInstance()    //進入程式點
{
CFrameWnd *Frame = new CFrameWnd();   //建立 CFrameWnd 物件
m_pMainWnd = Frame;   //將 m_pMainWnd 設定為 Frame

Frame->Create(NULL,"Hello World");                                     //建立視窗
Frame->ShowWindow(SW_SHOW); //顯示視窗

return true;
}
};

MyApp a_app; //建立一個應用程式物件,MyApp 為自訂的應用程式類別