CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 11 of 11
  1. #1
    Join Date
    Apr 2005
    Posts
    14

    Transparent checkbox on Property Page?

    I know someone must have asked this before...
    Does anyone know what to make a checkbox transparent on a PropertyPage? It seems to work fine on a Dialog, but it's all black on the PropertyPage.

    Anyone have any clues?

  2. #2
    Join Date
    May 1999
    Location
    ALABAMA, USA
    Posts
    9,917

    Re: Transparent checkbox on Property Page?

    Define: "transparent checkbox".
    Can you also post some code?
    There are only 10 types of people in the world:
    Those who understand binary and those who do not.

  3. #3
    Join Date
    Apr 2005
    Posts
    14

    Re: Transparent checkbox on Property Page?

    I'm hoping a picture is worth a thousand words:

    I didn't know how to get my bitmap to show here, so I attached it (help me with that one too? ) :-)

    Here is how I'm attempting to handle the messages to the screen

    HBRUSH CWanSetup::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
    {
    HBRUSH hbr = CPropertyPage::OnCtlColor(pDC, pWnd, nCtlColor);

    // Change any attributes of the DC here
    CBrush m_HollowBrush;
    // Return a different brush if the default is not desired
    // let static controls shine through
    switch(nCtlColor) {
    case CTLCOLOR_STATIC :
    case CTLCOLOR_BTN:
    case CTLCOLOR_MSGBOX:
    pDC->SetBkMode(TRANSPARENT);
    VERIFY(m_HollowBrush.CreateStockObject(HOLLOW_BRUSH));
    return HBRUSH(m_HollowBrush);
    default:
    break;
    }


    return hbr;
    }


    void CWanSetup::OnPaint()
    {
    CPaintDC dc(this); // device context for painting
    // Do not call CPropertyPage::OnPaint() for painting messages
    CBitmap BkBmp, *pOldBmp;
    BkBmp.LoadBitmap(IDB_BACKGROUND);
    CDC BmpDc;
    VERIFY( BmpDc.CreateCompatibleDC(&dc));
    pOldBmp = (CBitmap *)BmpDc.SelectObject(&BkBmp);
    //dc.BitBlt(0,0,m_nW, m_nH, &BmpDc, 0, 0, SRCCOPY);
    dc.BitBlt(0,0,1500, 1500, &BmpDc, 0, 0, SRCCOPY);
    BmpDc.SelectObject(pOldBmp);

    }

    BOOL CWanSetup::OnEraseBkgnd(CDC* pDC)
    {
    if(m_bmpBackground.GetPixelPtr() != 0)
    {
    CRect rc;
    GetClientRect(rc);
    int x = 0, y = 0;
    m_bmpBackground.DrawDIB(pDC, 0, 0, rc.Width(), rc.Height());
    return TRUE;
    }
    else
    return CPropertyPage::OnEraseBkgnd(pDC);
    }

    void CWanSetup::OnPaletteChanged(CWnd* pFocusWnd)
    {
    CMonroeDlg* psheet = (CMonroeDlg*) GetParent();
    psheet->OnPaletteChanged(pFocusWnd);
    CPropertyPage::OnPaletteChanged(pFocusWnd);
    }

    BOOL CWanSetup::OnQueryNewPalette()
    {
    CMonroeDlg* psheet = (CMonroeDlg*) GetParent();
    psheet->OnQueryNewPalette();
    return CPropertyPage::OnQueryNewPalette();}
    Attached Files Attached Files

  4. #4
    Join Date
    May 1999
    Location
    ALABAMA, USA
    Posts
    9,917

    Re: Transparent checkbox on Property Page?

    I am not able to reproduce your problem, providing your code you posted is exact copy of your code.

    What version of window you are using?

    By the way: next time use tags to post code snippet. It is much easier to read.
    There are only 10 types of people in the world:
    Those who understand binary and those who do not.

  5. #5
    Join Date
    Apr 2005
    Posts
    14

    Re: Transparent checkbox on Property Page?

    I'm using Visual C++ .NET which is version 7.0 I think.

    I created my project as a Dialog project and then created my PropertyPages. I'm only having problems on the PropertySheets with a background. If there's no background, there's no problem.

    What I posted is exactly what I have. How do you use tags?


    Please let me know what else I can get you to make this easier for you.

    Thanks.

  6. #6
    Andy Tacker is offline More than "Just Another Member"
    Join Date
    Jun 2001
    Location
    55°50' N 37°39' E
    Posts
    1,503

    Re: Transparent checkbox on Property Page?

    moved to VC.NET
    If you think you CAN, you can, If you think you CAN'T, you are probably right.

    Have some nice Idea to share? Write an Article Online or Email to us and You may WIN a Technical Book from CG.

  7. #7
    Join Date
    May 1999
    Location
    ALABAMA, USA
    Posts
    9,917

    Re: Transparent checkbox on Property Page?

    Quote Originally Posted by Andy Tacker
    moved to VC.NET
    Do you mean managed C++? Why? Can you elaborate?
    There are only 10 types of people in the world:
    Those who understand binary and those who do not.

  8. #8
    Join Date
    May 1999
    Location
    ALABAMA, USA
    Posts
    9,917

    Re: Transparent checkbox on Property Page?

    Quote Originally Posted by earlier by me
    IWhat version of window you are using?
    Quote Originally Posted by HoustonMcDog1
    I'm using Visual C++ .NET which is version 7.0 I think.
    Visual C++ .NET is not a Widows version. You are using Visual Studio 2000 (ver. 7.0) that is part of .NET programming environment.

    If you are not sure go Help->About. It is important to know what environment you are working in. Windows versions differ and behave differently, that is why I have asked for Windows version not developer tool version.

    I am not able to tell you what is wring since I have not encounter problem you have running app in Windows 2000.
    To reproduce an error I would have to test it on the same platform as you do. Did you try running it on different versions of Windows?
    There are only 10 types of people in the world:
    Those who understand binary and those who do not.

  9. #9
    Join Date
    May 2011
    Posts
    2

    Re: Transparent checkbox on Property Page?

    Quote Originally Posted by HoustonMcDog1 View Post
    I'm hoping a picture is worth a thousand words:

    I didn't know how to get my bitmap to show here, so I attached it (help me with that one too? ) :-)

    Here is how I'm attempting to handle the messages to the screen

    HBRUSH CWanSetup::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
    {
    HBRUSH hbr = CPropertyPage::OnCtlColor(pDC, pWnd, nCtlColor);

    // Change any attributes of the DC here
    CBrush m_HollowBrush;
    // Return a different brush if the default is not desired
    // let static controls shine through
    switch(nCtlColor) {
    case CTLCOLOR_STATIC :
    case CTLCOLOR_BTN:
    case CTLCOLOR_MSGBOX:
    pDC->SetBkMode(TRANSPARENT);
    VERIFY(m_HollowBrush.CreateStockObject(HOLLOW_BRUSH));
    return HBRUSH(m_HollowBrush);
    default:
    break;
    }


    return hbr;
    }


    void CWanSetup::OnPaint()
    {
    CPaintDC dc(this); // device context for painting
    // Do not call CPropertyPage::OnPaint() for painting messages
    CBitmap BkBmp, *pOldBmp;
    BkBmp.LoadBitmap(IDB_BACKGROUND);
    CDC BmpDc;
    VERIFY( BmpDc.CreateCompatibleDC(&dc));
    pOldBmp = (CBitmap *)BmpDc.SelectObject(&BkBmp);
    //dc.BitBlt(0,0,m_nW, m_nH, &BmpDc, 0, 0, SRCCOPY);
    dc.BitBlt(0,0,1500, 1500, &BmpDc, 0, 0, SRCCOPY);
    BmpDc.SelectObject(pOldBmp);

    }

    BOOL CWanSetup::OnEraseBkgnd(CDC* pDC)
    {
    if(m_bmpBackground.GetPixelPtr() != 0)
    {
    CRect rc;
    GetClientRect(rc);
    int x = 0, y = 0;
    m_bmpBackground.DrawDIB(pDC, 0, 0, rc.Width(), rc.Height());
    return TRUE;
    }
    else
    return CPropertyPage::OnEraseBkgnd(pDC);
    }

    void CWanSetup::OnPaletteChanged(CWnd* pFocusWnd)
    {
    CMonroeDlg* psheet = (CMonroeDlg*) GetParent();
    psheet->OnPaletteChanged(pFocusWnd);
    CPropertyPage::OnPaletteChanged(pFocusWnd);
    }

    BOOL CWanSetup::OnQueryNewPalette()
    {
    CMonroeDlg* psheet = (CMonroeDlg*) GetParent();
    psheet->OnQueryNewPalette();
    return CPropertyPage::OnQueryNewPalette();}
    Hi
    I am also facing the same problem. Please help me how you solve this problem.

  10. #10
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,675

    Re: Transparent checkbox on Property Page?

    You're aware this thread is 6 years old, are you? However, at least JohnCz is still around and maybe he sees your post.

    Note that the thread was erroneously moved here: The code discussed is native C++ with MFC while this section is for C++/CLI (formerly known as Managed C++). Which development platform are you using? In case it's C++ with MFC, the right place to ask about that is: http://www.codeguru.com/forum/forumdisplay.php?f=7
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

    This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

  11. #11
    Join Date
    May 1999
    Location
    ALABAMA, USA
    Posts
    9,917

    Re: Transparent checkbox on Property Page?

    Yes, I am still here.
    It is (as Eri523 pointed) a very old thread.
    Also, I have never seen problems that are exactly the same. Result may be the same or similar bur source of a problem is not the same.
    I would follow Eri523’s suggestion and create new thread in proper forum, attaching either snippets of your code or better yet entire sample application project presenting problem you are trying to solve.
    There are only 10 types of people in the world:
    Those who understand binary and those who do not.

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