Click here to Skip to main content
15,886,787 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hai,
my requirement is to draw a line over a bitmap loaded into memory. i am working in WinCE. The code i wrote is like this,
HGDIOBJ hPrevObj = 0;
HGDIOBJ hPrevObj1 = 0;
BOOL bStat = 0;
dwError = ::GetLastError();
hDCMem = ::CreateCompatibleDC( g_dc );
dwError = ::GetLastError();
SelectObject( hDCMem, g_hBitmap );

dwError = 0;
dwError = ::GetLastError();
SelectObject( hDCMem, g_hPen );
dwError = 0;
dwError = ::GetLastError();
bStat = MoveToEx( hDCMem, g_X, g_Y, 0 );
dwError = ::GetLastError();
bStat = 0;
g_X+= 10;
g_Y += 10;
bStat = LineTo( hDCMem, g_X, g_Y );
dwError = 0;
dwError = ::GetLastError();
bStat = 0;
//bStat = BitBlt( hDC, 0, 0, 240, 82, hDCMem, 0, 0, SRCCOPY );
bStat = StretchBlt( g_dc, 0, 0, 240, 82, hDCMem, 0, 0, 240, 82, SRCCOPY );
dwError = ::GetLastError();

The problem i am facing is that the line drawing function and BitBlt() function returns success but it is not getting reflected on the window or the loaded bit map.
Posted

1 solution

It is not "reflecting" because you don't do anything to render the graphics in the window. You need to render in response to WM_PAINT Windows message. Even if you do, your changes might not update the view, because nothing triggers sending this message. In this case, you also should call one of the invalidation functions.

Please see:
http://msdn.microsoft.com/en-us/library/dd145213%28v=vs.85%29.aspx[^].

This is a minimal code sample for using rendering on WM_PAINT:
http://msdn.microsoft.com/en-us/library/dd162487%28v=vs.85%29.aspx[^].

Invalidation:
http://msdn.microsoft.com/en-us/library/dd145002%28v=vs.85%29.aspx[^],
http://msdn.microsoft.com/en-us/library/dd145003%28v=vs.85%29.aspx[^].

See also the overview:
http://msdn.microsoft.com/en-us/library/dd162759%28v=vs.85%29.aspx[^].

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900