Solved

Create a brush

Posted on 2010-08-25
14
584 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
  • 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi cmd execution 6 55
Comparing dates in Delphi. Greater than/ Less than 3 117
Print Graphic and Text to Epson TM-T88v 12 176
How to debug For loops? 3 45
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

910 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now