Visual C++

This is a discussion on Visual C++ within the Windows Programming forums, part of the Platform Specific Boards category; Ken, I am attaching the program. Don't laugh at the simplicity of the program, it is a simple window template ...

  1. #16
    Registered User
    Join Date
    Feb 2003
    Posts
    184

    Program

    Ken,

    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:
    Attached Files Attached Files

  2. #17
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    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:
    Code:
    Gdiplus::Graphics *gs=new Gdiplus::Graphics(hdc);
    (see the example I have posted) or as:
    Code:
    Gdiplus::Graphics gs(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:
    Code:
    case WM_PAINT:
      {
      hdc = BeginPaint(hWnd, &ps);
        Gdiplus::Graphics gs(hdc);
        Gdiplus::Image image(L"misc0001.tif");
        gs.DrawImage(&image,0,0);
      EndPaint(hWnd, &ps);
      break;
      }
    Last edited by Ken Fitlike; 03-12-2003 at 05:21 PM.

  3. #18
    Registered User
    Join Date
    Feb 2003
    Posts
    184
    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???


    Thanks again,
    Kendal
    Attached Files Attached Files

  4. #19
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    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:

    http://www.codeproject.com/vcpp/gdip...plusbitmap.asp

    I'd be curious to know if you still get the same error(s) with that example.

    Good luck.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  5. #20
    Registered User
    Join Date
    Feb 2003
    Posts
    184
    Ken,

    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

    Kendal

  6. #21
    Registered User
    Join Date
    Feb 2003
    Posts
    184

    New info

    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.

    Thanks Ken,
    Kendal

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 04:45 PM
  2. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  3. load gif into program
    By willc0de4food in forum Windows Programming
    Replies: 14
    Last Post: 01-11-2006, 09:43 AM
  4. Errors with including winsock 2 lib
    By gamingdl'er in forum C++ Programming
    Replies: 3
    Last Post: 12-05-2005, 07:13 PM
  5. Learning OpenGL
    By HQSneaker in forum C++ Programming
    Replies: 7
    Last Post: 08-06-2004, 08:57 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21