![]() |
| ||
|
|
Новости |
Поиск |
FAQ |
Статьи |
Книги |
Новости VCL
| | Форумы ЧАТ |
Орешник |
|
| |||
| |||
« предыдущая ветвь | форум | следующая ветвь »
problem with transparency
Riton © (2006-11-04 17:04:00)Hello everybody,
I'd like to show text with a transparency effect on the desktop as below. It works good in delphi but not in kol. Why ? Is there a problem with the canvas ?
Indeed, a gray form is shown instead of my message "HELLO !". Can you resolve this problem please.
Thanks in advance.
Riton.
Here is the code :
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls;
type
TForm1 = class(TForm)
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormCreate(Sender: TObject);
private
{ Déclarations privées }
public
{ Déclarations publiques }
end;
var
Form1: TForm1;
HRgn,hr: THandle;
s: String;
implementation
{$R *.DFM}
procedure ShowForm(f:Tform);
begin
DeleteObject(HRgn);
s:='HELLO !';
BeginPath(f.Canvas.Handle);
with f.Canvas do
begin
Font.Name := 'times new roman'; Font.Size := 64; Font.Style := [fsBold];
TextOut(1, 1, s);
end;
hr := createrectrgn(1,1,f.canvas.TextWidth(s),f.canvas.TextHeight(s));
EndPath(f.Canvas.Handle);
HRgn := PathToRegion(f.Canvas.Handle);
combinergn(hrgn,hr,hrgn,rgn_diff);
SetWindowRgn(f.Handle,hrgn, True);
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
DeleteObject(HRgn);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
form1.BorderStyle:=Bsnone;
form1.left:=10;
form1.Top:=10;
form1.Color:=$004203E7;
ShowForm(form1);
end;
end.
Thaddy (2006-11-06 16:01:00) [1]Adapt this?
procedure TForm1.btnClick(sender:Pobj);
begin
with NewCanvas(getDc(0))^ do //desktop handle = 0!
try
SetBkMode(handle, TRANSPARENT);
Font.Color := clLime;
Font.FontStyle := [fsBold];
Font.FontName := 'Arial';
TextOut(40,40,'Drawing text on the desktop!');
finally
Free;
end;
end;
The rest of your code should easily fit in this snippet.