Hey,
Well I am having a little problem. I am trying to program a simple ping pong game. Well my problem is this. I created a fuction to fill a RECT with a sertain color. This is how it is declared:
extern bool FillRect(LPDIRECTDRAWSURFACE7 lpSurface, LPRECT lprect, COLORREF color);
Now, in my game code, I have a main loop. When I call this function from there everything goes well, but Whenever I try to call this same exact function from a fuction that is within a class I get this error:
''FillRect'' : cannot convert parameter 1 from ''struct IDirectDrawSurface7 *'' to ''struct HDC__ *''
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Here is the code that gives me the error:
int paddle::DrawPaddle(LPDIRECTDRAWSURFACE7 BackSurface) {
RECT BlockRect;
BlockRect.bottom = y_pos + height;
BlockRect.top = y_pos;
BlockRect.right = x_pos + width;
BlockRect.left = x_pos;
FillRect(BackSurface, &BlockRect, color); <- This is what screws up
}
// Now, here is the code I call in the main loop that works fine.
FillRect(lpDDSBack, &SurfaceRect, RGB(10,50,10));
Well, if anyone could help me, I would appreciate it. Thanks a lot.
Later, James
That's because your function is clashing with the Windows API function, conviently called...FillRect:
int FillRect(
HDC hDC, // handle to device context CONST RECT *lprc, // pointer to structure with rectangle HBRUSH hbr // handle to brush );
Not sure why calling it from inside an object changes the version of the function being called (could be a scoping thing, a #include thing, or just plain compiler wierdness).
My suggestion is to rename your function to DrawFillRect, or something like that (easy) or parsing the Windows header file out of your class definition files (fun, if you like grepping).
And don't even thing about trying to name a function CreateWindow...
-Rabid
Edited by - RabidOcelot on April 14, 2001 2:15:59 AM
Thanks a lot. It fixed the problem. I am supprised I didn''t think about that. I have used the windows FillRect function before so you would think that would of crossed my mind. Well thanks a lot.
Later
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
With your permission, GameDev.net uses analytics cookies to understand how people use the platform.
You can accept analytics or continue with necessary cookies only.
Learn more