Solved

Migrating from win32 APP to MFC

Posted on 2006-07-19
7
494 Views
Last Modified: 2008-02-01
Hi,

     Is there any easy way to migrate from application that develop with win32 app to mfc? or have to redo everything in mfc?

Regards
0
Comment
Question by:iphone
7 Comments
 
LVL 12

Expert Comment

by:rajeev_devin
ID: 17136770
>> Is there any easy way to migrate from application that develop with win32 app to mfc?
No, you need a lot of work.
0
 
LVL 48

Expert Comment

by:AlexFM
ID: 17136895
You need to create application using MFC Application Wizard and rewrite main functions. Only low-level stuff from existing application can be used. For example, if you have drawing function which accepts HDC parameter, you can call it from MFC CWnd::OnPaint passing CDC::m_hDC.

Out of topic: Is it time to move to MFC?
0
 
LVL 7

Expert Comment

by:nafis_devlpr
ID: 17137394
it actually depends on how the wrapper classes were designed. If you have called functions for a certain job when an event was fired then you will find it really easy to migrate the codes from win32App to MFC, cause in that case you will just have to design the user interface and the message maps and call the functions accordingly.

On the other hand if you hardcoded the instructions inside the event messages then you should get prpared for some real hard work.

Nafis
0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
LVL 86

Expert Comment

by:jkr
ID: 17138367
>>Is there any easy way to migrate from application that develop with win32 app to mfc?

If you already have a working application - why would you want to do that?
0
 

Author Comment

by:iphone
ID: 17143535
Because i want to load external SWF(Flash files) and play in the application, i ever ask this question and the best answer i found is use browser object to open html page which load SWF in there. So far the solution i have to achive this is only support for MFC programming. Is there any other way i could done in Win32 APP? The SWF is external file.

0
 
LVL 39

Expert Comment

by:itsmeandnobodyelse
ID: 17147431
>>>>Is there any easy way to migrate from application that develop with win32 app to mfc?

No, but it shouldn't be a task impossible. If your current application has a main dialog window you should create a dialog-based MFC app by using the Wizard. Then, you should be able to import your current resource-file by copy-paste. Add dialog classes for all dialogs you have and add an appropriate CString member for any edit field. For any button or menu you should add the equivalent item in the resource editor. Finally add (empty) handler functions for any event you currently were handling in the WIN32 app. Key events you better handle by accelerator entries. All drawing issues you should move to OnPaint member function of your diaolg class. Note most WINAPI functions have an equivalent in MFC by simply replacing the handle argument by the class object:

    HWND hwnEdit = GetDlgItem(hwndDlg, IDC_EDIT);
    SetWindowText(hwndEdit, "Hello World");

==>

   myDlg.GetDlgItem(IDC_EDIT)->SetWindowText("Hello World);

If you call the latter in a member function of MyDlg you can/have to omit the "myDlg."  I would recommend to migrate all WINAPI call to the corresponding MFC member call if available.

Always consider that a MFC application is reacting on messages rather than actively controlling the screen. So, don't migrate lengthy parts of your current app but always try keep it short and simple, e. g. send/post messages instead of doing all at one time. Then you can react in a different event handler what makes the app quick and user friendly.

Regards, Alex
 
0
 
LVL 22

Accepted Solution

by:
mahesh1402 earned 500 total points
ID: 17152034
I am not sure 'MFC migration tool kit' still available or not....Many developers have existing applications for Windows written in C/Win32 API. To help these developers migrate their applications to C++, the MFC Migration Kit supplies the following:
· MFC Migration Guide: a help file that takes you through the migration process sample applications using MFC.
· A migration tool  that scans your C language source code and suggests things you should do to migrate the code to MFC.
· sample applications, before migration, in C, and after migration, in C++.

The migration tool can also help you port applications  with or without MFC. The MFC Migration Guide explains how that port fits into your migration strategy.

http://support.microsoft.com/default.aspx?scid=kb;en-us;122764 <=====

This migration kit shows you how to convert a C program for Windows to C++, by using MFC. You can gain most of the benefits of C++ and MFC with a minimum of pasting code into MFC classes and a minimum of C-to-C++ translation.

-MAHESH
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question