Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "KOL";
Текущий архив: 2007.06.24;
Скачать: [xml.tar.bz2];

Вниз

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 вся ветка

Форум: "KOL";
Текущий архив: 2007.06.24;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.44 MB
Время: 2.081 c
2-1180234804
vegarulez
2007-05-27 07:00
2007.06.24
Пинг, TIdIcmpClient, except.


2-1180594297
Dimonnnmn
2007-05-31 10:51
2007.06.24
База данных


2-1180593796
Soi_
2007-05-31 10:43
2007.06.24
Сортировка данных


2-1180941562
mrFreeman
2007-06-04 11:19
2007.06.24
Преобразование TStrings в String и чтение строк из TListBox


2-1180439123
Demon123
2007-05-29 15:45
2007.06.24
Супер сложная задача





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
Английский Французский Немецкий Итальянский Португальский Русский Испанский