Write on the Desktop, create\access functions, select font


[ Delphi Tutorials -- by DelphiLand ]

Posted by bob P12404 on December 12, 2004 at 21:42:34:

Hi,
I've created a little app that will write on the desktop what ever you put in the code. Need help in modifying it please. I'll post my questions first then the source that I'm using. Thanks for any pointers...

Questions :
1) How can I create a modal form that will be used to alter\select the font type\size on the code below. After\before the text is sent to the desktop, I'd like to be able to modify the displayed font.

2) How can I create a modal form that will enable me to set the desktop screen cooridinates dynamically, instead of just using "DeskTopCanvas.TextOut(400,300,'Here is some text, it works, yippeeeee!!!');" in the code below. I'd like to use some kind of input box, don't know how to set it up.

3) As it is set up now, it prints out the text to the desktop, but not quite, really. Part of it prints out on the form, and when you move\drag the form, it moves whatever text that is on the form with it. So it seems like it's not quite printing to the desktop perse. Is there a Z-index something that I need to know about?

4) How can I make it transparent behind the text, ie let whatever that's on the desktop behind the text shine through. Just have the text, not the "white" background behind the text show.

OK, here's what I have :

{TexTopMainForm.pas}
unit TexTopMainForm;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, ExtCtrls;

type
TForm1 = class(TForm)
Panel1: TPanel;
StatusBar1: TStatusBar;
GroupBox1: TGroupBox;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
DeskTopCanvas:TCanvas;
implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
{We have set the DeskTopCanvas values}
DeskTopCanvas:=TCanvas.Create;
DeskTopCanvas.Handle:=GetDC(Hwnd_Desktop);
{This command will show the current text in the screen corner}
DeskTopCanvas.TextOut(400,300,'Here is some text, it works, yippeeeee!!!');
end;

end.

{TexTopMainForm.dfm}
object Form1: TForm1
Left = 408
Top = 113
Width = 446
Height = 312
BorderIcons = [biSystemMenu, biMinimize]
Caption = ' TexTop '
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Panel1: TPanel
Left = 0
Top = 0
Width = 438
Height = 30
Align = alTop
TabOrder = 0
object Button1: TButton
Left = 6
Top = 5
Width = 110
Height = 20
Caption = ' Send text to Desktop '
TabOrder = 0
OnClick = Button1Click
end
end
object StatusBar1: TStatusBar
Left = 0
Top = 266
Width = 438
Height = 19
Panels =
end
object GroupBox1: TGroupBox
Left = 0
Top = 30
Width = 438
Height = 236
Align = alClient
Caption = ' Yet to come '
TabOrder = 2
end
end

{TexTop.dpr}
program TexTop;

uses
Forms,
TexTopMainForm in 'TexTopMainForm.pas' {Form1};

{$R *.res}

begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.

Thanks again...



Related Articles and Replies


[ Delphi Tutorials -- by DelphiLand ]