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?
questionerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

BeyondWuCommented:
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.
0
AndyAinscowFreelance programmer / ConsultantCommented:
Did you create your 'pop-up' window with a WS_BORDER style.  (Check what styles you did use for your static control)
0
questionerAuthor Commented:
BeyondWu:
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.

AndyAinscow:
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.
0
BeyondWuCommented:
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();
      if(pWndParent)
            dc.SelectObject(pWndParent->GetFont());
      CString szCaption;
      GetWindowText(szCaption);
      dc.TextOut(0,0,szCaption);
      // Do not call CStatic::OnPaint() for painting messages
}
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.