This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unit Unit1; | |
{$mode objfpc}{$H+} | |
interface | |
uses | |
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, Spin, Windows; | |
type | |
{ TForm1 } | |
TForm1 = class(TForm) | |
Button1: TButton; | |
SpinEdit1: TSpinEdit; | |
SpinEdit2: TSpinEdit; | |
SpinEdit3: TSpinEdit; | |
SpinEdit4: TSpinEdit; | |
procedure Button1Click(Sender: TObject); | |
procedure FormCreate(Sender: TObject); | |
procedure FormResize(Sender: TObject); | |
private | |
{ private declarations } | |
public | |
{ public declarations } | |
procedure NewWindowRgn; | |
end; | |
var | |
Form1: TForm1; | |
implementation | |
{$R *.lfm} | |
{ TForm1 } | |
// Area tranparente | |
// Adaptado a partir de "Get transparent form - Forms - Tips & Tricks - Greatis Delphi Pages" | |
// http://www.greatis.com/delphicb/tips/lib/forms-transpform.html | |
procedure TForm1.NewWindowRgn; | |
var | |
FormRgn, NewRgn: THandle; | |
begin | |
FormRgn := CreateRectRgn(0, 0, Screen.Width, Screen.Height); | |
NewRgn:= CreateRectRgn( | |
SpinEdit1.Value, | |
SpinEdit2.Value, | |
SpinEdit3.Value, | |
SpinEdit4.Value); | |
CombineRgn(FormRgn, FormRgn, NewRgn, RGN_DIFF); | |
SetWindowRgn(Handle, FormRgn, True); | |
end; | |
procedure TForm1.FormCreate(Sender: TObject); | |
begin | |
HorzScrollBar.Visible:=False; | |
VertScrollBar.Visible:=False; | |
NewWindowRgn; | |
end; | |
procedure TForm1.Button1Click(Sender: TObject); | |
begin | |
NewWindowRgn; | |
end; | |
procedure TForm1.FormResize(Sender: TObject); | |
begin | |
NewWindowRgn; | |
end; | |
end. |
Infelizmente esta dica funciona apenas no Windows (não esquecer de incluir a unidade Windows na cláusula Uses).
Adaptado a partir de Get transparent form - Forms - Tips & Tricks - Greatis Delphi Pages.
[]'s,
Ericson Benjamim.
Fantástico. Gostei muito.
ResponderExcluirElias.