D.C.資訊交流網-[綜合論壇]-關閉註冊's Archiver

mahler14 發表於 2007-8-11 00:24

使用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]

Atom 發表於 2008-3-13 19:02

呵呵,,谢谢大大。。上周刚学mfc。刚好可以参考擦你考。。

arni 發表於 2008-4-2 16:38

感謝阿~!新手上路剛好需要

aquan147 發表於 2008-6-11 17:54

还是底层好玩!

还是底层好玩!可以知道很多东西?

esper 發表於 2008-6-12 11:43

感謝感謝, 正好拿來測試看看

頁: [1]

Powered by Discuz! Archiver 7.2  © 2001-2009 Comsenz Inc.