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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. MFC To ATL problems ??????

MFC To ATL problems ??????

Scheduled Pinned Locked Moved C / C++ / MFC
c++comtutorialquestion
12 Posts 3 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.
  • L Offline
    L Offline
    Leesen
    wrote on last edited by
    #1

    Is there any tool like java2idl that can directly change MFC code into ATL code??? I am now modify some MFC code ,in order to change it into a COM .But there are lots of problems, such as,type dismatch, return value . Anyone have some ideas about the steps how to proceed . I will preciate it. regards.

    C 1 Reply Last reply
    0
    • L Leesen

      Is there any tool like java2idl that can directly change MFC code into ATL code??? I am now modify some MFC code ,in order to change it into a COM .But there are lots of problems, such as,type dismatch, return value . Anyone have some ideas about the steps how to proceed . I will preciate it. regards.

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      No tool will do this for you. First of all, if you've used any of the MFC classes like CArray and CString, you'll need to convert them. Second, if you want GUI in ATL it's totally different. Third, because of marshalling, you cannot send any type you want through any exposed functions, and of course there is the whole issue of the IDL, and the functions you choose to expose. What sort of app is it ? Why do you want to convert it ? Christian come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002

      L 1 Reply Last reply
      0
      • C Christian Graus

        No tool will do this for you. First of all, if you've used any of the MFC classes like CArray and CString, you'll need to convert them. Second, if you want GUI in ATL it's totally different. Third, because of marshalling, you cannot send any type you want through any exposed functions, and of course there is the whole issue of the IDL, and the functions you choose to expose. What sort of app is it ? Why do you want to convert it ? Christian come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002

        L Offline
        L Offline
        Leesen
        wrote on last edited by
        #3

        But as I know , ATL can support MFC. Then could me use the MFC Class like CArray and CString. Because if I modify the software into COM ,the it can be used more freely .Do you think it is worth doing. If I choose surpport MFC checkbox when create a new ATL project, could me just copy the MFC Class into ATL class?

        C 1 Reply Last reply
        0
        • L Leesen

          But as I know , ATL can support MFC. Then could me use the MFC Class like CArray and CString. Because if I modify the software into COM ,the it can be used more freely .Do you think it is worth doing. If I choose surpport MFC checkbox when create a new ATL project, could me just copy the MFC Class into ATL class?

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          Bliven wrote: But as I know , ATL can support MFC. Yes, and I don't know of anyone ever doing it. ATL and MFC have different goals and only a fool would merge the two. Bliven wrote: Then could me use the MFC Class like CArray and CString. The fact that CArray is crap and std::String is usually perfectly alright being a side issue. Bliven wrote: Because if I modify the software into COM ,the it can be used more freely I guess, it can be used from VB, etc. Bliven wrote: Do you think it is worth doing. I have no idea. I asked you what your project was, and you've not answered me. Bliven wrote: If I choose surpport MFC checkbox when create a new ATL project, could me just copy the MFC Class into ATL class? If you used MFC in ATL, it would just work. The question though is, is this a GUI app, and if so, why do you think it will help to rewrite it as a COM app ? Christian come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002

          L T 2 Replies Last reply
          0
          • C Christian Graus

            Bliven wrote: But as I know , ATL can support MFC. Yes, and I don't know of anyone ever doing it. ATL and MFC have different goals and only a fool would merge the two. Bliven wrote: Then could me use the MFC Class like CArray and CString. The fact that CArray is crap and std::String is usually perfectly alright being a side issue. Bliven wrote: Because if I modify the software into COM ,the it can be used more freely I guess, it can be used from VB, etc. Bliven wrote: Do you think it is worth doing. I have no idea. I asked you what your project was, and you've not answered me. Bliven wrote: If I choose surpport MFC checkbox when create a new ATL project, could me just copy the MFC Class into ATL class? If you used MFC in ATL, it would just work. The question though is, is this a GUI app, and if so, why do you think it will help to rewrite it as a COM app ? Christian come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002

            L Offline
            L Offline
            Leesen
            wrote on last edited by
            #5

            Yes, it is a GUI app , just like foxmail .And it is a MFC app. And now my boss asked me to choose out the core code and organize it into a COM , without any GUI function. Thus ,the core code as a COM can be referenced as a dll in vb, asp and so on. And the client GUI can be designed with vb. I planned to rewrite it ,but the source code is so large and so obscurity . So I want to ask for a simple way to do this work .

            C 1 Reply Last reply
            0
            • C Christian Graus

              Bliven wrote: But as I know , ATL can support MFC. Yes, and I don't know of anyone ever doing it. ATL and MFC have different goals and only a fool would merge the two. Bliven wrote: Then could me use the MFC Class like CArray and CString. The fact that CArray is crap and std::String is usually perfectly alright being a side issue. Bliven wrote: Because if I modify the software into COM ,the it can be used more freely I guess, it can be used from VB, etc. Bliven wrote: Do you think it is worth doing. I have no idea. I asked you what your project was, and you've not answered me. Bliven wrote: If I choose surpport MFC checkbox when create a new ATL project, could me just copy the MFC Class into ATL class? If you used MFC in ATL, it would just work. The question though is, is this a GUI app, and if so, why do you think it will help to rewrite it as a COM app ? Christian come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002

              T Offline
              T Offline
              Tim Smith
              wrote on last edited by
              #6

              CAtlArray is MUCH better than MFC array (thank god). Also, for UNICODE/MLSU/ANSI applications, std::string has too many limitations. I have found that CStringT works much better in Windows applications. Tim Smith "Programmers are always surrounded by complexity; we can not avoid it... If our basic tool, the language in which we design and code our programs, is also complicated, the language itself becomes part of the problem rather that part of the solution." Hoare - 1980 ACM Turing Award Lecture

              C 1 Reply Last reply
              0
              • L Leesen

                Yes, it is a GUI app , just like foxmail .And it is a MFC app. And now my boss asked me to choose out the core code and organize it into a COM , without any GUI function. Thus ,the core code as a COM can be referenced as a dll in vb, asp and so on. And the client GUI can be designed with vb. I planned to rewrite it ,but the source code is so large and so obscurity . So I want to ask for a simple way to do this work .

                C Offline
                C Offline
                Christian Graus
                wrote on last edited by
                #7

                OK, now we have some idea what we are talking about. Have you done COM before ? You should create an ATL project, preferably NOT with MFC, but I dunno if you're stuck with that for ease of porting, define your interfaces and then try to port your code across. There is no automatic way to do that. Christian come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002

                L 1 Reply Last reply
                0
                • T Tim Smith

                  CAtlArray is MUCH better than MFC array (thank god). Also, for UNICODE/MLSU/ANSI applications, std::string has too many limitations. I have found that CStringT works much better in Windows applications. Tim Smith "Programmers are always surrounded by complexity; we can not avoid it... If our basic tool, the language in which we design and code our programs, is also complicated, the language itself becomes part of the problem rather that part of the solution." Hoare - 1980 ACM Turing Award Lecture

                  C Offline
                  C Offline
                  Christian Graus
                  wrote on last edited by
                  #8

                  Tim Smith wrote: Also, for UNICODE/MLSU/ANSI applications, std::string has too many limitations. You'll note I am not as damning of CString, there are definately ways in which it is better than std::string. I tend to use std::string, std::wstring and _bstr_t myself, but CString is not actually inferior, as CArray is. Christian come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002

                  1 Reply Last reply
                  0
                  • C Christian Graus

                    OK, now we have some idea what we are talking about. Have you done COM before ? You should create an ATL project, preferably NOT with MFC, but I dunno if you're stuck with that for ease of porting, define your interfaces and then try to port your code across. There is no automatic way to do that. Christian come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002

                    L Offline
                    L Offline
                    Leesen
                    wrote on last edited by
                    #9

                    I plan to copy all the MFC Class ,Including GUI Class ,such as Frmae,View, to the Atl Project .And it can be complied successfully. Then I can further modify the Atl project based on that. I will add some interface in Atl project to call function instead of the automation message loop . In this way , I think I could let the Atl dll run in VB GUI,with his own GUI (Frame ,view,Dialog ) just loaded in memory and not shown. This is my idea . What do you think of it ? I just want to get a general structrue ,and then I can modify the Atl code into more simple project,such as change Frame,view into other substitutes. In this way ,I can achieve my goal. Expecting your advice. Now I have copied all the MFC Class ,Including GUI Class ,such as Frmae,View,from the MFC Project to the Atl Project .And it can be complied successfully. But when I attempt to register the DLL I get the following error: Debug Assertion Failed! Program: C:\WINNT\System32\regsvr32.exe File: D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\APPCORE.CPP Line: 85 Expression: ASSERT(AfxGetThread() == NULL); So what does this really tell me and what can I do to correct it? Any ideas???

                    C 1 Reply Last reply
                    0
                    • L Leesen

                      I plan to copy all the MFC Class ,Including GUI Class ,such as Frmae,View, to the Atl Project .And it can be complied successfully. Then I can further modify the Atl project based on that. I will add some interface in Atl project to call function instead of the automation message loop . In this way , I think I could let the Atl dll run in VB GUI,with his own GUI (Frame ,view,Dialog ) just loaded in memory and not shown. This is my idea . What do you think of it ? I just want to get a general structrue ,and then I can modify the Atl code into more simple project,such as change Frame,view into other substitutes. In this way ,I can achieve my goal. Expecting your advice. Now I have copied all the MFC Class ,Including GUI Class ,such as Frmae,View,from the MFC Project to the Atl Project .And it can be complied successfully. But when I attempt to register the DLL I get the following error: Debug Assertion Failed! Program: C:\WINNT\System32\regsvr32.exe File: D:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\APPCORE.CPP Line: 85 Expression: ASSERT(AfxGetThread() == NULL); So what does this really tell me and what can I do to correct it? Any ideas???

                      C Offline
                      C Offline
                      Christian Graus
                      wrote on last edited by
                      #10

                      Bliven wrote: So what does this really tell me and what can I do to correct it? The whole thing sounds like a disaster to me. Why would you want to compile all that GUI code into an ATL component ? I suggest you buy the book 'teach yourself ATL in 24 hours' and read it. Then do what I suggested - rewrite the business logic into an ATL component, reusing as much code as you can, but rebuilding nonetheless, so that you end up with only the code you need. Christian come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002

                      L 1 Reply Last reply
                      0
                      • C Christian Graus

                        Bliven wrote: So what does this really tell me and what can I do to correct it? The whole thing sounds like a disaster to me. Why would you want to compile all that GUI code into an ATL component ? I suggest you buy the book 'teach yourself ATL in 24 hours' and read it. Then do what I suggested - rewrite the business logic into an ATL component, reusing as much code as you can, but rebuilding nonetheless, so that you end up with only the code you need. Christian come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002

                        L Offline
                        L Offline
                        Leesen
                        wrote on last edited by
                        #11

                        Thank you for your suggestion. Now I am following your suggestion to rewrite the business logic into an ATL component. Now there are some new problems. For example. I have created two ATL object 'Student'and 'Teacher', and 'Student' is a property of 'ITeacher'.In idl, it seems the function can not return the user define class type.Then how can I get the 'Student' property in VB?? in idl: [propget, id(1), helpstring("property Student")] HRESULT Student([out, retval] CStudent *pVal); [propput, id(1), helpstring("property Student")] HRESULT Student([in] CStudent newVal); E:\Programming\Study\ClassReturn\ClassReturn.idl(30) : error MIDL2025 : syntax error : expecting a type specification near "CStudent"

                        C 1 Reply Last reply
                        0
                        • L Leesen

                          Thank you for your suggestion. Now I am following your suggestion to rewrite the business logic into an ATL component. Now there are some new problems. For example. I have created two ATL object 'Student'and 'Teacher', and 'Student' is a property of 'ITeacher'.In idl, it seems the function can not return the user define class type.Then how can I get the 'Student' property in VB?? in idl: [propget, id(1), helpstring("property Student")] HRESULT Student([out, retval] CStudent *pVal); [propput, id(1), helpstring("property Student")] HRESULT Student([in] CStudent newVal); E:\Programming\Study\ClassReturn\ClassReturn.idl(30) : error MIDL2025 : syntax error : expecting a type specification near "CStudent"

                          C Offline
                          C Offline
                          Christian Graus
                          wrote on last edited by
                          #12

                          You can only return the types accepted by the IDL compiler. The easiest way in my experience to pass back data such as the details of a student is to pass it as XML. An XML string can contain as many different data items as you like, so long as they can be represented as text. Christian We're just observing the seasonal migration from VB to VC. Most of these birds will be killed by predators or will die of hunger. Only the best will survive - Tomasz Sowinski 29-07-2002 ( on the number of newbie posters in the VC forum )

                          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