Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. ATL / WTL / STL
  4. Migration from MFC to STL

Migration from MFC to STL

Scheduled Pinned Locked Moved ATL / WTL / STL
c++css
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hrishi321
    wrote on last edited by
    #1

    Hello all, Could anyone please give me a efficient method and suggestions for the following. I have many classes already in my VC++ project, which were build on MFC. Meaning the data types were MFC based. like CByteArray, CString etc etc. Now I need to avoid the uses of MFC data types , and introduce STL data types. could you please give me an efficient and less time consuming method to migrate the same. For eg: shal I use my own classes to mimic MFC classes like CString. or correct each uses/mehtod of MFC classes wherver there is, and change with STL based methods.... I am a bit confuse. please suggest me thanks in advance Hrishi

    A A B 3 Replies Last reply
    0
    • H hrishi321

      Hello all, Could anyone please give me a efficient method and suggestions for the following. I have many classes already in my VC++ project, which were build on MFC. Meaning the data types were MFC based. like CByteArray, CString etc etc. Now I need to avoid the uses of MFC data types , and introduce STL data types. could you please give me an efficient and less time consuming method to migrate the same. For eg: shal I use my own classes to mimic MFC classes like CString. or correct each uses/mehtod of MFC classes wherver there is, and change with STL based methods.... I am a bit confuse. please suggest me thanks in advance Hrishi

      A Offline
      A Offline
      Alain Rist
      wrote on last edited by
      #2

      Hi Hrishi,

      hrishi321 wrote:

      I have many classes already in my VC++ project, which were build on MFC. Meaning the data types were MFC based. like CByteArray, CString etc etc. Now I need to avoid the uses of MFC data types , and introduce STL data types.

      As MFC internally uses its own collection and string classes, you will increase your code footprint, and keep dependancy on all MFC classes and data types. Anyhow you can use CStdString[^] as drop-in replacement for CString, and you should write your own CStdByteArray etc.. based on STL collections and exposing the same interface as the matching MFC collections. It could be an interesting CodeProject article :) Good luck! AR

      When the wise (person) points at the moon the fool looks at the finger (Chinese proverb)

      H 1 Reply Last reply
      0
      • H hrishi321

        Hello all, Could anyone please give me a efficient method and suggestions for the following. I have many classes already in my VC++ project, which were build on MFC. Meaning the data types were MFC based. like CByteArray, CString etc etc. Now I need to avoid the uses of MFC data types , and introduce STL data types. could you please give me an efficient and less time consuming method to migrate the same. For eg: shal I use my own classes to mimic MFC classes like CString. or correct each uses/mehtod of MFC classes wherver there is, and change with STL based methods.... I am a bit confuse. please suggest me thanks in advance Hrishi

        A Offline
        A Offline
        Albert Holguin
        wrote on last edited by
        #3

        There's A LOT that goes into writing a framework, so you certainly don't want to write your own replacement classes. Depending on how much of the project is MFC based, you may have issues trying to replace with only STL calls. Some concepts don't exactly translate well, for example, what is a CDialog (the base for creating dialogs in MFC)? Well, its a bunch of WinAPI calls that create windows, configure properties, and act as a container for code within the dialog. How would you replicate that with STL alone? You can, but its a lot of work, STL is not exactly a framework that comes equipped as an MFC replacement (or replacement for any type of framework for that matter).

        H 1 Reply Last reply
        0
        • A Alain Rist

          Hi Hrishi,

          hrishi321 wrote:

          I have many classes already in my VC++ project, which were build on MFC. Meaning the data types were MFC based. like CByteArray, CString etc etc. Now I need to avoid the uses of MFC data types , and introduce STL data types.

          As MFC internally uses its own collection and string classes, you will increase your code footprint, and keep dependancy on all MFC classes and data types. Anyhow you can use CStdString[^] as drop-in replacement for CString, and you should write your own CStdByteArray etc.. based on STL collections and exposing the same interface as the matching MFC collections. It could be an interesting CodeProject article :) Good luck! AR

          When the wise (person) points at the moon the fool looks at the finger (Chinese proverb)

          H Offline
          H Offline
          hrishi321
          wrote on last edited by
          #4

          Thank you so much for your kind suggestion. I already started my implementation. Thought I am sure, I will have small doubts on my path. As a starter, I am trying to implement the CBytearray, Could you please tell me, whether do I need to implement FreeExtra() method of MFC CBytearray, in my stl:: vector? . Is there any methods to mimic this? Or actually STL tales care of it own?

          A 1 Reply Last reply
          0
          • A Albert Holguin

            There's A LOT that goes into writing a framework, so you certainly don't want to write your own replacement classes. Depending on how much of the project is MFC based, you may have issues trying to replace with only STL calls. Some concepts don't exactly translate well, for example, what is a CDialog (the base for creating dialogs in MFC)? Well, its a bunch of WinAPI calls that create windows, configure properties, and act as a container for code within the dialog. How would you replicate that with STL alone? You can, but its a lot of work, STL is not exactly a framework that comes equipped as an MFC replacement (or replacement for any type of framework for that matter).

            H Offline
            H Offline
            hrishi321
            wrote on last edited by
            #5

            thanks for your suggestion. After doing a small research and checking the amount of use of the MFC types, I have decided to implement the MFC types, whichever are in my project, and of-course not all methods but eh necessary ones. :) I will have many doubts during this course of time, Hope to keep getting advices from you :) thanks hrishi

            1 Reply Last reply
            0
            • H hrishi321

              Thank you so much for your kind suggestion. I already started my implementation. Thought I am sure, I will have small doubts on my path. As a starter, I am trying to implement the CBytearray, Could you please tell me, whether do I need to implement FreeExtra() method of MFC CBytearray, in my stl:: vector? . Is there any methods to mimic this? Or actually STL tales care of it own?

              A Offline
              A Offline
              Alain Rist
              wrote on last edited by
              #6

              Hi, If your compiler supports C++2011 (VC2010 or gcc 4.5) std::vector::shrink_to_fit() is the functional equivalent to CByteArray::FreeExtra().If you are on C++2003 use v.reserve(v.size()) to achieve the same goal. cheers, AR

              When the wise (person) points at the moon the fool looks at the finger (Chinese proverb)

              1 Reply Last reply
              0
              • H hrishi321

                Hello all, Could anyone please give me a efficient method and suggestions for the following. I have many classes already in my VC++ project, which were build on MFC. Meaning the data types were MFC based. like CByteArray, CString etc etc. Now I need to avoid the uses of MFC data types , and introduce STL data types. could you please give me an efficient and less time consuming method to migrate the same. For eg: shal I use my own classes to mimic MFC classes like CString. or correct each uses/mehtod of MFC classes wherver there is, and change with STL based methods.... I am a bit confuse. please suggest me thanks in advance Hrishi

                B Offline
                B Offline
                Bram van Kampen
                wrote on last edited by
                #7

                Why do you want to do that! Horses for Courses. Do you also want to migrate from Exel to Word? Regards, :)

                Bram van Kampen

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups