CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 1999
    Posts
    2

    How do you draw a transparent hatch brush in NT4?



    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!



  2. #2
    Guest

    Re: How do you draw a transparent hatch brush in NT4?

    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


  3. #3
    Join Date
    Apr 2002
    Posts
    3

    Re: How do you draw a transparent hatch brush in NT4?

    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.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured