Transparent background with Visible Text

Posted on 2004-11-04
Last Modified: 2013-11-20
I have a frameless popup dialog box with a single static text control that follows the cursor and displays information on what the cursor is over. That part is all working quite satisfactorily.
The problem now is that the boss has decided that he doesn't like the small "box" that is around the text. e would like both the dialog box and the background of the text control to be transparent while the text is is still completely visible.
Any suggestions on how this can be done?
Question by:questioner
    LVL 9

    Expert Comment

    I don't understand why " there is a small "box" that is around the text"..
    But if you want to make your static text control transparent in dialogbox, you just need to right-click your static text control in your resource editor, then select the "Propertys" from the poped-up menu, then select the "Extended Styles" tab, and check the "Transparent" check-box. That's all.
    You also can change the style with SetWindowLong API to add the WS_EX_TRANSPARENT.
    LVL 43

    Expert Comment

    Did you create your 'pop-up' window with a WS_BORDER style.  (Check what styles you did use for your static control)

    Author Comment

    The box I was referring to is the background of the text. What the boss is wanting is to be able to see the text clearly but be able to see through the hole in the letter 'O' for example.
    I have tried the Transparent check box option and have found little success with it. In test dialogs I get no change and in my real dialog it makes my idalog transparent alright but along with the text, it isa only visible when it flashes up as it moves.

    the pop-up window does not have a WS_BORDER. It only has WS_POPUP and WS_VISIBLE. There are no styles used for the static control.
    LVL 9

    Accepted Solution

    OK, understand your question. You can do like this:
    1. Create a new CTest, derive from CStatic.
    2. Overload the OnPaint function as following
    3. Open the ClassWizard dialogbox, select "Member variables" tab, then select your dialogbox name from "Class Name:" combolist
    4. Select your static control (you need to change your static control first, e.g. IDC_STATIC2), double click on your static control's ID.
    5. Input a name for your static control in the prompted dialogbox, select "Control" from "Category:" combo-box.
    6. If you already insert the new Static class "CTest" into your project, you can see "CTest" in "Valuable type:" combo-box, select it.
    7. If you can't find "CTest" yet, you can just select CStatic first and then change all CStatic to CTest by hand.
    8. Don't forgot to include you CTest.h in your project.
    Now, everything is ready, rebuild it and test it.

    void CTest::OnPaint()
          CPaintDC dc(this); // device context for painting
          // TODO: Add your message handler code here
          dc.SetBkMode(TRANSPARENT);               // <--- set the background transparent
          // Set default font
          CWnd* pWndParent = GetParent();
          CString szCaption;
          // Do not call CStatic::OnPaint() for painting messages

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
    If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
    This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now