0

I have an application which the main form of it its called Fmain. How can i make the Fmain to be the PNG image which i have as Image1 assigned in my source?

FMain.brush.bitmap:=Image1.picture.bitmap;

that's for if the Image1 is a *.bmp one, but i need the transperancy of my PNG file.

user3211668
  • 53
  • 1
  • 3
  • 14
  • Does this http://stackoverflow.com/questions/18707850/why-the-transparency-of-a-png-image-is-lost-when-i-use-tpicture help? – ForguesR May 29 '14 at 19:26
  • no, but thanks for the try. I already have a component where i can use png images in TImage. what i need it for the main form to disappear and be replaced by the PNG image. Like this application: http://www.youtube.com/watch?v=sgZWy2E6Quk – user3211668 May 29 '14 at 19:46
  • Take a look at [`this tutorial`](http://melander.dk/articles/alphasplash2). – TLama May 29 '14 at 20:02
  • Transparent implies there will be something behind the image to show through. What is that something? – David Heffernan May 29 '14 at 21:25

2 Answers2

0

I don't think you will be able to make a custom shaped TForm with a transparent png.

Have a a look at this answer Irregularly shaped forms and more specifically to this http://docwiki.embarcadero.com/Libraries/XE2/en/Vcl.Forms.TCustomForm.TransparentColorValue .

Community
  • 1
  • 1
ForguesR
  • 3,558
  • 1
  • 17
  • 39
0

Are you wanting to make a form that has an odd shape? As in, you want to have the transparent parts of the PNG not be clickable as a form? If so then you are going about it the wrong way. If you were to put an image on the form and set the transparent properties on the image, then all you will do is see the form behind the image.

If you want to have a form that is the shape of the visible area of the PNG then you need to create an oddly shaped form. This is done by using regions and SetWindowRgn.

Luckily there is a handy tool out there for this: Gabes OddForm Assistant. I have used this to great effect a number of times.

In order to use it you will need to save your PNG as a bitmap and then load it into the utility. Once it is done it will give you the code required to make the form. You can just have a look in the pas file it creates and see how it is done, tinkering if you feel the need. You can either use the form directly or graft the code to where you need it.

Hope this helps.

EchelonKnight
  • 321
  • 2
  • 4
  • Rather than region shaped windows suggest [`layered windows`](http://msdn.microsoft.com/en-us/library/ms997507.aspx). – TLama May 30 '14 at 09:46
  • Thanks TLama, I hadn't used Layered Windows before. I found a Delphi example on the EDN here: [D: 26063, Layered Window For Delphi ver 1.0.0](http://cc.embarcadero.com/item/26063). However, for a hard-edged window the shaped window is rather simple (can be used on any existing form) and the layered window is more complicated (need to subclass it, which may not fit with the OP's hierarchy). I suppose that it is up to them though. – EchelonKnight May 30 '14 at 10:49