Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Create a brush

Posted on 2010-08-25
14
Medium Priority
?
597 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 200 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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 800 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 1000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
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…

721 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