Compiler error after setting icon property

  • Thread starter Thread starter TGF
  • Start date Start date
T

TGF

Hello,

When I attempt to set the icon property on a Windows form (.NET), when I
go to compile, I get the following error....

e:\Projects\MyApp\AboutForm.h(108): error C2039: 'GetObjectA' : is not a
member of 'System::Resources::ResourceManager'

....Does anyone know why this happens, and the way to correct it....I looked
up the function member "GetObject", and it is a valid member function. Note
that this error occurs in the InitializeComponent() function where the VS
code generator says not to edit it. So what gives!
 
Add

#undef GetObject

somewhere after your includes and before the line that contains GetObject.

Ronald Laeremans
Visual C++ team
 
Ron,

Thanks for the help! I would really like to eliminate the error if at
all possible, rather than working around it.

-TGF



Ronald Laeremans said:
Add

#undef GetObject

somewhere after your includes and before the line that contains GetObject.

Ronald Laeremans
Visual C++ team

TGF said:
Hello,

When I attempt to set the icon property on a Windows form (.NET),
when
 
#undef-ing GetObject does eliminate the error - it's not a workaround.

The problem is that <windows.h> #defines several hundred words as macros -
many of those same words exist as member function names in the .NET
framework classes. The combination of those two facts means that when you
have a translation unit that #includes <windows.h> and uses .NET framework
classes, you're likely to have name clashes between the macros and the .NET
member functions. Since macros are unscoped, the only real solutions are:
1. Don't mix <windows.h> and .NET in the same translation unit or 2. #undef
the names that clash.

-cd
 
Back
Top