使用MFC創建視窗
[font=標楷體][size=10pt]//[/size][/font][font=標楷體][size=10pt]一個最簡單的MFC應用程式: welcome.h[/size][/font][font=標楷體][size=10pt]//Author:Curtis Chou [/size][/font]
[font=標楷體][size=10pt] [/size][/font]
[font=標楷體][size=10pt]classCWelcomeWnd : public CFrameWnd {[/size][/font]
[font=標楷體][size=10pt]public:[/size][/font]
[font=標楷體][size=10pt]
CWelcomeWnd();[/size][/font]
[font=標楷體][size=10pt]
~CWelcomeWnd();[/size][/font]
[font=標楷體][size=10pt]private:[/size][/font]
[font=標楷體][size=10pt]
CStatic *m_pHello;[/size][/font]
[font=標楷體]};[/font]
[font=標楷體][size=10pt] [/size][/font]
[font=標楷體][size=10pt]//[/size][/font][font=標楷體][size=10pt]一個最簡單的MFC應用程式: welcome.cpp[/size][/font]
[font=標楷體][size=10pt]//Author:Curtis Chou [/size][/font]
[font=標楷體][size=10pt] [/size][/font]
[font=標楷體][size=10pt]#include<afxwin.h>[/size][/font]
[font=標楷體][size=10pt]#include"welcome.h"[/size][/font]
[font=標楷體][size=10pt] [/size][/font]
[font=標楷體][size=10pt]CWelcomeWnd::CWelcomeWnd(){[/size][/font]
[font=標楷體][size=10pt]
Create( NULL,[/size][/font]
[font=標楷體][size=10pt]
"[/size][/font][font=標楷體][size=10pt]歡迎",[/size][/font]
[font=標楷體][size=10pt]
WS_OVERLAPPEDWINDOW,[/size][/font]
[font=標楷體][size=10pt]
CRect( 200, 200, 460, 400)
);[/size][/font]
[font=標楷體][size=10pt]
m_pHello = new CStatic;[/size][/font]
[font=標楷體][size=10pt]
m_pHello->Create([/size][/font]
[font=標楷體][size=10pt]
"[/size][/font][font=標楷體][size=10pt]歡迎來到MS Visual C++的世界!" ,[/size][/font]
[font=標楷體][size=10pt]
WS_CHILD | WS_VISIBLE | WS_BORDER| SS_CENTER ,[/size][/font]
[font=標楷體][size=10pt]
CRect( 40, 50 , 200, 120) ,[/size][/font]
[font=標楷體][size=10pt]
this );[/size][/font]
[font=標楷體][size=10pt]}[/size][/font]
[font=標楷體][size=10pt] [/size][/font]
[font=標楷體][size=10pt]CWelcomeWnd::~CWelcomeWnd(){[/size][/font]
[font=標楷體][size=10pt]
delete m_pHello;[/size][/font]
[font=標楷體][size=10pt]}[/size][/font]
[font=標楷體][size=10pt] [/size][/font]
[font=標楷體][size=10pt]//[/size][/font][font=標楷體][size=10pt]宣告應用程式類別[/size][/font]
[font=標楷體][size=10pt]classCWelcomeApp : public CWinApp {[/size][/font]
[font=標楷體][size=10pt]public:[/size][/font]
[font=標楷體][size=10pt]
BOOL InitInstance(){[/size][/font]
[font=標楷體][size=10pt]
m_pMainWnd = new CWelcomeWnd ;[/size][/font]
[font=標楷體][size=10pt]
m_pMainWnd -> ShowWindow( m_nCmdShow);[/size][/font]
[font=標楷體][size=10pt]
m_pMainWnd -> UpdateWindow();[/size][/font]
[font=標楷體][size=10pt]
return TRUE;[/size][/font]
[font=標楷體][size=10pt]
}[/size][/font]
[font=標楷體][size=10pt]};[/size][/font]
[font=標楷體][size=10pt] [/size][/font]
[font=標楷體][size=10pt]CWelcomeApphi;[/size][/font] 呵呵,,谢谢大大。。上周刚学mfc。刚好可以参考擦你考。。 感謝阿~!新手上路剛好需要
还是底层好玩!
还是底层好玩!可以知道很多东西? 感謝感謝, 正好拿來測試看看頁:
[1]