Guest

creating a bitmap pattern for a window's HBRUSH

By: a guest on Jan 28th, 2012  |  syntax: None  |  size: 0.76 KB  |  hits: 23  |  expires: Never
download  |  raw  |  embed  |  report abuse
Copied
  1. HDC dc=GetDC(hWnd);
  2. COLORREF backColour=GetBkColor(dc);
  3.  
  4. // do something...
  5.  
  6. ReleaseDC(dc);
  7.        
  8. COLORREF bg = GetSysColor(COLOR_BTNFACE);
  9.     bg = RGB(GetBValue(bg), GetGValue(bg), GetRValue(bg));
  10.     COLORREF fg = bg - 0x00151515; //slightly darker than the background color
  11.     COLORREF bits[30] = {          //would be problematic I guess if the color
  12.       bg, bg, bg, bg, fg,          //was originally less than 0x00151515
  13.       bg, bg, bg, fg, bg,
  14.       bg, bg, fg, bg, bg,
  15.       bg, fg, bg, bg, bg,
  16.       fg, bg, bg, bg, bg
  17.     };
  18.     HBITMAP hbm = CreateBitmap(5, 5, 1, sizeof(COLORREF) * 8, bits);
  19.        
  20. hbr = CreatePatternBrush(hbm);
  21.        
  22. HBRUSH main_st_color_ev(HWND hwnd, HDC hdc, HWND hwndChild, int type){
  23.  
  24.   return stripes;
  25.  
  26. }
  27.        
  28. SetBkMode(hdc, TRANSPARENT);