Im trying to learn how to load jpeg images for display using gdi+. Im using vc++ 2008 express as my compiler options appear to be vc++ or borland. As I cannot afford to pay the kind of money borland is asking, I have had to go with vc++ - even though I hate it. I know there is a free version of borland, but it is commandline and as Im not a seasoned programmer, I really need the comfort of a working ide.

My first problem was that vc++ wouldnt compile without producing 140+ errors. this was due to not including the line:

Code:
#pragma comment(lib, "C:\\Program Files\\Microsoft SDKs\\Windows\\v6.1\\Lib\\GdiPlus.lib")
I had to do this even though I had added the include and lib directory for the sdk using tools > options > vc++ directories - and placing the entries at the very top of the lists.

Then I edited the resource file with a text editor to allow me to place 'open' in the file menu of my app. I had to do it manually as vc++ 2008 express doesnt allow resource editimg. With a now working menu, I used openfilename to request the user for a picture:

Code:
case IDM_LOAD:
    {
    OPENFILENAME ofn = {0};
            
     ofn.lStructSize = sizeof(OPENFILENAME);
     ofn.hwndOwner = hWnd;
     ofn.lpstrFilter = TEXT ("Jpeg Image (*.jpg)\0*.jpg\0All Files (*.*)\0*.*\0");
     TCHAR strFileName[MAX_PATH] = {0};
     ofn.lpstrFile = strFileName;
     ofn.nMaxFile = MAX_PATH;
     ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST |OFN_HIDEREADONLY;
     ofn.lpstrDefExt = TEXT ("jpg");
     ofn.lpstrInitialDir = TEXT ("My Documents\\My Pictures");
     GetOpenFileName(&ofn);
     MessageBox (hWnd, strFileName, TEXT ("File is:"), MB_OK);

     CImage image;
     //Image image(L"C:\\path\\pigeon1.jpg");

     }
     break;
Iv had to use the text macro and changed char szFileName to tchar strFileName, as vc++ seems to require this. the messagebox confirms the app is looking at the correct file. I cannot find anything on loading jpegs using gdi+ with vc++ online. the sdk help seems to indicate I need to use the image class along with graphics object.

i have found 2 examples in the sdk - Image class (they show with bitmap) and CImage class.

CImage class:
CImage provides enhanced bitmap support, including the ability to load and save images in JPEG, GIF, BMP, and Portable Network Graphics (PNG) formats
the example they give is:
Code:
CImage image;
// Code to load/create image goes here

// Get a CDC for the image
CDC* pDC = CDC::FromHandle(image.GetDC());

// Use pDC here

image.ReleaseDC();
All I get from CImage is the error 'error C2065: 'CImage' : undeclared identifier'
I have included gdiplus.h and even Gdiplusheaders.h in the file stdafx.h. coding is becomming a real fight, not only with gdi+, but also vc++ and its annoying traits.

please, can anyone help - or at least point me in the direction of something helpfull...