Solved

Create a brush

Posted on 2010-08-25
14
588 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
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!

 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

730 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