sunshine737
asked on
Problem with changing the position of cross mark on BMP image
Hi,
I am displaying BMP image with cross mark by using DirectDraw. I used the following functions.
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- -
HBITMAP hbitmap = (HBITMAP)LoadImage(hinstan ce,bmp_nam e,IMAGE_BI TMAP,0,0,L R_LOADFROM FILE);
HBITMAP old_bitmap = (HBITMAP)SelectObject(hdc, hbitmap);
HDC surfaceDC = NULL;
HRESULT result = backSurface->GetDC(&surfac eDC);
StretchBlt(surfaceDC,0,0,r eSize.cx,r eSize.cy,h dc,0,0,ima geSize.cx, imageSize. cy,SRCCOPY );
HPEN pen = CreatePen(PS_DOT, 1, RGB(0,0,0));
HPEN oldPen = (HPEN)SelectObject(surface DC, pen);
MoveToEx(surfaceDC, 0, pt.y, NULL);
LineTo(surfaceDC, reSize.cx, pt.y);
MoveToEx(surfaceDC, pt.x, 0, NULL);
LineTo(surfaceDC, pt.x, reSize.cy);
SelectObject(surfaceDC, oldPen);
backSurface->ReleaseDC(sur faceDC);
SelectObject(hdc,old_bitma p);
DeleteObject(hbitmap);
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
I am moving the cross on image by using key events, means for each event i am redrawing image and new position of cross. Its working well.
The problem is, when i am showing multiple images in loop with 40ms sleep time, i am unable to move the cross until it completes the loop. No event is working when loop is running. How can i move cross, ie independent from loop and image?
Thanking you
Vihar
I am displaying BMP image with cross mark by using DirectDraw. I used the following functions.
--------------------------
HBITMAP hbitmap = (HBITMAP)LoadImage(hinstan
HBITMAP old_bitmap = (HBITMAP)SelectObject(hdc,
HDC surfaceDC = NULL;
HRESULT result = backSurface->GetDC(&surfac
StretchBlt(surfaceDC,0,0,r
HPEN pen = CreatePen(PS_DOT, 1, RGB(0,0,0));
HPEN oldPen = (HPEN)SelectObject(surface
MoveToEx(surfaceDC, 0, pt.y, NULL);
LineTo(surfaceDC, reSize.cx, pt.y);
MoveToEx(surfaceDC, pt.x, 0, NULL);
LineTo(surfaceDC, pt.x, reSize.cy);
SelectObject(surfaceDC, oldPen);
backSurface->ReleaseDC(sur
SelectObject(hdc,old_bitma
DeleteObject(hbitmap);
--------------------------
I am moving the cross on image by using key events, means for each event i am redrawing image and new position of cross. Its working well.
The problem is, when i am showing multiple images in loop with 40ms sleep time, i am unable to move the cross until it completes the loop. No event is working when loop is running. How can i move cross, ie independent from loop and image?
Thanking you
Vihar
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
void CGeneralFunctions::DoEvent
{
MSG msg;
while ( ::PeekMessage(&msg, NULL, wMsgFilterMin, wMsgFilterMax, PM_NOREMOVE ) )
{
if ( ::GetMessage(&msg, NULL, wMsgFilterMin, wMsgFilterMax))
{
::TranslateMessage(&msg);
::DispatchMessage(&msg);
}
else
{
break;
}
}
}
Passing some message interval to this function, you handle only these messages, other messages remain in the message queue. You can use this function passing interval of keyboard messages. In this case current window will not be unexpectedly closed inside of loop.