Click to See Complete Forum and Search --> : How do you draw a transparent hatch brush in NT4?


Ron Clarke
March 29th, 1999, 05:43 PM
Is there a way to draw a transparent hatch brush in NT 4? I have tried a variety of things, but can't seem to get it.

I'm trying to draw a circle with a hatch brush which partially covers a green rectangle under it. I need the green to

show through as the background to the brush-filled circle.

Here's the latest attempt:

I receive a ROP mix from another part of the application, containing foreground and background ROPs. This is broken

into its component parts and used in an attempt to set the background mode (m_fgbgRops coming in is 0x00000B0D,

background=:

//these values look OK in the debugger...

UINT rop2Fg = m_fgbgRops & 0xFF;

UINT rop2Bg = (m_fgbgRops >> 8) & 0xFF;

Created brush using CreateHatchBrush; creation works OK...

// Set Bk mode; Not Effective

int nBkRet; //for debugging view

if ( m_fgbgRops == 0x0d0d /*rop2Bg == R2_COPYPEN*/ )//R2_COPYPEN,R2_COPYPEN

nBkRet = SetBkMode(m_diInfo.m_pDC->m_hDC, OPAQUE);

else if ( m_fgbgRops == 0x0b0d /*rop2Bg == R2_NOP*/ ) //R2_NOP,R2_COPYPEN

nBkRet = SetBkMode(m_diInfo.m_pDC->m_hDC, TRANSPARENT );

The SetBkMode call returns successfully, but appears to do nothing!

April 16th, 1999, 10:32 PM
The Suggestion I would make is read up on CBrush class, it can make the brush you want for any platform, then CBrush *pOldBrush = pDC->SelectObject(&NewBrush) will implement the new brush on the pDC, I hopes this helps

Kallol Chaudhuri
April 4th, 2002, 10:41 AM
Well, its not really straight forward. First you create a memory bitmap with the size of the window. Then draw the circle with the hatch brush on the memory bitmap. Create a monochrome bitmap from the memory bitmap. Now maskblt onto the screen the memory bitmap, with the monochrome bitmap as the mask.