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 (2) trap the wizard (dialog Chapter)

Published on| May 5th, 2009 | No Comment.
Description:
WTL basic characteristics, and wrote articles in the following. So, then I would like WTL to create a screen using a simple dialog.
It is written in the title, here, MFC, so you want to describe the differences between, MFC I would describe the difference between Wizard.
For environmental uses of the environment created by the article.


Articles: from WTL to MFC (1) ATL basis

Sample source code you used here:

Japanese Wizard:

Let's make a WTL dialog using a wizard
Create a new project
[File] - [New] - [Projects] The following screen appears.

"Project" an appropriate name (in this case, for example "dlgtest" and. ) Set, "OK" button.
Setting the project

"Next" button.


Here,
The left "type of application" in "DAIAROGUBESU" from the menu.
"Modal dialog" is put in check.

The right of the screen "project options" in ". CPP file" is put in check. (MFC wizards come up with to compare with the CPP CPP file)

"Finish" button.

As an example "dlgtest" If the project name should be created the following files.
WTL MFC
res / dlgtest.ico


dlgtest.cpp
dlgtest.h
dlgtest.rc
MainDlg.cpp
MainDlg.h
resource.h
stdafx.cpp
stdafx.h
res / dlgtest.ico
res / dlgtest.manifest
res/dlgtest.rc2
dlgtest.cpp
dlgtest.h
dlgtest.rc
dlgtestDlg.cpp
dlgtestDlg.h
Resource.h
stdafx.cpp
stdafx.h
MainDlg (WTL) and dlgtestDlg (MFC), the name is different, the same functional class.

If you have a resource for some of the files is different, almost one to one support files.

Wizard trap (1)
(It is not more exaggerated than the trap.... )
Before it, the end of the wizard, "Finish" when you click a button to output the following error, the project may not be loaded automatically.
Class does not support automation.
This is the UIZADOSUKURIPUTO, Express does not occur because it is recognized correctly in the wizard.

WTL UIZADOSETTOAPPU of script files (setupxx.js) as follows: add a line. ※ script file,
% WTL installation directory% \ AppWiz \ setupxx.js
Our name.
xx setupxx.js of the
70: For VC + +70
71: For VC + +71
80: For VC + +80
.
90: VC + +90 for, officially, not yet. Individually, many are available on the site. We also offer at this site.


setup90.js below the 124 line and add a line per line.
1
2
3
		fileDest.WriteLine("Param=\"NO_RESOURCE_EDITOR = 1\"");
		//	add following line.
		fileDest.WriteLine("Param=\"VC_EXPRESS = 1\""); 
Change the above, after saving, double-click, and then set up.
Later in the wizard, the error would not.

When we compile and run it, you'll see a screen similar to the following simple.


To add a new button, try to display a message box
Add a new button
ResEdit using the Add button.


Here is an example
Caption: Thanks
ID: IDC_BUTTON1
And.

PIKUCHAKONTORORU and paste controls and a slider (like the message below) may cause compilation errors of the resource. This is, COMMCTRL as often happens, if the header does not load properly.
(There are problems with simple configuration. )

error RC2104: undefined keyword or key name: WC_STATIC

[Tools] - [Option]
[Solutions and Projects (Left) - [include] (Right screen)

In, Microsoft Platform SDK's include directory to the top, I'll have a strong position.
% Platform SDK installation directory% \ include
Example) C: \ Program Files \ Microsoft Platform SDK \ Include

Then, please try to rebuild implementation. I will not be in error.


Add a new button handler
The VC + +, OK after the handler of the button will be added.

