EVC program ported to VS2005

Source: Internet
Author: User

First, VS2005 new project (with the same name as the project to be migrated, so that resources can be copied).

Ii. copy the. h and. cpp files under eVC to the new project and overwrite the original. rc file with the new project. RC.

There are several ways to copy resources, here is a quote from a netizen xuyongbeijing2008 article

Act 1:

Add another project's RC file to your project, and the resource view will appear with two RC, copy the resources from the RC to your own project RC.

Method 2:How to copy a project's dialog resource to another project in VC? This is a very professional and useful question. In fact, the VC designers have already considered this problem for us.
In the VC6 environment, select Class View, select the classes that correspond to the dialog box you want to clone, such as CAboutDlg, right-click and select Add to Gallery. Select the Project menu in the new project, select Add Component and Activx, and you will see a folder with the same name as the previous project, enter the folder, and select *.OGX.   Select Insert and you will find that the original dialog has been added to the new project.     Add:. NET easier, add the original project to the new project, directly copy the dialog box past the line. How to copy a dialog resource in the 3:vc++ method

First Step: Open the original project's. rc file with Notepad and find the information for the dialog box you want to copy, as shown below

Idd_ugms_dialogdialogex 0, 0, 320, 230
STYLE Ws_child | Ws_visible
ExStyle Ws_ex_appwindow
FONT 9, "Song Body"
BEGIN
GROUPBOX "Student Information", idc_static,10,8,290,200
GROUPBOX "", idc_static,25,55,205,120
Pushbutton "First (&f)", idc_button_first,30,30,35,15
Pushbutton "Forward (&b)", idc_button_pre,82,30,35,15
Pushbutton "Back (&n)", idc_button_next,134,30,35,15
Pushbutton "Last (&l)", idc_button_last,186,30,35,15
Pushbutton "Query (&q)", idc_button_query,246,70,40,15
Pushbutton "Increased (&a)", idc_button_add,246,96,40,15
Pushbutton "Modified (&m)", idc_button_modify,246,122,40,15
Pushbutton "Delete (&d)", idc_button_delete,246,148,40,15
Pushbutton "OK (&o)", idc_button_ok,58,183,40,15
Pushbutton "Cancel (&c)", idc_button_cancel,150,183,40,15
Ltext "School Number:", idc_static,52,75,25,8
Ltext "Name:", idc_static,52,100,25,8
Ltext "Gender:", idc_static,52,125,25,8
Ltext "Enrollment Time:", idc_static,44,151,41,8
EDITTEXT Idc_edit_sid,91,72,95,15,es_autohscroll
EDITTEXT Idc_edit_sname,91,96,95,15,es_autohscroll
EDITTEXT Idc_edit_ssex,91,120,95,15,es_autohscroll
CONTROL "DateTimePicker1", Idc_datetimepicker_scomedate,
"SysDateTimePick32", Dts_rightalign | ws_tabstop,91,144,
95,15
GROUPBOX "", idc_static,25,19,205,35
END

The green background in the above code represents the ID of the dialog resource to be copied, which is the information for this dialog box that is recorded in the. rc file, and the code in the middle of the yellow background is

The control information that is added to the corresponding dialog box is simply copied to the appropriate. rc file for the new project. The corresponding ID dialog box resource between Begin and end;

The second step: Open the original project under the FileView view of the header files under the Resource.h file, the corresponding ID of the information in the new project resource.h can be copied;

For example:

Resource ID for replication
#define IDC_BUTTON_FIRST 1000
#define IDC_BUTTON_PRE 1001
#define IDC_BUTTON_NEXT 1002
#define IDC_BUTTON_LAST 1003
#define Idc_button_query 1004
#define IDC_BUTTON_ADD 1005
#define IDC_BUTTON_MODIFY 1006
#define IDC_BUTTON_DELETE 1007
#define IDC_BUTTON_OK 1008
#define IDC_BUTTON_CANCEL 1009
#define IDC_EDIT_SID 1010
#define IDC_EDIT_SNAME 1011
#define IDC_EDIT_SSEX 1012
#define IDC_DATETIMEPICKER_SCOMEDATE 1013

