Главная страница
    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.45 MB
Время: 0.042 c
2-1179403094
kubatura
2007-05-17 15:58
2007.06.24
игнорирование регистра в запросе


15-1179975610
Sergey Masloff
2007-05-24 07:00
2007.06.24
Посоветуйте кофигурацию компьютера


2-1180939730
Alexys
2007-06-04 10:48
2007.06.24
Кнопки


9-1154442100
nuf
2006-08-01 18:21
2007.06.24
как нарисовать прицел на экране?


15-1179906322
Сатир
2007-05-23 11:45
2007.06.24
Переход с Indy 9.0 на Indy 10.0 (вопрос для знатоков Indy)





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский