Quantcast
Channel: Helyar.net » c
Viewing all articles
Browse latest Browse all 2

Introduction to MFC

$
0
0

The Microsoft Foundation Class library is a framework for Windows GUIs in C++, based on the Win32 API C library.

To create a simple window, you need to create an app and a window.

The app class handles most of the behind the scenes stuff, including program entry. There must be one globally defined instance of the app for the program to run.

Here is a very basic MFC application. It just shows a blank window.

#include <afxwin.h>
 
 
class CHelloWorldFrame : public CFrameWnd
{
public:
	DECLARE_MESSAGE_MAP()
};
 
BEGIN_MESSAGE_MAP(CHelloWorldFrame, CFrameWnd)
END_MESSAGE_MAP()
 
 
 
class CHelloWorldApp : public CWinApp
{
public:
	CHelloWorldApp() : CWinApp(_T("App Name")) {}
 
	BOOL InitInstance()
	{
		CFrameWnd* frame = new CHelloWorldFrame();
		m_pMainWnd = frame;
		frame->Create(NULL, _T("Window Caption"));
		frame->ShowWindow(SW_SHOW);
		return TRUE;
	}
};
 
CHelloWorldApp theApp;

If you want to create a form with buttons, text boxes etc, you should probably look at CFormView. Alternatively, create a dialog-based application in Visual Studio rather than single document (SDI).


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images