I am attaching the program. Don't laugh at the simplicity of the program, it is a simple window template that I have added header files to and a couple of lines. I know I must be missing a lot of additions, but I was trying to take one thing at a time. Anyway, here is the code:
In order to use gdiplus you first have to initialise it with Gdiplus::GdiplusStartup then, when your done, you release it with a call to Gdiplus::GdiplusShutdown (see the example I posted).
You can't use an unitialised pointer: either declare and allocate your Gdiplus::Graphics object as:
(see the example I have posted) or as:
Gdiplus::Graphics *gs=new Gdiplus::Graphics(hdc);
where 'hdc' is the device context to be associated with the Graphics object. If you go with the first method then don't forget to use delete on the pointer.
Use appropriate member access syntax; '->' for pointer to member, otherwise use '.'.
Gdiplus requires UNICODE strings so precede string literals with 'L' to make sure the functions get just that. For example where you have the path "misc0001.tif", change it to L"misc0001.tif".
So, your modified WM_PAINT handler would look something like:
hdc = BeginPaint(hWnd, &ps);
I follow you. It makes sense, but when I make the necessary changes, I get namespace errors. Just to see what would happen I added the using namespace Gdiplus; declaration and tried to compile, when I did it gave me the error
error C2871: 'Gdiplus' : a namespace with this name does not exist
The project is set up exactly like I set up the sample you sent to make sure that my linker paths were setup right. I am using .NET and gdiplus.h are located in VC7/Platform SDK/include/prerelease. This directory is set up in my include path as well as the appropriate lib path for the lib file. It compiles when I just add the header file which declares the namespace, why would it tell me that namespace does not exist when I try using it?????
I included my edited .cpp file just for you to review. Every time I compile it I get the c2871 error. Does it compile on yours???
It works ok with msvc6 (I don't have vc.net and probably won't anytime soon). Does it work ok in msvc6 for you?
This seems to claim to work with vc.net - you could try it out:
I'd be curious to know if you still get the same error(s) with that example.
Good luck. :)
Just to let you know, that code did compile within my .NET environment. I just don't understand why my code is not picking up GDIPLUS namespace. I'll just keep looking. If and when I find the error, I will post it for you for future reference. Thanks greatly for all of you help. I have learned a lot from you. Once again THANKS :D
I just got around to trying that .cpp on MSVC6 and I get the same errors. What I do is open a new hello world project and replace the main .cpp program with my .cpp program that accesses GDIPLUS.h. I make sure that my project->settings->link tab includes gdiplus.lib and that my tools->options->directories include the path for the gdiplus.h and gdiplus.lib. I still get those darn "Gdiplus does not exist or is not a namespace" errors. Just to let you know, you asked if it worked on my MSVC6 version. It's got me? Will keep hunting though.