Click to See Complete Forum and Search --> : How to Display and Move Cross on BMP Image


muthyala
November 9th, 2004, 07:48 AM
Hi,

I am displaying BMP Image on dialog by using DirectDraw. I need to show cross on image and should move with any keys or mouse.
Please tell me how can proceed further, because i am new to graphics programming.
This is some of my code to display bitmap.

HBITMAP hbitmap = (HBITMAP)LoadImage(hinstance,bmp_name,IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
HBITMAP old_bitmap = (HBITMAP)SelectObject(hdc,hbitmap);
HDC surfaceDC = NULL; // We're going to fill this with the HDC of our backSurface
HRESULT result = backSurface->GetDC(&surfaceDC);
if(result != DD_OK){
SelectObject(hdc,old_bitmap);
DeleteObject(hbitmap);
return false;
}
StretchBlt(surfaceDC,0,0,m_size.cx,m_size.cy,hdc,0,0,bm.bmWidth,bm.bmHeight,SRCCOPY);
backSurface->ReleaseDC(surfaceDC);
SelectObject(hdc,old_bitmap);
DeleteObject(hbitmap);

Thank you
Muthyala

Marc G
November 9th, 2004, 08:10 AM
You should handle WM_MOUSEMOVE and WM_KEYDOWN messages. The handlers for these messages should change a variable that contains the coordinates of your cross and then they should call InvalidateRect. This will cause the application to call your WM_PAINT handler. In this WM_PAINT handler you first draw your bitmap and then use the MoveTo and LineTo functions to draw a cross at the coordinates that were saved.