problem with MFC

Discussion in 'SolidWorks' started by Andreas, Nov 26, 2003.

  1. Andreas

    Andreas Guest

    Hello,

    I have created a Solidworks addin with the SW Wizzard in Visual C++ 7.
    I would like to use MFC, so I included afxwin.h . When I try to
    compile the project, the compiler delivers the following message:

    fatal error C1189: WINDOWS.H already included. MFC apps must not
    include <windows.h>

    What is wrong?

    Thanks a lot.

    Regards,
    Andreas


    P.S.: this is my stdafx.h:




    #pragma once


    #ifndef STRICT
    #define STRICT
    #endif

    // Modify the following defines if you have to target a platform prior
    to the ones specified below.
    // Refer to MSDN for the latest info on corresponding values for
    different platforms.
    #ifndef WINVER // Allow use of features specific to Windows 95 and
    Windows NT 4 or later.
    #define WINVER 0x0400 // Change this to the appropriate value to
    target Windows 98 and Windows 2000 or later.
    #endif

    #ifndef _WIN32_WINNT // Allow use of features specific to Windows NT
    4 or later.
    #define _WIN32_WINNT 0x0400 // Change this to the appropriate value to
    target Windows 2000 or later.
    #endif

    #ifndef _WIN32_WINDOWS // Allow use of features specific to Windows
    98 or later.
    #define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value
    to target Windows Me or later.
    #endif

    #ifndef _WIN32_IE // Allow use of features specific to IE 4.0 or
    later.
    #define _WIN32_IE 0x0400 // Change this to the appropriate value to
    target IE 5.0 or later.
    #endif

    #define _ATL_APARTMENT_THREADED
    #define _ATL_NO_AUTOMATIC_NAMESPACE

    #define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString
    constructors will be explicit

    // turns off ATL's hiding of some common and often safely ignored
    warning messages
    #define _ATL_ALL_WARNINGS

    #include <atlbase.h>
    #include <atlcom.h>
    #include <atlwin.h>
    #include <atltypes.h>
    #include <atlctl.h>
    #include <atlhost.h>

    #include <afxwin.h> // <----

    #import "swpublished.tlb" raw_interfaces_only, raw_native_types,
    named_guids, auto_search
    #import "sldworks.tlb" raw_interfaces_only, raw_native_types,
    named_guids, auto_search, rename("PropertySheet", "ShowPropertySheet")
    #include "swconst.h"

    //SolidWorks TypeLibrary Versions
    #define ID_SLDWORKS_TLB_MAJOR 12
    #define ID_SLDWORKS_TLB_MINOR 0

    #define ID_SWPUBLISHED_TLB_MAJOR 1
    #define ID_SWPUBLISHED_TLB_MINOR 0

    using namespace ATL;
    using namespace SldWorks;
    using namespace SWPublished;
     
    Andreas, Nov 26, 2003
    #1
  2. The #include <atlbase.h> indtrectly includes <windows.h> via <atlcore.h>.
    Try moving the #include <afxwin.h> before the atl stuff in your stdafx.h.

    By the way, do you know that SW Corp won't be supporting MFC addins from the
    next version onwards? Also, if you use MFC with Visual C++ 7 you will have
    to distribute new versions of the MFC dlls with your application. If you
    want to use Visual C++ 7, why not make a COM addin? (That at least is not
    so tightly bound into SolidWorks, and also should be supported by SW Corp
    for some time to come.)
     
    Paul Delhanty, Nov 26, 2003
    #2
  3. Andreas

    neil Guest

    I see you have worked for D Cubed Paul, any insights as to why SW are not
    utilising their latest spline tools?
     
    neil, Nov 26, 2003
    #3
  4. Sorry, I can't speak for SW or D-Cubed. Also, anything concrete that I
    might know that it is not already public I'm not at liberty to disclose.

    In general terms, I would just say the obvious things. D-Cubed products are
    software components rather than end use products. They take significant
    amounts of work to integrate properly into end user products. It is one
    thing to produce a proof of concept integration that can demonstrate
    functionality; quite another to produce something that it is ready to ship.
    The animations on D-Cubed's website show their products integrated into
    their own test harnesses. The test harnesses supply the graphics and user
    interface; the actual product scopes are restricted to maths and geometry.
    As a result, it doesn't suprise me if there is a time lag between D-Cubed
    announcing a new software component, and it forming part of a shipping end
    user product.
     
    Paul Delhanty, Nov 26, 2003
    #4
  5. Andreas

    neil Guest

    appreciate non disclosure - thanks for your reply
     
    neil, Nov 26, 2003
    #5
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.