Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Timage transparenty on transparent form

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

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

618 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