using GDI+

B

Bonj

How can GDI+ be used from C++?? I tried the following
methods, but all failed with about 100 different errors
relating to stuff that was not in any file I created.
The file <gdiplus.h> only exists on my (XP pro) system in
a directory that was underneath the .NET install directory.
So I added this as an include directory to VC6.

1st attempt: Create standard Win32 app with VC6, #include
<gdiplus.h> (which it can now see), and try to create a
Graphics object. Fails with over 100 errors, none of which
I understand. Still fails if I add gdiplus.lib to the list
of libraries.

2nd attempt: Create standard Win32 app with VC.NET 2002
(unmanaged), #include <gdiplus.h>, and try to create a
Graphics object. Fails with over 100 errors.

3rd attempt: As 2nd attempt but starting off as a managed
empty project.

4th attempt: copy example code listing of a complete
program into each of the programs listed above. Fails
again.

From this, it would seem like C# is the only language
capable of using GDI+ (other than VB.NET which I don't
like purely because C# exists). Am I right, or can it be
done?
 
T

Thore Karlsen

How can GDI+ be used from C++?? I tried the following
methods, but all failed with about 100 different errors
relating to stuff that was not in any file I created.
The file <gdiplus.h> only exists on my (XP pro) system in
a directory that was underneath the .NET install directory.
So I added this as an include directory to VC6.

1st attempt: Create standard Win32 app with VC6, #include
<gdiplus.h> (which it can now see), and try to create a
Graphics object. Fails with over 100 errors, none of which
I understand. Still fails if I add gdiplus.lib to the list
of libraries.

2nd attempt: Create standard Win32 app with VC.NET 2002
(unmanaged), #include <gdiplus.h>, and try to create a
Graphics object. Fails with over 100 errors.

3rd attempt: As 2nd attempt but starting off as a managed
empty project.

4th attempt: copy example code listing of a complete
program into each of the programs listed above. Fails
again.

From this, it would seem like C# is the only language
capable of using GDI+ (other than VB.NET which I don't
like purely because C# exists). Am I right, or can it be
done?

It can definitely be done in C++. What errors are you getting?
 
R

Ron Natalie

Bonj said:
How can GDI+ be used from C++?? I tried the following
methods, but all failed with about 100 different errors
relating to stuff that was not in any file I created.
The file <gdiplus.h> only exists on my (XP pro) system in
a directory that was underneath the .NET install directory.
So I added this as an include directory to VC6.
You need to install the Platform SDK (one that's recent since
the inception of GDI+). The SDK will add the appropriate
search paths for both the include files and the libraries to your
VC++ 6.
 
D

Doug Forster

Hi,

GDI+ is defined in a namespace called Gdiplus.

Try

#include <gdiplus.h>
using namespace Gdiplus;

Sometimes the GDI+ objects confilict with regular C++ objects so if the
above still causes problems omit the using and try using a Gdiplus:: prefix
before all GDI+ declarations.


Cheers

Doug Forster
 
R

Ron Natalie

Doug Forster said:
Hi,

GDI+ is defined in a namespace called Gdiplus.

Try

#include <gdiplus.h>
using namespace Gdiplus;

Sometimes the GDI+ objects confilict with regular C++ objects so if the
above still causes problems omit the using and try using a Gdiplus:: prefix
before all GDI+ declarations.
Also VC6 doesn't implement using properly, I've given up and just fully-qualified
the names most places.
 
Y

yuchuan_wang

It definitely can be used in C++.
Include the header file, and link gdiplus.lib.
Gdiplus is one namespace, use Gdiplus::image, for example.
and Call GdiplusStartup before making any other GDI+ calls, and call
GdiplusShutdown when you have finished using GDI+.
 

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