Solved

Transparent Form

Posted on 1998-06-30
11
377 Views
Last Modified: 2010-04-04
Hi, Can any one tell me how to create a transparent form in Delphi 3?
By transparent, I mean that the form it self is invisible, while the complementary objects remain visible!
  I will apreciate very much if you can put an example source code in the answer!
0
Comment
Question by:jconde
11 Comments
 
LVL 8

Expert Comment

by:ZifNab
Comment Utility
Hi jconde,

What do you mean exactely with a transparent form? What do you want to accomplish?

Zif.
0
 
LVL 7

Author Comment

by:jconde
Comment Utility
Edited text of question
0
 
LVL 1

Expert Comment

by:Greedy
Comment Utility
hummm...do you want the user to be able to move this form (quickly)...oh actually I think I have a quick way they could even move it...when they want to move this window change it to outline drag instead of full contents drag...then after the move you read in the section of the screen memory that would be under the window and display this as a background bitmap...I know all the routines but making a source code example will eat too much time from me and besides Ziffy needs the points to be #1.  To get an example of reading in the screen do a deja news search for 'screen capture routine with delphi'  
0
 
LVL 4

Accepted Solution

by:
BoRiS earned 100 total points
Comment Utility
jconde

(Quote)Use a TForm. Override its CreateParams method and Or the WS_EX_TRANSPARENT style into Params.Exstyle after you called the inherited method. Add a handler for the WM_ERASEBKGND message and have it return msg.result := 1
*without* calling the inherited handler. That gives you about the best
Windows has on offer re transparency. (Unquote Peter below TeamB)

So I did Something like this...

first create the procedure CreateParams...

procedure CreateParams( var Params: TCreateParams );

then passed it like so

procedure TForm1.CreateParams( var Params: TCreateParams );
begin
  inherited CreateParams( Params );
  Params.ExStyle := Params.ExStyle or WS_EX_TRANSPARENT;
end;

then just to check I placed a button on the for that would create a Tedit on the form...

procedure TForm1.Button1Click(Sender: TObject);
var       PEdit : TEdit;
begin
  PEdit := TEdit.Create(Form1 );
  PEdit.Parent := Self;
  inc( n, 20 );
  PEdit.Top := n;
  PEdit.Left := n;
  PEdit.color := clGray;
  PEdit.Visible := true;
end;

hope this helps....

Later
BoRiS
0
 
LVL 4

Expert Comment

by:jeurk
Comment Utility
Hello,
I suggest you use the following component that you will find
at
http://www.wirtschaft.TU-Ilmenau.DE/~aeg/
look in the self made section for a component called
tshapeform
it free and it's the best transparent form component ever trust me.
I'm using it.
I hope it helps.
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 5

Expert Comment

by:ronit051397
Comment Utility
Don't forget the override in the CreateParams.
0
 
LVL 7

Author Comment

by:jconde
Comment Utility
Thanks everyone,  I'm really pleased to see this site working better than the delphi news group.  Hats off to you all!!!
0
 
LVL 7

Author Comment

by:jconde
Comment Utility
Thanx jeurk,roint,boris
0
 
LVL 1

Expert Comment

by:sviksna
Comment Utility
Hello,
You can use this way:
at first, you must set, tahat the form.borderstyle is bsNone

and then use

procedure TForm1.FormCreate(Sender: TObject);
begin
brush.style := bsClear;
end;

if you remove form, you must repain the form. So that's all. I think it's very esay and looks great.

Sandis Viksna,
http://www.ogre2vsk.edu.lv/viksna/
0
 
LVL 1

Expert Comment

by:sviksna
Comment Utility
sorry,
not "you must repain the form."
but "you must repaint the form."

bye
0
 

Expert Comment

by:joanita
Comment Utility
1. Sandis Viksna solution (borderstyle bsnone and brush.style bsClear) is by far the best and simplest.
Do not forget to have an arrangement to close the form ie by a timer or mouse/key board event as all ' visual handles' to the form are  lost with bsnone as border style.
2.If you need a cirular or elliptical shaped form try this
procedure TMyShape.FormCreate(Sender: TObject);
var
R : HRgn;
x1,x2,y1,y2 : integer;
begin
{x1 := ....
...
..}
R := CreateEllipticRgnIndirect(Rect(x1,y1,x2,y2));
SetWindowRgn(Handle,R,True);
end;
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now