tags:

views:

168

answers:

3
+1  A: 

You could use CreateHatchBrush for simple inbuilt patterns. To create your own, you use CreatePatternBrush.

To quote from MSDN:

A brush created by using a monochrome (1 bit per pixel) bitmap has the text and background colors of the device context to which it is drawn. Pixels represented by a 0 bit are drawn with the current text color; pixels represented by a 1 bit are drawn with the current background color.

Which is I beleave what you are trying to do?

Shane Powell
Well, basically. But I don't really know what a device context is, and I still don't know how I would get the background color of the window, and then alter that value to create the foreground color
Carson Myers
A device context is the thing you draw with in GDI. It represents memory, a screen a printer that kind of thing.
1800 INFORMATION
ah, okay, I see
Carson Myers
+1  A: 

You get the current back colour of a device context by using GetBkColor. You can get a device context compatible with the window using GetDC. To put it together, use something like this:

HDC dc=GetDC(hWnd);
COLORREF backColour=GetBkColor(dc);

// do something...

ReleaseDC(dc);
1800 INFORMATION
that looks a lot easier,but,I'm creating the brush in a function, which is used in the class for the window (it hasn't been registered or created yet).
Carson Myers
A: 
Carson Myers
I think that this code is probably fragile - after a bit of research it seems that CreateBitmap creates a DDB (device dependant bitmap) - you shouldn't use it for editing. The layout of the bits in a DDB is up to the device driver. You should be creating a DIB instead. Not too confusing I hope
1800 INFORMATION