Solved

transparent static text on bitmap background problem

Posted on 2002-05-05
6
491 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Login Script to Copy Folders 12 28
windows 10 how make picture as desktop background 2 58
java ^ examples 8 62
sumHeights  challenge 17 66
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
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.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

920 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

11 Experts available now in Live!

Get 1:1 Help Now