Brush Class

So I am out to use a Brush with windows easier. So far this is what I have.
I am trying to get a hatched brush, thats the goal, but all is white. I know this because I am drawing Rectanlges, and I can see the outline, but no color at all. Even tried to put random colors in myBrush but nothing comes out. Thanks for looking at the code.
-bA.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
  #pragma once
#if !defined( __BrushClass_H__ )
#define __BrushClass_H__

#include "stdafx.h"
#include <iostream> 
#include "windows.h"


class BRUSH
{
   public:
     
      BRUSH( HDC hdc, COLORREF color = RGB(0,0,0),
                          UINT style = BS_SOLID,
                     UINT hatchStyle = HS_BDIAGONAL );
      ~BRUSH();
      void select( );

   private:

      HBRUSH myBrushHand;
      HGDIOBJ oldBrush;
      HDC myHDC;
      COLORREF myColor;
      LOGBRUSH myBrushInfo;
      
};
#endif 

BRUSH::BRUSH( HDC myhdc, COLORREF color, UINT brushStyle, UINT hatchStyle ) 
{
   myBrushInfo.lbColor = color;
   myBrushInfo.lbStyle = brushStyle;
   myBrushInfo.lbHatch = hatchStyle;

   myHDC       = myhdc;
   myBrushHand = CreateBrushIndirect( &myBrushInfo );
   oldBrush  = ::SelectObject( myHDC, myBrushHand );
}
BRUSH::~BRUSH()
{
   ::SelectObject( myHDC, oldBrush );
   if( myBrushInfo.lbColor != 0xFFFFFFFF )
      ::DeleteObject( myBrushHand );
}


void BRUSH::select(){

   ::SelectObject( myHDC, myBrushHand);
}

Topic archived. No new replies allowed.