?
Solved

Timage transparenty on transparent form

Posted on 2006-11-02
4
Medium Priority
?
255 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 1000 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

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

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

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
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: …
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses
Course of the Month13 days, 8 hours left to enroll

800 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