The third step: remember not to omit Ah, if there is duplicate ID, you can change it.

Method 4: today encountered the module transplant problem, the dialog box class (inherited from CDialog) to be ported to the target project. I found a few posts on the Internet, which was very jerky. After asking our technical director, we finally solved the problem.
Problem: Copy one of the dialog resources and classes from an MFC SDI project to another MFC SDI.
1. Open the old project in VC6, select the resource file under the dialog folder in the Resource tab of the workspace (that is, the one that will appear in the edit window after double-clicking), press CTRL + C (Edit->copy also).
2. Close the current project, take care not to close VC6, open Target Project (file->openworkspace), then select Dialog folder in the Resource tab of the workspace, and then press CTRL + V (Edit->paste also). OK, the dialog box is copied over.
3. Copy the CPP H file of the dialog class to the target project (not detailed, add files to the current project)
4. Open the copied class CPP and h files, delete the unused header files (old engineering related), and add the files contained in the. h file
#include "Resource.h" The fourth step is critical, the old project is not included in this file, but after the migration must be manually added header file contains. Because the problem stuck 10 minutes ...
This class can then be used in the new project, mainly in the dialog box of this class, where the resources are duplicated for the first time. Dare not to enjoy, take out to learn with the novice.

Then, when you have created a dialog resource to add to the new project: (1) Right-click the solution where the new project is located add "existing project" to add the old project, (2) switch to "Resource View" and right-click "Copy" on the Old Project dialog resource, (3) Right-click "Paste" on the resource of the New Project dialog box; (4) You can now add classes for the New dialog box, copy the response function of the old project, and (5) switch back to Solution Explorer, and right-click the old project "remove".

Third, modify the error


This also refers to the content of a Ziseliuxingzh blog


