Solved

Transparent Form

Posted on 1998-06-30
11
379 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
ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

 
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
 
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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 a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

803 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