#include <windows.h> causes compile error

G

Guest

I am devloping a simple .net windows form using C++.
without includeing windows.h it compiles and runs, but is not really doing
anything.

when I add the #include <windows.h> then I get various compiler errors
listed below:
c:\T02010_NET_ora9\cgi-bin\programs\ManualKeeper\Form1.h(120): error C2039:
'GetObjectA' : is not a member of 'System::Resources::ResourceManager'

c:\T02010_NET_ora9\cgi-bin\programs\ManualKeeper\Form1.h(203): error C2653:
'MessageBoxA' : is not a class or namespace name

private: System::Void submit_Click(System::Object * sender,
System::EventArgs * e){
MessageBox::Show (S"Accept It worked!", S"Message...");
}


Below is the code that these errors occured on.
this->logo_1->Image = (__try_cast<System::Drawing::Image *
(resources->GetObject(S"logo_1.Image")));

Does any one know why this is causing a problem and how can I get around it.
The windows.h is actually in a 3rd party non managed dll that I need to use.
So I
need to use it, unless there is some other equivelent .h for windows.h that
I can include in this 3rd party .h to get around problem. I have used this
3rd party dll in another .net application and it worked fine. That
application was a windows service application.
To recreate problem you don't need 3rd party .dll, all you need to do is add
#include <windows.h> in forms1.h of a simple form and try to compile.

Thanks,
Brian
 
M

Mattias Sjögren

Does any one know why this is causing a problem and how can I get around it.

Because windows.h (indirectly) adds things like

#define MessageBox MessageBoxA

You can try to add

#undef MessageBox

after the #include


Mattias
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Top