Solved

transparent static text on bitmap background problem

Posted on 2002-05-05
6
494 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

Technology Partners: 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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C++ BOOL WINAPI ReadFile fails on windows 10 when reading from USB cable 9 520
dog bark java program 15 121
Message not shown 5 85
Adjust the codes 3 33
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 …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

733 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