Click to See Complete Forum and Search --> : Problems with bitmaps?


paisano
February 20th, 2003, 01:54 AM
Hi people, iam having trouble with bitmaps, because i dont understand how can i display different bitmaps with out
replacing others. With this code:

hdc = BeginPaint( hwnd, &ps );
memdc = CreateCompatibleDC( hdc );
SelectObject( memdc, hbit );

BitBlt( hdc, 10, 10, 256, 128, memdc, 0, 0, SRCCOPY );
BitBlt( hdc, 300, 100, 256, 128, memdc, 0, 0, SRCCOPY );

EndPaint( hwnd, &ps );

I can only display the same bitmap on different location, but if i create another one and try to do this:

hdc = BeginPaint( hwnd, &ps );
memdc = CreateCompatibleDC( hdc );
SelectObject( memdc, hbit );
SelectObject( memdc, hbit2 ); //The other one

BitBlt( hdc, 10, 10, 256, 128, memdc, 0, 0, SRCCOPY );
BitBlt( hdc, 300, 100, 256, 128, memdc, 0, 0, SRCCOPY );

EndPaint( hwnd, &ps );

It replace the old one with the new one. The last parameter in the function BitBlt say how the colors will work, i guest
thats not my problem, I like to know how i can display diferent bitmaps, with out replace the old one?

Hope some one can help me, thanks and have a nice day.
:confused:

SumGuy
February 28th, 2003, 02:23 PM
I think that you need to make another compatible DC for that to work.


The problem that I had, was that I started my project as a *.c file and then realized that that only uses c style code. So, I saved my stuff as *.cpp and the SelectObject started giving an error that void* cannot be converted to an HGIOBJ.

Is there a way to fix that error?

paisano
March 2nd, 2003, 03:06 AM
Ok you see, the problem there is that you need to update your functions, look how it looks the SelectObject function:

HGDIOBJ SelectObject(
HDC hdc, // handle to device context
HGDIOBJ hgdiobj // handle to object
);

If you dont resolve your problem, show the code. Ok.