Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1258
  • Last Modified:

Transparent background with Visible Text

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?
  • 2
1 Solution
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.
Did you create your 'pop-up' window with a WS_BORDER style.  (Check what styles you did use for your static control)
questionerAuthor Commented:
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.
OK, understand your question. You can do like this:
1. Create a new Class.eg. 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now