1, StdAfx.cpp (Resealse mode also need to change)
Compilation error: D:program filesmicrosoft Visual Studio 8vcceatlmfcincludeafxver_.h (): Fatal error C1189: #error: Please use the/ MD switch for _afxdll builds
Workaround: Right-click the project name, open the Project Properties dialog box, switch to the C/c++->code generation page, set the runtime libarary to "multi-threaded DLL (/MD)", To resolve this issue.
2, compile Error: Error C2065: ' I ': undeclared identifier
Cause: This is due to the presence of the following code snippet:
for (int i = 0; i < Max_len; i + +)
{
......
}
for (i = 0; i < max_num; i + +)
{
......
}
For eVC to leave the loop, the loop variable is still valid, and can still be used, but under the VS2005 is not possible, it is obvious that VS2005 the definition of variables and review more stringent, there is also the problem of cross-boundary is more than EVC to strong.
Workaround: (Cannot fully trust the compiler, nor can you throw all grammar checks to the compiler)
int i = 0;
for (i = 0; i < Max_len; i + +)
{
......
}
for (i = 0; i < max_num; i + +)
{
......
}
3. Error C2664: ' _wcsnicmp ': cannot convert parameter 2 from ' Lpword ' to ' const wchar_t * '
Type conversions need to be enforced.
4. Error C2061:syntax error:identifier ' Helpinfo '
Add yourself to the Helpinfo type and add the header file HelpInfo.h.
5, error C2146:syntax error:missing '; ' before identifier ' M_wndcommandbar '
Cause: Ccecommandbar class is CCommandBar replaced under Windows Mobile 5.0/6.0
Workaround:
Ccecommandbar M_wndcommandbar; ----〉ccommandbar M_wndcommandbar;
6, Error C2065: ' num_tool_tips ': undeclared identifier
Solve:
#if defined (_WIN32_WCE_PSPC) && (_win32_wce >= 212)
#define NUM_TOOL_TIPS 8
#endif
7, Error C3861: ' on_wm_helpinfo ': identifier not found
Same 4
8. Error C2440: ' static_cast ': cannot convert from ' void (__cdecl Cmyappview::*) (void) ' to ' LRESULT (__cdecl CWnd::*) (WP Aram,lparam) ' None of the functions with this name in scope match the target type
Workaround:
afx_msg void Onhotlinkexplain (); --- 〉
afx_msg LRESULT onhotlinkexplain (WPARAM wparam,lparam LPARAM);
9. Error C2664: ' CSize cdc::gettextextent (lpctstr,int) const ': cannot convert parameter 1 from ' WORD * ' to ' LPCTSTR '
Types pointed to is unrelated; Conversion requires reinterpret_cast, C-style cast or Function-style cast required cast
Pdc->gettextextent (&i, 1). CX); -
Pdc->gettextextent ((LPCTSTR) &i, 1). CX;
10, Error C2039: ' Onhelpinfo ': is not a member of ' CView '
Error C2039: ' Onhelpinfo ': is not a member of ' CFrameWnd '
Error C2039: ' Onhelpinfo ': is not a member of ' CDialog '
Workaround: Replace the corresponding class member function with True Onhelpinfo '
Return Cview::onhelpinfo (Phelpinfo); --Return TRUE;
11, Error C2039: ' m_bShowSharedNewButton ': is not a member of ' CCommandBar '
D:program filesmicrosoft Visual Studio 8VCceatlmfcincludeafxext.h (557): See Declaration of ' CCommandBar '
Workaround:
Directly comment out M_wndcommandbar.m_bshowsharednewbutton = FALSE;
12,. Myapp.rc (380): Fatal error Rc1015:cannot open include file ' wceres.rc '.
Workaround:
Directly commented out: #include "wceres.rc"//Wce-specific components
However, this error is annoying, every time you modify the resource file, you have to modify the statement, do not know why.
13, Resease mode also want to modify
Error lnk2019:unresolved external symbol Shinitextracontrols referenced in function "protected: __cdecl Cmyappview::cmya Ppview (void) "(0cmyappview@ @IAA @xz)
Problem: Shinitextracontrols () was called in the program;
Error lnk2019:unresolved external symbol shsippreference referenced in function "protected:void __cdecl Cmyappview::onki Llfocusword (void) "(onkillfocusword@cmyappview@ @IAAXXZ)
Problem: Shsippreference was called in the program
All of the above two functions are in: Library:aygshell.lib
Workaround:
Engineering--Properties-->linker-->input--> Additional Denpendencies:aygshell.lib
14, Resease mode also want to modify
Orelibc.lib (wwinmain.obj): Error lnk2019:unresolved external symbol wWinMain referenced in function wWinMainCRTStartup
Property-〉linker-〉anvanced-〉entrypoint
Change wWinMainCRTStartup to WinMainCRTStartup
Entry Point is WinMainCRTStartup (ANSI) or wWinMainCRTStartup (Uincode), which is: ... WinMainCRTStartup or wWinMainCRTStartup will call WinMain or wWinMain.
15, Error C3861: ' loadstdprofilesettings ': identifier not found
Comment out function loadstdprofilesettings;
The function of the specific function, see MSDN.
BTW: Compile time, there may be some of the above errors generated by the chain error, commonly known as "butterfly Effect", such as error C2143:syntax error:missing '; ' Before '} '
Error C2143:syntax error:missing '; ' Before ', '
Error C2143:syntax error:missing '; ' Before ' {'
Less ' {', '} ', '; ' And so on, the above error-the main contradiction solved, these errors-wrong contradiction will be solved. Moreover, this project was previously compiled under the eVC IDE, MS, how to optimize or improve the compiler, it is not always possible to contradict things, always consider the compatibility bar, to themselves or the company's predecessors have confidence.
To this, it has been able to compile the pass, but when running, the following problems appear:
16, Resease mode also want to modify
Press F5 and the following dialog box appears:

Workaround:
Right-click the properties of the project-〉general-〉project Defaults–〉use MFC:
Use MFC in a shared dll--> with MFC in a static DLL
Because of this, the EXE program produced by VS2005 is more than 200 k larger than eVC.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.