Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: GDIWinCeBitmap
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
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 680
1 OriginalGriff 379
2 Manas Bhardwaj 350
3 Abhinav S 293
4 Sampath Lokuge 245
0 Sergey Alexandrovich Kryukov 7,967
1 OriginalGriff 4,332
2 Peter Leow 3,699
3 Maciej Los 3,515
4 Er. Puneet Goel 3,107


Advertise | Privacy | Mobile
Web01 | 2.8.140415.2 | Last Updated 2 Apr 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid