Using Visual C++-2010 Professional trial version
to create a simple Window:
(Win32 was written in C and had no native support for C++. Therefore, Microsoft created a library, named Microsoft Foundation Classes Library, and abbreviated MFC. This library was originally an “adaptation” or customization of Win32, adding object-orientation (classes and inheritance) to it.)
-----------------------------------------------------------------
Create a Win32 Project named MFCSimpleWindow using
File->Project->new->Win32
Create it as an Empty Project and a Windows Application,
Click Finish
On the main menu, click Project -> MFCSimpleWindow
Properties..
Use Unicode Character Set to use Unicode, or
select "not set" to not to use Unicode
To create a new source file, on the main menu, click
Project -> Add New Item, In the Templates section, click C++
File (.cpp), Set the Name as Exercise
(step 7) in Exercise.cpp: type: (MFC base class start with C)
#include <afxwin.h>
struct CMainFrame : public CFrameWnd
{
CMainFrame()
{
// Create(NULL, "Windows Application Tester");
Create(NULL, _T("Windows Application Tester")); // in Unicode
}
};
struct CExerciseApp : public CWinApp
{
BOOL InitInstance()
{
CMainFrame *Frame = new CMainFrame();
m_pMainWnd = Frame;
Frame->ShowWindow(SW_NORMAL);
Frame->UpdateWindow();
return TRUE;
}
};
CExerciseApp theApp;Build->Build Solution, Run->Run without debugging
Build->Build Solution, Run->Run without debugging
Change only Code in step 7 to create popup window
#include <afxwin.h>
struct CFrameTest : public CFrameWnd
{
CFrameTest()
{
Create(NULL, _T("Windows Application Tester"),
WS_POPUPWINDOW | WS_CAPTION,
CRect(400, 280, 580, 520), NULL, NULL,
WS_EX_TOOLWINDOW);
}
};
struct CAppTest : public CWinApp
{
BOOL InitInstance()
{
CFrameTest *Tester = new CFrameTest();
m_pMainWnd = Tester;
Tester->ShowWindow(SW_NORMAL);
return TRUE;
}
};
CAppTest theApp;
No comments:
Post a Comment