Mega Code Archive

 
Categories / Delphi / Examples
 

Magnifyingglass

Subject: Re: Round child forms >Date: Wed, 31 Mar 1999 14:05:46 -0500 >From: "Anthony Farrell" <afarrell@hteinc.com> >Hi all, >I am looking for a way to implement a type of magnifying >glass into an application. >It needs to be round (ugh), and it cannot extend beyond >the parent form. >If anyone has any ideas, please drop me a line. >thanks >tony Search the Win32 programmers help file for "region". Here are some APIs: CreateEllipticRgn -- Creates elliptic window CreateEllipticRgnIndirect CreatePolygonRgn -- Creates customshaped window CreatePolyPolygonRgn CreateRectRgn -- Creates rectangular window(default) CreateRectRgnIndirect CreateRoundRectRgn -- Creates round-edged window Here is an example (can't remember the authors name): ---------------------------------------------------------------------------- ---- unit Unit1; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, Buttons; type TForm1 = class(TForm) Image1: TImage; SpeedButton1: TSpeedButton; procedure FormCreate(Sender: TObject); procedure SpeedButton1Click(Sender: TObject); private { Private declarations } procedure CreateParams(var Params: TCreateParams); override; public { Public declarations } end; var Form1: TForm1; implementation procedure TForm1.CreateParams(var Params: TCreateParams); begin inherited createparams(params); {This makes a borderless and captionless form} params.style:=params.style or ws_popup xor ws_dlgframe; end; {$R *.DFM} procedure TForm1.FormCreate(Sender: TObject); var formrgn:hrgn; begin {makes the form clear} form1.brush.style:=bsclear; {makes the form round} GetWindowRgn(form1.Handle, formRgn); DeleteObject(formRgn); formrgn:= CreateRoundRectRgn(0, 0,form1.width,form1.width,form1.width,form1.width); SetWindowRgn(form1.Handle, formrgn, TRUE); end; procedure TForm1.SpeedButton1Click(Sender: TObject); begin form1.close; end; end.