shaderect.txt
上传用户:topsoptop
上传日期:2007-01-03
资源大小:1k
文件大小:1k
源码类别:

图形图像处理

开发平台:

Visual C++

  1. void ShadeRect( CDC *pDC, CRect& rect )
  2. {
  3. // Bit pattern for a monochrome brush with every
  4. // other pixel turned off
  5. WORD Bits[8] = { 0x0055, 0x00aa, 0x0055, 0x00aa,
  6.  0x0055, 0x00aa, 0x0055, 0x00aa };
  7. CBitmap bmBrush;
  8. CBrush brush;
  9. // Need a monochrome pattern bitmap
  10. bmBrush.CreateBitmap( 8, 8, 1, 1, &Bits );
  11. // Create the pattern brush
  12. brush.CreatePatternBrush( &bmBrush );
  13. CBrush *pOldBrush = pDC->SelectObject( &brush );
  14. // Turn every other pixel to black
  15. COLORREF clrBk = pDC->SetBkColor( RGB(255,255,255) );
  16. COLORREF clrText = pDC->SetTextColor( RGB(0,0,0) );
  17. // 0x00A000C9 is the ROP code to AND the brush with the destination
  18. pDC->PatBlt(rect.left, rect.top, rect.Width(), rect.Height(), 
  19. (DWORD)0x00A000C9); //DPa - raster code
  20. pDC->SetBkColor( RGB(0,0,0) );
  21. pDC->SetTextColor( GetSysColor(COLOR_HIGHLIGHT) );
  22. // 0x00FA0089 is the ROP code to OR the brush with the destination
  23. pDC->PatBlt(rect.left, rect.top, rect.Width(), rect.Height(), 
  24. (DWORD)0x00FA0089); //DPo - raster code
  25. // Restore the device context
  26. pDC->SelectObject( pOldBrush );
  27. pDC->SetBkColor( clrBk );
  28. pDC->SetTextColor( clrText );
  29. }