Link to home
Start Free TrialLog in
Avatar of skifte
skifte

asked on

How to install GdiPlus.h

I have downloaded Microsoft SDK. Then I have moved all the files from
C:\Programmer\Microsoft SDK\include
to
C:\Programmer\Microsoft Visual Studio\VC98\Include
Then I have in my program written
#include <GdiPlus.h>
The hole work is to be able to include GdiPlus.h
But when i run the program, I get a lot of error messages. What can be wrong?
I get 102 error messages, like

--------------------Configuration: Messages1 - Win32 Debug--------------------
Compiling...
Exercise.cpp
c:\programmer\microsoft visual studio\vc98\mfc\include\gdiplusinit.h(32) : error C2065: 'ULONG_PTR' : undeclared identifier
c:\programmer\microsoft visual studio\vc98\mfc\include\gdiplusinit.h(32) : error C2065: 'token' : undeclared identifier
c:\programmer\microsoft visual studio\vc98\mfc\include\gdiplusinit.h(32) : error C2165: 'left-side modifier' : cannot modify pointers to data
c:\programmer\microsoft visual studio\vc98\mfc\include\gdiplusinit.h(32) : error C2071: 'NotificationHookProc' : illegal storage class
c:\programmer\microsoft visual studio\vc98\mfc\include\gdiplusinit.h(33) : error C2146: syntax error : missing ')' before identifier 'token'
c:\programmer\microsoft visual studio\vc98\mfc\include\gdiplusinit.h(33) : error C2165: 'left-side modifier' : cannot modify pointers to data
c:\programmer\microsoft visual studio\vc98\mfc\include\gdiplusinit.h(33) : error C2071: 'NotificationUnhookProc' : illegal storage class
c:\programmer\microsoft visual studio\vc98\mfc\include\gdiplusinit.h(33) : error C2059: syntax error : ')'
c:\programmer\microsoft visual studio\vc98\mfc\include\gdiplusinit.h(86) : error C2059: syntax error : 'const'
c:\programmer\microsoft visual studio\vc98\mfc\include\gdiplusinit.h(95) : error C2146: syntax error : missing ')' before identifier 'token'
c:\programmer\microsoft visual studio\vc98\mfc\include\gdiplusinit.h(95) : warning C4229: anachronism used : modifiers on data are ignored
c:\programmer\microsoft visual studio\vc98\mfc\include\gdiplusinit.h(95) : error C2182: 'GdiplusShutdown' : illegal use of type 'void'
c:\programmer\microsoft visual studio\vc98\mfc\include\gdiplusinit.h(95) : error C2059: syntax error : ')'
c:\programmer\microsoft visual studio\vc98\mfc\include\gdiplusimaging.h(22) : error C2065: 'ImageFormatUndefined' : undeclared identifier
c:\programmer\microsoft visual studio\vc98\mfc\include\gdiplusimaging.h(22) : error C2501: 'DEFINE_GUID' : missing storage-class or type specifiers
c:\programmer\microsoft visual studio\vc98\mfc\include\gdiplusimaging.h(22) : error C2078: too many initializers
c:\programmer\microsoft visual studio\vc98\mfc\include\gdiplusimaging.h(23) : error C2065: 'ImageFormatMemoryBMP' : undeclared identifier
c:\programmer\microsoft visual studio\vc98\mfc\include\gdiplusimaging.h(23) : error C2501: 'DEFINE_GUID' : missing storage-class or type specifiers
c:\programmer\microsoft visual studio\vc98\mfc\include\gdiplusimaging.h(23) : error C2374: 'DEFINE_GUID' : redefinition; multiple initialization
        c:\programmer\microsoft visual studio\vc98\mfc\include\gdiplusimaging.h(22) : see declaration of 'DEFINE_GUID'
c:\programmer\microsoft visual studio\vc98\mfc\include\gdiplusimaging.h(23) : error C2078: too many initializers
c:\programmer\microsoft visual studio\vc98\mfc\include\gdiplusimaging.h(24) : error C2065: 'ImageFormatBMP' : undeclared identifier
c:\programmer\microsoft visual studio\vc98\mfc\include\gdiplusimaging.h(24) : error C2501: 'DEFINE_GUID' : missing storage-class or type specifiers
c:\programmer\microsoft visual studio\vc98\mfc\include\gdiplusimaging.h(24) : error C2374: 'DEFINE_GUID' : redefinition; multiple initialization
        c:\programmer\microsoft visual studio\vc98\mfc\include\gdiplusimaging.h(22) : see declaration of 'DEFINE_GUID'
c:\programmer\microsoft visual studio\vc98\mfc\include\gdiplusimaging.h(24) : error C2078: too many initializers
c:\programmer\microsoft visual studio\vc98\mfc\include\gdiplusimaging.h(25) : error C2065: 'ImageFormatEMF' : undeclared identifier
c:\programmer\microsoft visual studio\vc98\mfc\include\gdiplusimaging.h(25) : error C2501: 'DEFINE_GUID' : missing storage-class or type specifiers
c:\programmer\microsoft visual studio\vc98\mfc\include\gdiplusimaging.h(25) : error C2374: 'DEFINE_GUID' : redefinition; multiple initialization
        c:\programmer\microsoft visual studio\vc98\mfc\include\gdiplusimaging.h(22) : see declaration of 'DEFINE_GUID'
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
ASKER CERTIFIED SOLUTION
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 skifte
skifte

ASKER

First I have reinstalled VC++ and SDK.
I have downloaded alle the files nessecary to GdiPlus. I have found a good link:

http://www.codeproject.com/vcpp/gdiplus/startinggdiplus.asp
There stands:
Also put gdiplus.lib in your list of libraries by choosing Project/Settings/Link and entering it into the object/library modules area.

I have two gdiplus.lib on my harddisk.
D:\Programmer\Microsoft SDK\Lib\gdiplus.lib
D:\Programmer\Microsoft SDK\Lib\IA64\gdiplus.lib
Which path skal I write?

Then there stands:
To get your application to work with GDI+, do the following: in stdafx.h, add:

On my harddisk, I have more than 200 stdafx.h. Which one shall I make the change in?

Them there stands:
in your application class, add the member:

I have one cpp file (exercise.cpp), and for the time I write all the code there. What is my 'application class'?

Thanks in advance.

Avatar of skifte

ASKER

Here i the complete exercise.cpp

##### Code start #####
#include <afxwin.h>
#include <string.h>
#include <windows.h>
#include <afx.h>

class CExerciseApp : public CWinApp
{
    public:
      virtual BOOL InitInstance();
};

// Her begynder hovedvindue

class CMainFrame : public CFrameWnd
{
    public:
      CMainFrame();
};

CMainFrame::CMainFrame()
{
   Color firstColor(255, 128, 128, 255);
   COLORREF colorRef ;

   colorRef = SetDCBrushColor (NULL, firstColor);

   CString strMyClass;
   // load stock cursor, brush, and icon for
   // my own window class
   try
   {
      strMyClass = AfxRegisterWndClass(CS_VREDRAW | CS_HREDRAW,::LoadCursor(NULL, IDC_ARROW),
         (HBRUSH) ::GetStockObject(colorRef), ::LoadIcon(NULL, IDI_APPLICATION));
   }

   catch (CResourceException* pEx)
   {
      AfxMessageBox(_T("Couldn't register class! (Already registered?)"));
      pEx->Delete();
   }
   // Her slutter en blok
      
   Create(strMyClass, "Bjarne's Timer");
}

// Her begynder ettervindue

class ettervindue : public CFrameWnd
{
    public:
      ettervindue();
};

ettervindue::ettervindue()
{
      Create(NULL, "Ettervindue");
}

// Her slutter ettervindue

BOOL CExerciseApp::InitInstance()
{
      m_pMainWnd = new CMainFrame;
      m_pMainWnd->ShowWindow(SW_MAXIMIZE);

      ettervindue * etterpointer = new ettervindue;
      etterpointer->ShowWindow(SW_SHOW);

      return TRUE;
}

CExerciseApp theApp;
##### Code end #####

The porpose is to change the background colour of CMainFrame.
CExerciseApp is the application class.

You have to change the stdafx.h which belongs to that project where you want to use gdiplus but from the code you are showing you don't use it for this app. So you have to put the changes either into exercise.h or merge them into exercise.cpp.

And the answer to your first Q is use
D:\Programmer\Microsoft SDK\Lib\gdiplus.lib
The other is for the IA64 architechture which I suppose you are not using.
Avatar of skifte

ASKER

I have surfed the net for advise. But there is a problem with stdafx.h. In Tools, Options, Directories, I include 4 directories:
D:\Programmer\Microsoft SDK\include
C:\Programmer\Microsoft Visual Studio\VC98\INCLUDE
C:\Programmer\Microsoft Visual Studio\VC98\MFC\INCLUDE
C:\Programmer\Microsoft Visual Studio\VC98\ATL\INCLUDE
I have looked in all 4 directories, but there is no stdafx.h. Then I have seeked through the C and D drive, and have found 200 stdafx.h. But they are different. Some of them are, I have not looked through them all. Is it a software error, that there id no stdafx.h i the SDK or VC++ directories?

Where can I obtain the correct stdfafx.h?