Solved

Transparent Form

Posted on 1998-06-30
11
378 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
ID: 1356708
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
ID: 1356709
Edited text of question
0
 
LVL 1

Expert Comment

by:Greedy
ID: 1356710
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
ID: 1356711
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
ID: 1356712
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 5

Expert Comment

by:ronit051397
ID: 1356713
Don't forget the override in the CreateParams.
0
 
LVL 7

Author Comment

by:jconde
ID: 1356714
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
ID: 1356715
Thanx jeurk,roint,boris
0
 
LVL 1

Expert Comment

by:sviksna
ID: 1356716
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
ID: 1356717
sorry,
not "you must repain the form."
but "you must repaint the form."

bye
0
 

Expert Comment

by:joanita
ID: 1356718
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
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…
A short film showing how OnPage and Connectwise integration works.
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.

929 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

8 Experts available now in Live!

Get 1:1 Help Now