Solved

Timage transparenty on transparent form

Posted on 2006-11-02
4
254 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

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

696 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