[Insight-users] How to write a MFC project using the toolkit

Luis Ibanez luis . ibanez at kitware . com
Mon, 08 Dec 2003 22:25:36 -0500


Hi Zhang,

An example on how to create a MFC + ITK
project has been commited into

      InsightApplications/ItkMFC

http://www . itk . org/cgi-bin/cvsweb . cgi/InsightApplications/ItkMFC/?cvsroot=Insight

The easy way to proceed is to first create the
project from VisualStudio (but not build it!).

VisualStudio generates template files with the
skeleton of the application. Then you write a
CMakeLists.txt file  like the one in ItkMFC
(the file is attached below...)

At this point you can run CMake and generate
the project files for visual studio. As usual
It is recomended to do an outsource build.

Once you succed to build and run the project
in this state, you can start adding ITK code
to the basic skeleton of the application.


Please let us know if you find any problem
with your ITK + MFC project.


Thanks,


  Luis


--------- The CMakeLists.txt follows ---------

PROJECT( ItkMFC )

ADD_DEFINITIONS(-D_AFXDLL)

SET(CMAKE_MFC_FLAG 6)

SET(ItkMFC_SRCS
   StdAfx.cpp
   ItkMFC.cpp
   ItkMFC.rc
   ItkMFCDoc.cpp
   MainFrm.cpp
   ItkMFCView.cpp
   ItkPipeline.cxx
   )

IF(WIN32)
  LINK_LIBRARIES(
    wsock32
  )
ENDIF(WIN32)


FIND_PACKAGE(ITK)
IF(ITK_FOUND)
   INCLUDE(${ITK_USE_FILE})
ELSE(ITK_FOUND)
   MESSAGE(FATAL_ERROR
           "Cannot build without ITK.  Please set ITK_DIR.")
ENDIF(ITK_FOUND)


ADD_EXECUTABLE (ItkMFC WIN32 ${ItkMFC_SRCS})
TARGET_LINK_LIBRARIES(ItkMFC ${ITK_LIBRARIES} )


------------------------
zhang pumpkin wrote:

> Hi,every one:
>   I'm a fresh man for the Insight toolkit.Now my problem is that  I want 
> to use VC6 to create a MFC project which can using the insight 
> toolkit.As you know,All the examples in the toolkit are run under the 
> console mode or using another GUI toolkit,but without the Microsoft MFC 
> classes.
>   As I yet don't know how to create a Windows mode project with the 
> cmakesetup tool so what I can do just was creating a MFC project with 
> the VC6 then including the head files of the ITK ,but this approach 
> doesn't work,the project always can't pass the link or compile.The 
> terrible simple problem are droving me creazy for my job must finish 
> before the Christmas.
>  I hope some one can tell me how to generate a MFC project with the 
> CMakesetup or how to use the toolkit in a MFC project.thanks.
> 
> _________________________________________________________________
> Ãâ·ÑÏÂÔØ MSN Explorer:   http://explorer . msn . com/lccn/ 
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk . org
> http://www . itk . org/mailman/listinfo/insight-users
>