?
Solved

transparent static text on bitmap background problem

Posted on 2002-05-05
6
Medium Priority
?
499 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
Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

 
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 400 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

649 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