Solved

transparent static text on bitmap background problem

Posted on 2002-05-05
6
495 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
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!

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

691 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