Solved

transparent static text on bitmap background problem

Posted on 2002-05-05
6
490 Views
Last Modified: 2013-11-20
hi,
on the function OnCtlColor
i am doing the following in order to draw background bitmap.
{
HBRUSH hbr;

     hbr=CDialog::OnCtlColor(pDC,pWnd,nCtlColor);
         
     static HBRUSH hBrush=NULL;
     if(nCtlColor == CTLCOLOR_DLG)
     {
          CBitmap bitmap;
          bitmap.LoadBitmap(IDB_BACK);      
          if(!hBrush)
               hBrush=CreatePatternBrushbitmap);
               hbr=hBrush;    
     }
return hbr;
}


i want to show the static text i got on this dialog with the transparent style but what i get is the gray background.
i checked the transparent box in the properties.
some1 maybe got a solution?
thanks.
0
Comment
Question by:talsp
6 Comments
 
LVL 49

Expert Comment

by:DanRollins
ID: 6990710
Is the rest of the dialog background correct?  

If you want to modify the background color for the static control itself, you must change your IF statement so that CTLCOLOR_STATIC is also handled.

You may also need to handle OnEraseBkgnd().

-- Dan
0
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 6990814
Derive a class from CStatic
handle WM_ERASEBACKGROUND. In thie OnEraseBackground function draw the bitmap u want.

If u want to draw the image of the dialog, just set that bitmap to this class. This class wants to keep a memory dc of this bitmap, and draw it on OnErasebackground.

There is no need to draw the static text on the control. That all will done by the parent class

GOOD LUCK

0
 

Author Comment

by:talsp
ID: 6992198
thank you both for your answers but i still can't get it.

DanRollins: i did what u said but now only the checkboxes i am using have transparent labels but all the edit boxes and static text controls still with gray background
(btw the transparent background the checkboxes has now is not "smooth" with the background)

roshmon: i am trying to understand your point, the problem i got is that the static text i am using are created by the resource editor and not dynamically.
i am also having problem to understand it correctly i think.

thanks both an di hope u can help me more.
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 3

Expert Comment

by:Shay050799
ID: 6992342
best way is open the bitmap in paintbrush and edit it.
then save it

it'll work

Shay
0
 
LVL 49

Accepted Solution

by:
DanRollins earned 100 total points
ID: 6992408
The "Transparent" checkmark in the dialog properties does not do what it seems like it should do.

See the example at the bottom of this link:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_mfc_CWnd.3a3a.OnCtlColor.asp

You need to set

   pDC->SetBkMode(TRANSPARENT);

so that when the static text is drawn, it does not grey-fill the box.

-- Dan
0
 

Author Comment

by:talsp
ID: 6992460
thanks man,
i really appreciate your help.
the last comment of yours solve the prob.
byebye
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

743 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

13 Experts available now in Live!

Get 1:1 Help Now