Главная страница
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.02 c
2-1180525602
lopi
2007-05-30 15:46
2007.06.24
*.*


2-1180234804
vegarulez
2007-05-27 07:00
2007.06.24
Пинг, TIdIcmpClient, except.


3-1175243884
elserpiente
2007-03-30 12:38
2007.06.24
диалог создания строки подключения в ADOConnection в runtime


2-1178607605
Pi314159265358979
2007-05-08 11:00
2007.06.24
Вид файлов в FileListBox


15-1180502196
worldmen
2007-05-30 09:16
2007.06.24
Не устанавливаеться Delphi 5