Hi,
I am pretty new to C. One of my first projects is to convert an existing program written in another language to Pelles C. I am now trying to create an array of GpImage (so GDI+) objects and display the one which is selected by the user. At design time I do not know how many pictures the user will select and which one. What I managed so far: initialise GDI+, load the jpg-file using GdipLoadImageFromFile and display the file using GdipDrawImageRect in a WM_PAINT event of a subclassed static control. FYI, the code looks like this. I got a global variable:
GpImage *pP;
I load a file:
GpStatus st;
st = GdipLoadImageFromFile(Pict[1].FileName, (GpImage**)&pP);
and draw it:
LRESULT BigStaticProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) {
RECT RC;
switch (Msg) {
case WM_PAINT:
GetClientRect(hStaticBig, &RC);
GdipDrawImageRect(pGraphObjectBigStat, pP, 0, 0, RC.right, RC.bottom);
}
return DefSubclassProc(hWnd, Msg, wParam, lParam);
};
This works.
Now when I try to implement the global dynamic array of GpImage objects, I change to:
GpImage *pPict;
Then I allocate memory for an array:
pPict=(GpImage*)calloc((Plant.NumPictures), sizeof(GpImage*));
(This approach works for me for integer and structure arrays.)
In this line sizeof(GpImage*) returns 8 which is correct.
Then when I try to load the array I use this code:
long i;
GpStatus st;
pPict=(GpImage*)calloc((Plant.NumPictures), sizeof(GpImage*));
for (i = 0; i < Plant.NumPictures; i = i +1) {
st = GdipLoadImageFromFile(Pict[i].FileName, (GpImage**)&pPict[i]);
if(st==Ok){
MessageBox(NULL, L"was OK", L"Message", MB_OK);}
else {
MessageBox(NULL, L"was NOT OK", L"Message", MB_OK);
}
}
And then I get the error message at the line with 'GdipLoadImageFromFile': "error #2153: Unknown size for type 'GpImage (aka (incomplete) struct tagGpImage)'."
First of all I do not understand the message because a few lines up the compiler DOES know the size of GpImage. Secondly, I do not know how to get this code working. Thirdly, how to change the code in the WM_PAINT event?
I guess it is something stupid but I have been trying for days now so I hope someone here is willing and able to help me.
Any help is appreciated.