Solved

Timage transparenty on transparent form

Posted on 2006-11-02
4
253 Views
Last Modified: 2010-04-05
Hello developers

I have successfully created a TImage with transparency using this code:

  Image1.Picture.Bitmap.TransparentColor :=  Image1.Picture.Bitmap.Canvas.Pixels[50,300];    
  Image1.Picture.Bitmap.TransparentMode := tmFixed;
  Image1.Transparent := true;

This works fine.

Secondy I need my form to be transparent, which is done using this code:

procedure TForm.FormCreate(Sender: TObject);
var
  hRgn: Cardinal;
  i: Integer;
begin
 //Transparentform
  with FormProducts do
  begin
    BorderStyle := bsNone;
    hRgn := CreateRectRgn(0, 0, 0, 0);
    for i := 0 to ControlCount - 1 do
      with Controls[i].BoundsRect do
        CombineRgn(hRgn, hRgn, CreateRectRgn(Left, Top, Right, Bottom), RGN_OR);
    SetWindowRgn(handle, hRgn, True);
  end;
end;

Which also works. The problems arise when these snippets are combined. The image doesn't show the graphics behind the form, but shows the color the form was before it became transparent. Any idea how to get around this problem?

My main task is to create a form which isn't triangular. I need some of the edges to be round and follow the shape of some images. If anyone has a different idea to do this it would also be most welcome.
0
Comment
Question by:Robert_MP
[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
4 Comments
 
LVL 11

Expert Comment

by:Mihai Stancescu
ID: 17856826
Try to put the transparent color of the form to the color that remains visible.

Regards,
Mishu
0
 
LVL 14

Accepted Solution

by:
Pierre Cornelius earned 250 total points
ID: 17857026
You need to intercept the WM_EraseBkgnd message passed to the form. something like:

type
  TMyTransparentForm = Class(TCustomForm)
...
  private
    procedure WMEraseBkgnd(var Message: TWmEraseBkgnd); message WM_ERASEBKGND;
...  
  end;

...
procedure TForm1.WMEraseBkgnd(var Message: TWmEraseBkgnd);
begin
  Message.Result:= 1;
end;
...
0

Featured Post

Independent Software Vendors: 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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Print Graphic and Text to Epson TM-T88v 12 538
Performance of SQL statement 37 143
Tembedded WB animatid gifs not animated on some pcs 2 89
firemonkey Android Listview Sort items 7 95
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…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

738 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