Solved

Create a brush

Posted on 2010-08-25
14
590 Views
Last Modified: 2013-11-23
My question is, how to create a transparent bitmap on each control?
var 
MyBitmap: TBitmap;
Begin
MyBitmap:=TBitmap.Create;
MyBitmap := image1.Picture.Bitmap;

//this creates an image from image1
Form1.Brush.Bitmap:=MyBitmap;

//this creates an image too, but the image is new, it is not transparent with the form1 image
Memo1.Brush.Bitmap:=MyBitmap;

//this does not create an image, transparent with the form1
Button1.Brush.Bitmap:=MyBitmap;

Open in new window

form1
0
Comment
Question by:systan
[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
  • 5
  • 3
  • 3
  • +1
14 Comments
 
LVL 13

Expert Comment

by:aflarin
ID: 33520820
For labels you can just set Transparent property to True
0
 
LVL 13

Assisted Solution

by:aflarin
aflarin earned 50 total points
ID: 33520864
I'm afraid for other controls you have to override their paint procedure
0
 
LVL 25

Expert Comment

by:epasquier
ID: 33521850
yes, doing such transparent controls is not easy. You'll have to do it for each kind.

I'll see what I can find for some of them, I know there has been lots of work on that kind of subject.

In the meantime, there is something you do wrong, I know that it is not the subject but :

MyBitmap:=TBitmap.Create;
MyBitmap := image1.Picture.Bitmap;

You DON'T HAVE and MUST NOT create a bitmap to put in MyBitmap if it is to get it from Image1 the next line. By doing so, you are loosing the reference of the bitmap just created and some memory will leak.

simply :
MyBitmap := image1.Picture.Bitmap; (get the reference)
or :
MyBitmap:=TBitmap.Create;
MyBitmap.Assign(image1.Picture.Bitmap); (copy the content)
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 25

Expert Comment

by:epasquier
ID: 33521884
0
 
LVL 25

Expert Comment

by:epasquier
ID: 33521990
for richedit :

Richedit1.Brush.Style:=BsClear;
SetWindowLong(Form1.Richedit1.Handle, GWL_EXSTYLE, WS_EX_TRANSPARENT);

this ones have a unit for both TMemo (looks like the same as the first) and TEdit
http://www.experts-exchange.com/Programming/Languages/Pascal/Delphi/Q_20300214.html
0
 
LVL 14

Expert Comment

by:DragonSlayer
ID: 33522152
Not directly relevant, but might do for an interesting read:
http://melander.dk/articles/alphasplash/
http://melander.dk/articles/alphasplash2
0
 
LVL 14

Author Comment

by:systan
ID: 33522449
>>I'm afraid for other controls you have to override their paint procedure
I Need more research Aflarin

>>MyBitmap.Assign(image1.Picture.Bitmap); (copy the content)
>>Richedit1.Brush.Style:=BsClear;
>>SetWindowLong(Form1.Richedit1.Handle, GWL_EXSTYLE, WS_EX_TRANSPARENT);
I will Epasquier

DragonSlayer?
Alphablend?
Can this procedure applicable to my form? with the buttons, listboxes, tabmenus, labels will be alphablend to my form?  I think this is just like doing a transparent controls over the form? Isn't it?
Or this is just a few seconds alphablend then back to normal window?
0
 
LVL 14

Assisted Solution

by:DragonSlayer
DragonSlayer earned 200 total points
ID: 33522612
Not really... that's why I said it's not directly relevant, heh :-D

Back to your Q, aside from overriding Paint, you would also need to override the WM_ERASEBKGND message of the component... here's a sample:

http://delphicikk.atw.hu/listaz.php?id=1341&oldal=26
0
 
LVL 25

Accepted Solution

by:
epasquier earned 250 total points
ID: 33522676
check the memo and edit sample, they both gives you the principles of what you have to look at.
0
 
LVL 14

Author Closing Comment

by:systan
ID: 33523054
>>override the WM_ERASEBKGND message
I think this is also connected with what epasquier's comment_v

>>check the memo and edit sample, they both gives you the principles of what you have to look at.
Yes, I have that in mind when I see the code,  thanks epasquier.


Why wait,  this post is closed.
Thanks a lot friends, experts
0
 
LVL 14

Expert Comment

by:DragonSlayer
ID: 33523159
Actually you do not have to award me some of the points... epasquier did a good enough job... I was just pointing out similar samples. I'm not into this for the points anyway :-D
0
 
LVL 13

Expert Comment

by:aflarin
ID: 33523258
>> Actually you do not have to award me some of the points... epasquier did a good enough job

I agree at all. Great job, epasquier
0
 
LVL 14

Author Comment

by:systan
ID: 33524539
Excuse me fellows,
But  I did what I want,   just like I did in some of my questions.
I'm not a gridy kind of person,  the point here is that you contributed, helped, as epaquier said "team work", so the rest of you shall have a share.   I am the one incharge if the comment is good for me or not,  so please understand the asker, me.


Thank you all
0
 
LVL 25

Expert Comment

by:epasquier
ID: 33525939
Yes, Team Work !  I'm glad somebody in that last post heard the message how it was intended.
I have no complaints with your way of distributing points, I find it fair and only wish it would be always the same for all askers.
0

Featured Post

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

734 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