Articles   Members Online: 3
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to create a round form Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
22-Oct-02
Category
VCL-Forms
Language
Delphi All Versions
Views
44
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Misha Moellner

How can I make a transparent or solid round form, without caption and border?

Answer:

This is a complete example of how to make a round form. Do not forget to create a 
TButton to close the window
   
1   unit Unit1;
2   
3   interface
4   
5   uses
6     Windows, Messages, SysUtils, Classes, Graphics, Controls,
7     Forms, Dialogs, ExtCtrls, Buttons, StdCtrls;
8   
9   type
10    TForm1 = class(TForm)
11      Button1: TButton;
12      procedure FormCreate(Sender: TObject);
13      procedure Button1Click(Sender: TObject);
14    private
15      { Private-Deklarationen}
16      procedure CreateParams(var Params: TCreateParams); override;
17    public
18      { Public-Deklarationen}
19    end;
20  
21  var
22    Form1: TForm1;
23  
24  implementation
25  
26  {$R *.DFM}
27  
28  { TForm1 }
29  
30  procedure TForm1.CreateParams(var Params: TCreateParams);
31  begin
32    inherited CreateParams(Params);
33  
34    {Remove caption and border}
35    Params.Style := Params.Style or ws_popup xor ws_dlgframe;
36  end;
37  
38  procedure TForm1.FormCreate(Sender: TObject);
39  var
40    FormRgn: hRgn;
41  begin
42    {clear form}
43    Form1.Brush.Style := bsSolid; //bsclear;
44    {make form round}
45    GetWindowRgn(Form1.Handle, FormRgn);
46  
47    { delete the old object }
48    DeleteObject(FormRgn);
49    { make the form rectangular }
50    Form1.Height := 500;
51    Form1.Width := Form1.Height;
52    { create the round form }
53    FormRgn := CreateRoundRectRgn(1, 1, Form1.Width - 1,
54      Form1.height - 1, Form1.width, Form1.height);
55  
56    { set the new round window }
57    SetWindowRgn(Form1.Handle, FormRgn, TRUE);
58  end;
59  
60  procedure TForm1.Button1Click(Sender: TObject);
61  begin
62    Form1.close;
63  end;
64  
65  end.


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC