精华区 [关闭][返回]

当前位置:网易精华区>>讨论区精华>>编程开发>>● Delphi>>图形界面和窗体>>圆形窗体

主题:圆形窗体
发信人: daji(妲姬)
整理人: teleme(2001-04-27 09:22:28), 站内信件
================================================================================
制作一个透明或实心的园形窗体,没有标题栏和边界。

{ 不要忘了添加一些可以关闭窗口的物件,程序中使用的是TButton } 
   
unit Unit1; 

interface 

uses 
  Windows, Messages, SysUtils, Classes, Graphics, Controls, 
  Forms, Dialogs, ExtCtrls, Buttons, StdCtrls; 

type 
  TForm1 = class(TForm) 
    Button1: TButton; 
    procedure FormCreate(Sender: TObject); 
    procedure Button1Click(Sender: TObject); 
  private 
    { Private-Deklarationen} 
    procedure CreateParams(var Params: TCreateParams); override; 
  public 
    { Public-Deklarationen} 
  end;       

var 
  Form1: TForm1; 

implementation 

{$R *.DFM} 

{ TForm1 } 

procedure TForm1.CreateParams(var Params: TCreateParams); 
begin 
  inherited CreateParams(Params); 

  {Remove caption and border} 
  Params.Style := Params.Style or ws_popup xor ws_dlgframe; 
end; 

procedure TForm1.FormCreate(Sender: TObject); 
var 
  FormRgn: hRgn; 
begin 
  {clear form }
  Form1.Brush.Style := bsSolid; //bsclear; 
  {make form round} 
  GetWindowRgn(Form1.Handle, FormRgn); 

  { delete the old object?} 
  DeleteObject(FormRgn); 
  { make the form rectangular } 
  Form1.Height := 500; 
  Form1.Width := Form1.Height; 
  { create the round form } 
  FormRgn := CreateRoundRectRgn(1, 1, Form1.Width - 1, 
             Form1.height - 1, Form1.width, Form1.height); 

  { set the new round window } 
  SetWindowRgn(Form1.Handle, FormRgn, TRUE); 
end; 

procedure TForm1.Button1Click(Sender: TObject); 
begin 
  Form1.close; 
end; 

end. 



----
                ^^                                    `_ ,
 ^^           |    |    |      Hello,                -(_)-
      ^^     )_)  )_)  )_)         My Friends!        ,  `
姬海涵      )___))___))___)\                  ,
           )____)____)_____)\\              __)\_
妲姬网苑 _____|____|____|____\\\__    (\_.-'    a`-.
---------\                   /--------(/~~````(/~^^`--------
  ^^^^^ ^^^^^^^^^^^^^^^^^^^^^         http://daji.xoasis.com
    ^^^^      ^^^^     ^^^    ^^      [email protected]
         ^^^^      ^^^
 

[关闭][返回]