[MainDlg.h add]
1
2
3
4
5
6
7
8
9
10
11
12
	BEGIN_MSG_MAP(CMainDlg)
		MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
			:
		COMMAND_ID_HANDLER(IDCANCEL, OnCancel)
		//	add following line.
		COMMAND_ID_HANDLER(IDC_BUTTON1, OnThankYou)
	END_MSG_MAP()
	:
	:
	LRESULT OnCancel(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
		// 以下の1行を追加!!
	LRESULT OnThankYou(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/);

[MainDlg.cpp added to the last line]
1
2
3
4
5
LRESULT CMainDlg::OnThankYou(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
	MessageBox("ThankYou");
	return 0;
}
Try to build and run
To build, I could easily see a message box and try to run.


So far, it was very easy. If you use MFC, many small parameter of this handler will be surprised.
COMMAND_ID_HANDLER macro definitions and further? .
1
2
3
4
5
6
7
8
#define COMMAND_ID_HANDLER(id, func) \
        if(uMsg == WM_COMMAND && id == LOWORD(wParam)) \
        { \
                bHandled = TRUE; \
                lResult = func(HIWORD(wParam), LOWORD(wParam), (HWND)lParam, bHandled); \
                if(bHandled) \
                        return TRUE; \
        }
I will certainly work to the same, wParam of a low not seen it.
MFC actually, is to be expanded as follows: To the same, wParam of a high "BN_CLICKED" after you check in, I should call the handler.
However, this is good, but now, here is precisely because we, then, MFC I want to close.
(WTL in the handler are equivalent to define it. )

[dlgtestDlg.h added to the end of]
1
2
3
4
	:
public:
	afx_msg void OnThankYou();
	:

[dlgtestDlg.cpp add]
1
2
3
4
5
6
7
8
9
10
11
12
13
BEGIN_MESSAGE_MAP(CdlgtestDlg, CDialog)
	:
	//}}AFX_MSG_MAP
	ON_BN_CLICKED(IDC_BUTTON1, OnThankYou)
END_MESSAGE_MAP()
	:
	:
	:
void CdlgtestDlg::OnThankYou()
{
	// TODO : ...
	MessageBox("ThankYou");
}
To close the MFC, WTL has been defined in the "COMMAND_HANDLER_EX" is used.
(atlclack.h MESSEJIMAPPUMAKURO Most are defined. )
Using it to make changes as follows.

[MainDlg.h Change]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
	BEGIN_MSG_MAP(CMainDlg)
		MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
			:
		COMMAND_ID_HANDLER(IDCANCEL, OnCancel)
		//	add following line.
		//COMMAND_ID_HANDLER(IDC_BUTTON1, OnThankYou)
		COMMAND_HANDLER_EX(IDC_BUTTON1, BN_CLICKED,OnThankYou)
	END_MSG_MAP()
	:
	:
	LRESULT OnCancel(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
		//	replace following line.
//	LRESULT OnThankYou(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
	void OnThankYou(UINT uNotifyCode, int nID, CWindow wndCtl);

[MainDlg.cpp Change]
1
2
3
4
5
6
//LRESULT CMainDlg::OnThankYou(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
void CMainDlg::OnThankYou(UINT uNotifyCode, int nID, CWindow wndCtl)
{
	MessageBox("ThankYou");
//	return 0;
}

Trap Wizard (2)
And the following error while compiling.
error C3867: 'CMainDlg:: OnThankYou': There is no function call argument list. To create a pointer to the Members' & CMainDlg:: OnThankYou 'Please use the
error C2143: syntax error: '; 'A' break 'not before.
error C3861: 'COMMAND_HANDLER_EX': identifier not found
Was created by the wizard, by default, WTL header and do not capture the MESSEJIMAPPUMAKURO.

I will do in stdafx.h and add the following.
1
2
3
4
5
	:
#include <atldlgs.h>
//	add
#include <atlcrack.h>      // WTL enhanced msg map macros
	:

Okay and I OMOIKI This will output the following error when you run the compiled.
error C3861: 'SetMsgHandled': identifier not found
error C3861: 'IsMsgHandled': identifier not found

This is, WTL80 or problems? It is unknown, the map defined start, "BEGIN_MSG_MAP" rather than "BEGIN_MSG_MAP_EX" is a must use.
As far as the documentation is in, WTL7.0 later, "BEGIN_MSG_MAP" but "BEGIN_MSG_MAP_EX" There is also described as good, in fact, in accordance with the document notes that "BEGIN_MSG_MAP_EX" I do not have to be.

And to do this, you should complete the build.

Trap? Nothing that is not simple, and it has to鵜呑MI the wizard, when you customize, me, and I would appreciate you KUMITOっin the sense that I care.

In fact, WTL, not to use the Wizard, ATL and I can catch and keep the chaos to create a simple wizard screens.
MFC Wizard, after using the Wizard, MFC can use the most, WTL wizard is after using the Wizard, ATL and I have to get the most use That kind of power.

Comments

Leave a Reply







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