Home

OFF-SOFT.net

OFF-SOFT.net

This site is support & information site of WEB,and Software. This site might help you that create software or Web Site…perhaps?[:]

From WTL to MFC (1) ATL basic

Published on| April 29th, 2009 | No Comment.
Let's create a ATL window
So, immediately, a program to screen a simple dialog lets you create ATL and MFC.

Screen is displayed to the left to run,
"OK", "Cancel" to exit and click on
On the right of the screen, "Close" to exit and click the
Let's programming.

The dialog 1.MFC
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS
 
#define _AFX_ALL_WARNINGS
 
#include <afxwin.h>
#include <afxext.h>
 
#include <afxdtctl.h>
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h>
#endif
 
 
#include "resource.h"
 
/////////////////////////////////////////
// The About dialog
 
class CAboutDlg : public CDialog
{
public:
	CAboutDlg() : CDialog(CAboutDlg::IDD) {};
 
	enum { IDD = IDD_ABOUT };
 
	protected:
	virtual void DoDataExchange(CDataExchange* pDX)
	{
		CDialog::DoDataExchange(pDX);
	}
 
protected:
	DECLARE_MESSAGE_MAP()
};
 
 
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
END_MESSAGE_MAP()
 
 
 
 
 
 
 
 
 
/////////////////////////////////////////
//	WinMain
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hInstPrev,
                   LPSTR szCmdLine, int nCmdShow)
 
{
	if (AfxWinInit(hInst, hInstPrev, szCmdLine, nCmdShow)){
		CAboutDlg dlg;
		dlg.DoModal();
	}
 
	AfxWinTerm();
	return 0;
}
The dialog 2.ATL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <atlbase.h>
#if _ATL_VER < 0x7000
extern CComModule _Module;
#endif
#include <atlwin.h>
 
#if _ATL_VER < 0x7000
CComModule _Module;
#define _APP _Module
#else
#define _APP _AtlBaseModule
#endif
 
#include "resource.h"
 
/////////////////////////////////////////
// The About dialog
 
class CAboutDlg : public CDialogImpl<CAboutDlg>
{
public:
    enum { IDD = IDD_ABOUT };
 
    BEGIN_MSG_MAP(CAboutDlg)
        MESSAGE_HANDLER(WM_CLOSE, OnClose)
        COMMAND_ID_HANDLER(IDOK, OnOKCancel)
        COMMAND_ID_HANDLER(IDCANCEL, OnOKCancel)
    END_MSG_MAP()
 
 
    LRESULT OnClose
        (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
    {
        EndDialog(IDCANCEL);
        return 0;
    }
 
    LRESULT OnOKCancel
        (WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
    {
        EndDialog(wID);
        return 0;
    }
};
 
/////////////////////////////////////////
//	WinMain
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hInstPrev,
                   LPSTR szCmdLine, int nCmdShow)
{
#if _ATL_VER < 0x7000
    _Module.Init(NULL, hInst);
#endif
 
	CAboutDlg dlg;
	dlg.DoModal();
 
    _APP.Term();
    return 0;
}

Make a simple explanation.
ATL to DIALOG Class of the two.
CDialogImpl: The dialog uses a simple, CAxDialogImpl: ActiveX is used to have a dialog control.
Here is a simple dialog, CDialogImpl used.

Well, it felt like we saw. CAboutDlg slight differences in the process.
In MFC, Close, OnOK, OnCacel is easily available.
ATL, the default behavior is not around, you should write.
Little, SDK is reminiscent coding.
Also, _ATL_VER but here and there, which, ATL 7.0 for the basic structure of different earlier or later, we switched to using the flag description.
The free version provides all of ATL if, perhaps, ATL version, 3.0.
From various aspects, 3.0, MFC's programmer, I think there are many annoying situations. The biggest point is not more than 7.0 and ATL:: CString is not available. If possible, 7.0 is the version that is more than ready, and, if we make it easier.

I but not the same, in future, I think a little more掘RI下GETAI.

Finally, you have to compare the size.
Optimization / O1 in size results in the release
  • ATL 56kb
  • MFC 29kb (DLL)
  • MFC 136kb (STATIC)
Approximate, would result in the expected.

From above, some sites have a deeper comparison. In consideration of WTL, is a good reference.
http://www.endurasoft.com/vcd/mfcwtl.htm

Comments

Leave a Reply







  • はてなブックマークへ追加する
  • Facebookでシェアする
  • twitter でつぶやく
  • Google Plusでシェアする
  • Pocketでシェアする
ページトップへ