Display transparent images on desktop

Display transparent images on desktop

Display transparent images on desktop

This Delphi graphic tutorial shows how to display a transparent image on desktop. Main technique we using here is full screen transparent form and then place image object on form. By few simple changes you can create various effect like generating mouse trail and more.

DownloadDownload This Tutorials

Bookmark:

Display transparent images on desktop

Click anywhere on the desktop to show an image (flower) at mouse position. Basically what this program does is using full screen transparent form, put a transparent bitmap image on mouse position. Once you go through this program you may amaze how easy to write this program.

Draw crosshair on form

Use following commands to make transparent form and hide the image at start up.

procedure TForm1.FormCreate(Sender: TObject);
begin
     { Set transparent background }
     Brush.Style:=bsClear;

     { Hide image at start up }
     Image1.Visible := False;
end;

This one put the flower (bitmap image) at mouse position.

procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
     { Show image at current cursor position }
     Image1.Top := Y - Round(Image1.Height / 2);
     Image1.Left := X - Round(Image1.Width / 2);
     Image1.Visible := True;
end;

You can do few changes to generate images randomly on screen using system timer.

procedure TForm1.Timer1Timer(Sender: TObject);
begin
     Image1.Top:=Random(Screen.Height);
     Image1.Left:=Random(Screen.Width);
end;

If you like to generate mouse trail effect by placing images on screen, use following method.

procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
begin
     { Set new image position at cursor }
     Image1.Top := Mouse.CursorPos.Y - Round(Image1.Height / 2);
     Image1.Left := Mouse.CursorPos.X - Round(Image1.Width / 2);
end;

If you like to generate mouse trailer effect by placing different images on screen, use following method. Show varies flowers as user move mouse. Flower are changed randomly as user move mouse. All the images are stored in ImageList components.

procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
begin
     { Clear the previous image }
     Image1.Picture:=Image2.Picture;

     { Randomly assigned a image from image list
     GetBitmap - Retrieves a specified image as a bitmap.}
     ImageList1.GetBitmap(Random(10), Image1.Picture.Bitmap);

     { Set new image position at cursor }
     Image1.Top := Y - Round(Image1.Height / 2);
     Image1.Left := X - Round(Image1.Width / 2);
end;

Download This Delphi Tutorials.

Download materials for this article (Delphi - Tutorials)

Download - display-image-on-desktop.zipdisplay-image-on-desktop.zip
       File size: 32 KB, File type: zip
       Total downloads: 438, Upload date: February 11 - 2009

Download - display-images-randomly-on-desktop.zipdisplay-images-randomly-on-desktop.zip
       File size: 33 KB, File type: zip
       Total downloads: 241, Upload date: February 11 - 2009

Download - image-mouse-trail.zipimage-mouse-trail.zip
       File size: 32 KB, File type: zip
       Total downloads: 235, Upload date: February 11 - 2009

Download - random-images-mouse-trail.ziprandom-images-mouse-trail.zip
       File size: 313 KB, File type: zip
       Total downloads: 228, Upload date: February 11 - 2009

dohab :: April 26-2010 :: 01:56 PM

you are the man! It's perfect !

Leave a comment