Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2007.06.24;
Скачать: CL | DM;

Вниз

problem with transparency   Найти похожие ветки 

 
Riton   (2006-11-04 17:04) [0]

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) [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.



Страницы: 1 вся ветка

Текущий архив: 2007.06.24;
Скачать: CL | DM;

Наверх




Память: 0.47 MB
Время: 0.019 c
2-1180612312
pathfinder
2007-05-31 15:51
2007.06.24
Передача объекта как параметра..


15-1179773449
Астроном
2007-05-21 22:50
2007.06.24
Фотография воды на Марсе...


15-1180100568
tesseract
2007-05-25 17:42
2007.06.24
Ну и мощный он perl


2-1180532037
andreyka
2007-05-30 17:33
2007.06.24
сохранение StringGrid


2-1180707150
AndrewBB
2007-06-01 18:12
2007.06.24
Битовые строки