Click here to Skip to main content
13,091,894 members (62,255 online)
Rate this:
 
Please Sign up or sign in to vote.
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 2-Apr-12 0:27am

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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
  Permalink  

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy |
Web02 | 2.8.170813.1 | Last Updated 2 Apr 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100