Link to home
Start Free TrialLog in
Avatar of barkhashah
barkhashah

asked on

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

Hi All,
Can any one please tell me how to know after what inclusion of a file ( "#include ....") following error can come.
Also , how can i undef __windows__ . Actually i am using some apis and macros which need windows.h inclusion and the application is MFC based also. Really dont know how to solve this problem.

c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\afxv_w32.h(18) : fatal error C1189: #error :  WINDOWS.H already included.  MFC apps must not #include <windows.h>
Thanks
barkha
ASKER CERTIFIED SOLUTION
Avatar of AlexFM
AlexFM

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Santino_k
Santino_k

Hi barkha,
Now you have your #include problem solved, I am answering to your undef query (If you know the solution just ignore my post)
you can use following to undef any def s --

#ifdef __windows__
#undef __windows__
#endif

Have a nice day

Regards,
Santino
Avatar of barkhashah

ASKER

Thanks santino
Always welcome
Dear All,

         I am facing with the same problem that Barkha had (c:\program files\microsoft visual studio\vc98\mfc\include\afxv_w32.h(14) : fatal error C1189: #error :  WINDOWS.H already included.  MFC apps must not #include <windows.h>).

         I tried the soln's. suggested by AlexFM and Santino. But no Luck.

         I am using Visual C++6.0 (with ATL COM - for developing a COM Component) and XP Professional OS.

         I would really appreciate your help.

Many Thanks in advance,
Mamtha.
Hi Mamtha,
Do you have support for MFC enabled iin your ATL project?
Dear Santino,

 Thanks a lot for your help. I guess my ATL COM project is NOT enabled with MFC Support.
 
Onceagain Thanks,
Mamtha
 
Hi All,

  I am newbie to COM, trying to learn & develop COM Components. May I know, is it possible to directly fire an event(or call Client Interface Method, that is actually implemented in the Client) from the COM Server Thread. [The thread has been created using the MFC CWinThread class].
 
 For Example,

   I have a Event/method( called Fire_ButtonPressed ) in my Client-side interface called IHeadSetEvents. I need to call this event
from thread (that resides in the COM Server).

 The Problem is, if I fire/call this event ( Fire_ButtonPressed ) from my COM Server thread directly, it throws an error Fire_ButtonPressed  "undeclared".
When I try to include the Header file of the ConnectionPoints ( IHeadSetCP.h - where the Fire_ButtonPressed has been defined by the ATLCOM Wizard ), it throws an odd error saying "IID__IHeadSetEvents undeclared"(pointing to the class shown below).


//---------------------> Class generated by the ATLCOM Wizard <---------------------

template <class T>
class CProxy_IHeadSetEvents : public IConnectionPointImpl<T, &IID__IHeadSetEvents, CComDynamicUnkArray>
{
      //Warning this class may be recreated by the wizard.
public:
      HRESULT Fire_ButtonPressed(INT ButtonID)
      {
            HRESULT ret;
            T* pT = static_cast<T*>(this);
            int nConnectionIndex;
            int nConnections = m_vec.GetSize();
            
            for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
            {
                  pT->Lock();
                  CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
                  pT->Unlock();
                  _IHeadSetEvents* p_IHeadSetEvents = reinterpret_cast<_IHeadSetEvents*>(sp.p);
                  if (p_IHeadSetEvents != NULL)
                        ret = p_IHeadSetEvents->ButtonPressed(ButtonID);
            }      return ret;
      
      }
      
};


//---------------------> Firing an event from the function (that is a part of my Thread Class - derived from CWinThread class) <--

int HeadSetThread::MyThreadFunc()
{
      .......................
      
      .......................

      // Button pressed ?? Fire an event to the Client //

      .......................
      
      .......................
      

      CProxy_IHeadSetEvents::Fire_ButtonPressed(true);

}

 How can I solve this problem? Please help. [ If you need my source code or any further info. for better understanding of my  que, please let me know].

Thanks a lot in advance,
Mamtha