I need advice on how to convert MFC dependent source to non-MFC
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10

Thread: I need advice on how to convert MFC dependent source to non-MFC

Hybrid View

  1. #1
    Join Date
    Jun 2008
    Location
    greater Cincinnati
    Posts
    54

    Question I need advice on how to convert MFC dependent source to non-MFC

    Hello to anyone who reads this!

    IDE = Visual Studio 2008 Express


    I am a novice programmer(still...) , and I am trying to build the Code Project project located at this address:
    http://www.codeproject.com/Articles/...t=4330960&fr=1

    The project page is titled " Remote Control PCs ".

    I would like to use this program plus I wanted to practice programming using the code base. However, I don't have MFC so I thought I would just convert it to non-MFC.


    =========What I Need Help With==============

    ----First Issue-


    I don't fully know what needs to be done or how to go about doing it. So I was wondering if someone could browse through the code(the source is relatively small) and give me some advice on what all needs to be changed.

    And I was also wanting some advice on perhaps how to make these changes.

    For example, It seems to me that any class inherited from MFC would need to be reimplemented. I think I also need to reimplement any code that uses "stdafx.h"

    I don't fully know how to do the above so if someone could give some pointers that would really help(I think).



    ----Second Issue-


    In the second paragraph Andy Blantly wrote that

    Quote Originally Posted by Andy Blantly-Code Project
    I built a custom project out of the zlib library and compiled it as a Windows library with the /MT settings. Both 32 and 64 bit library files, in Release and Debug mode, are included. The ZLIB.H and ZCONF.H files are also included. For examples of single-threaded usage, see the CZLib class. For examples of multi-threaded usage, see the classes CDriveMultiThreadedCompression, CMultiThreadedCompression, and CZLib.

    1)How should I go about compiling this zlib custom project?
    2)Where does the /MT option go ?
    3)How do I use the output ( zlib.lib - I guess)?


    ===============================


    Thank you very much for your time, and
    a very good day to everyone!
    Last edited by kmkkra; February 25th, 2013 at 04:46 PM.

  2. #2
    Join Date
    Apr 1999
    Posts
    27,446

    Re: I need advice on how to convert MFC dependent source to non-MFC

    Quote Originally Posted by kmkkra View Post
    I am a novice programmer(still...) , and I am trying to build the Code Project project located at this address:
    http://www.codeproject.com/Articles/...t=4330960&fr=1

    The project page is titled " Remote Control PCs ".

    I would like to use this program plus I wanted to practice programming using the code base. However, I don't have MFC so I thought I would just convert it to non-MFC.
    If you're a novice, then the last thing you should be attempting to do is to convert from one framework to no framework. Only an experienced programmer who knows both enviroments would know what to do, and do it correctly with a minimum of problems.

    Why not compile the code and run it to see how it works first? Then step through the code to see how each piece operates. Then you have to figure out how the MFC class works. Then you need to know the equivalent of this using the Windows API, and that in itself could be a project.

    And this is assuming you know the C++ properly without any problems whatsoever with the language. No questions on "what's a string consist of" or "how do you use pointers correctly", "when do you use the heap", etc.

    Regards,

    Paul McKenzie

  3. #3
    Join Date
    Jun 2008
    Location
    greater Cincinnati
    Posts
    54

    Re: I need advice on how to convert MFC dependent source to non-MFC

    Quote Originally Posted by Paul McKenzie View Post
    If you're a novice, then the last thing you should be attempting to do is to convert from one framework to no framework. Only an experienced programmer who knows both environments would know what to do, and do it correctly with a minimum of problems.
    Well, maybe I should have said ~intermediate. I am not sure exactly how to gauge my understanding of C++. Right now I am trying to learn about Object Oriented analysis and design, and I think I have a rough understanding of it, so far. I do, however, still need to practice , a lot, with well written C++ code bases or frameworks.

    I feel that if I am given a little guidance then I should eventually be able to make the necessary conversions. I only need to get a hack up and running to help give me an idea of the flow of execution. Then I can gradually legitimize the hack as I learn.






    Quote Originally Posted by Paul McKenzie View Post
    Why not compile the code and run it to see how it works first? Then step through the code to see how each piece operates.
    Oh sorry, I originally forgot the word "Express" in "Visual Studio Express" within my first post. I just now went ahead and amended it.

    I would compile the code but I only have Visual Studio 2008 Express and subsequently no MFC, so it won't compile without a lot errors.

    Quote Originally Posted by Paul McKenzie View Post
    Then you have to figure out how the MFC class works. Then you need to know the equivalent of this using the Windows API, and that in itself could be a project.

    I think I can handle this... But then again, I am currently just looking to get a hack up and running and then I will gradually fix the hack as I am able.



    Best wishes to you McKenzie.
    Last edited by kmkkra; February 25th, 2013 at 05:58 PM.

  4. #4
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,070

    Re: I need advice on how to convert MFC dependent source to non-MFC

    Quote Originally Posted by kmkkra View Post
    I think I can handle this... But then again, I am currently just looking to get a hack up and running and then I will gradually fix the hack as I am able.
    Sorry, but a hack is not an option here. You either re-invent framework by writing your own one but having application class level APIs looking identical to MFC classes, or literally port every MFC line to non-MFC construct along with primitives/constructs lying underneath. And both cases explicitly require for master level in MFC, Win32 API, designing C++ APIs, etc.

    Even porting to WTL is going to be way too over intermediate level, I think, though I'm not an expert in WTL.

    As for VS Express version. Some time ago MFC4.2 and ATL3.0 were available as a part of some MS Platform SDK, PSDK Win2003Server AFAIR. So you always can start with this free-of-charge option.
    Best regards,
    Igor

  5. #5
    Join Date
    Jun 2008
    Location
    greater Cincinnati
    Posts
    54

    Re: I need advice on how to convert MFC dependent source to non-MFC

    Quote Originally Posted by Igor Vartanov View Post
    Sorry, but a hack is not an option here. You either re-invent framework by writing your own one but having application class level APIs looking identical to MFC classes, or literally port every MFC line to non-MFC construct along with primitives/constructs lying underneath. And both cases explicitly require for master level in MFC, Win32 API, designing C++ APIs, etc.
    I seem to be finding all the MFC code pretty easily so I may just give one of these options a go.


    Quote Originally Posted by Igor Vartanov View Post
    As for VS Express version. Some time ago MFC4.2 and ATL3.0 were available as a part of some MS Platform SDK, PSDK Win2003Server AFAIR. So you always can start with this free-of-charge option.
    I'll look into this.




    Thanks Igor.

  6. #6
    Join Date
    Apr 1999
    Posts
    27,446

    Re: I need advice on how to convert MFC dependent source to non-MFC

    Quote Originally Posted by kmkkra View Post
    I feel that if I am given a little guidance then I should eventually be able to make the necessary conversions. I only need to get a hack up and running to help give me an idea of the flow of execution. Then I can gradually legitimize the hack as I learn.
    I think the whole idea of doing a line-by-line, function-by-function translation is not a good way to go about this.

    Take a step back and ask yourself what the program it is you're trying to write supposed to do. Is it just to translate a framework into a non-framework, or is it to do remote PC access? If it is the latter, then why not study how this is done using the Win32 API and other libraries? You don't need MFC for that.

    You start by writing small C++ programs (maybe even console programs) that test the API calls to see how they work. Then you put together an application, wrapping the core and knowledge you gained from the small programs with a framework, whether it is MFC, Qt, WTL, or whatever you want.

    Regards,

    Paul McKenzie

  7. #7
    Join Date
    Jun 2008
    Location
    greater Cincinnati
    Posts
    54

    Re: I need advice on how to convert MFC dependent source to non-MFC

    Quote Originally Posted by Paul McKenzie View Post
    I think the whole idea of doing a line-by-line, function-by-function translation is not a good way to go about this.
    Quote Originally Posted by Paul McKenzie View Post
    You start by writing small C++ programs (maybe even console programs) that test the API calls to see how they work.

    I suppose your right. It, typically, may be better just starting from scratch. But my problem is that I have a psychological disorder( I'm embarrassed to admit)that has been quite debilitating, and has held me back tremendously in life.
    (I've slowly been recuperating over the past year though... Hope to fully recuperate soon!)

    Allthough, for me, under my circumstances, I think I may be better off working with this dude's code since it already seems to have all the bells and whistles. But I may start from scratch at some point. In fact, if I weren't so debilitated I , more than likely, would work from scratch.


    Good day!
    Last edited by kmkkra; February 28th, 2013 at 10:23 PM.

  8. #8
    Join Date
    Apr 1999
    Posts
    27,446

    Re: I need advice on how to convert MFC dependent source to non-MFC

    Quote Originally Posted by kmkkra View Post
    I suppose your right. It, typically, may be better just starting from scratch. But my problem is that I have a psychological disorder( I'm embarrassed to admit)that has been quite debilitating, and has held me back tremendously in life.
    (I've slowly been recuperating over the past year though... Hope to fully recuperate soon!)
    No problem. I wish you good luck in your future endeavors.

    Since zlib was mentioned, I think you should start with that. I know you don't need a wrapper for it, because I have used it without any wrapper. If you compile the sources and read the documentation, you should be able to call inflate and deflate functions, testing them on various files to see if they work.

    Once you see that you've written functions without a framework to get zlib to work, then you put that to the side and work on something else. At the end, you have these components built up and you then use them in the larger app.

    Regards,

    Paul McKenzie

  9. #9
    Join Date
    Feb 2013
    Location
    United States
    Posts
    56

    Re: I need advice on how to convert MFC dependent source to non-MFC

    You could use LoadLibrary() to load the ZLIB DLL you are using and then GetProcAddress() to get the export function addresses. You would then need to create "function declarations" (I forgot the correct terminology) for each export function. For example:
    Code:
    typedef int (__cdecl* uncompress_function)(unsigned char*, unsigned int*, unsigned char*, unsigned int);
    where uncompress_function is the type name I made up. You then call the exported function like this:
    Code:
    uncompress_function UncompressFunction = GetProcAddress(ZLIBModuleHandle, "uncompress");
    int Result = (*UncompressFunction)(DestinationBuffer, &DestinationBufferSize, SourceBuffer, SourceBufferSize);
    This is just an example. The actual export functions and their interfaces will depend on the specific DLL. You will need very good documentation for that DLL.
    MFC functions are often just wrapper functions, so it may not be too hard to figure out what they are doing.
    Last edited by Coder Dave; February 27th, 2013 at 06:01 AM.

  10. #10
    Join Date
    Jun 2008
    Location
    greater Cincinnati
    Posts
    54

    Re: I need advice on how to convert MFC dependent source to non-MFC

    @Coder Dave - post #7


    Thank you very much for your insight. However, "Andy Blantly-Code Project" wrote a custom project out of the zlib and it's a dependency for the other two projects. I was wondering (in post #1) what, if anything, needs to be done both pre- and post- compile of the zlib project. I was hoping that I don't need to do anything, -- but I don't know...


    Good day!
    Last edited by kmkkra; February 28th, 2013 at 10:21 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center