خرید بک لینک

Vote count: 0

Greeting, I'm novice in MFC area.

I have a question about process of starting MFC application.

I leaed that unlike SDK program, I don't have to write WinMain. Because It is supplied by the class library and is called when the application starts up.*

And my curious part is here: *Then CWinApp calls member functions of the application object to initialize and run the application.

That sentence indicates that CWinApp already know address value of application object which is made by a programmer.

However, even though application object is defined as global variable, how can WinMain function find application object's address value?

I couldn't find any coection or declaration in my sample MFC code which brings address value to the WinMain function.

#include <afxwin.h>

class CHelloApp : public CWinApp
{
public:
virtual BOOL InitInstance();
};

class CMainFrame : public CFrameWnd
{
public:
CMainFrame();
protected:
afx_msg void OnPaint();
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
DECLARE_MESSAGE_MAP()
};
CHelloApp theApp;

BOOL CHelloApp::InitInstance()
{
m_pMainWnd = new CMainFrame;
m_pMainWnd->ShowWindow(m_nCmdShow);
retu TRUE;
}

CMainFrame::CMainFrame()
{
Create(NULL, "HelloMFC Application");
}


BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
ON_WM_PAINT()
ON_WM_LBUTTONDOWN()
END_MESSAGE_MAP()

asked 2 mins ago

برچسب: نویسنده: استخدام کار تاريخ: يکشنبه 1 فروردين 1395 ساعت: 20:31

صفحه بندی