Author Topic: [SOLVED] Images and controls  (Read 263 times)

Petrus Vorster

  • Sr. Member
  • ****
  • Posts: 261
[SOLVED] Images and controls
« on: August 28, 2026, 11:18:26 am »
Hi All

I started a project with an background image on the main form.
It simply uses the current one currently on the Desktop.

I have observed something interesting.
1. If  Windows is set to a background color instead of an image, my form becomes transparent. My panels shows, but everywhere the image would have been is transparent. It also allows mouse movements to highlight desktop icons that was underneath.

2. A PAGECONTROL opens for some function with Tabpages on it. Its Zorder is on top of everything in the form.
A DBNAVIGATOR on that Tabsheet seems to have some Transparent border that shows the Windows desktop underneath the project. Dragging the form makes it very obvious.

Perhaps the background image idea on the form was not the best idea.

-Peter
No other control seems to do it.
« Last Edit: September 01, 2026, 10:39:07 am by Petrus Vorster »

Ñuño_Martínez

  • Hero Member
  • *****
  • Posts: 1228
    • Burdjia
Re: Images and controls
« Reply #1 on: August 31, 2026, 07:07:49 pm »
I'm curious:  How do you assign the desktop background to the form?  Is it portable?
Are you interested in game programming? Join the Pascal Game Development community!
Also visit the Game Development Portal

Petrus Vorster

  • Sr. Member
  • ****
  • Posts: 261
Re: Images and controls
« Reply #2 on: September 01, 2026, 10:33:09 am »
Hi

Basically just ask windows what its current background is.
A bit of AI code and a Timage that is anchored to the main form borders.
I deleted the whole thing, because it causes weird tranparency on some cotrols.

Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls,
  9.   Windows;
  10.  
  11. type
  12.  
  13.   { TForm1 }
  14.  
  15.   TForm1 = class(TForm)
  16.     Button1: TButton;
  17.     Image1: TImage;
  18.     procedure Button1Click(Sender: TObject);
  19.   private
  20.  
  21.   public
  22.  
  23.   end;
  24.  
  25. var
  26.   Form1: TForm1;
  27.  
  28. implementation
  29.  
  30.  
  31. procedure TForm1.Button1Click(Sender: TObject);
  32. var
  33.   WallpaperPath: array[0..MAX_PATH] of Char;
  34. begin
  35.  
  36.   FillChar(WallpaperPath, SizeOf(WallpaperPath), 0);
  37.   if SystemParametersInfo(SPI_GETDESKWALLPAPER, MAX_PATH, @WallpaperPath, 0) then
  38.   begin
  39.     // Check if file exists and load it into TImage
  40.     if FileExists(WallpaperPath) then
  41.     begin
  42.       Image1.Picture.LoadFromFile(WallpaperPath);
  43.     end
  44.     else
  45.       ShowMessage('Wallpaper file not found: ' + WallpaperPath);
  46.   end
  47.   else
  48.     ShowMessage('Failed to query wallpaper information.');
  49. end;
  50.  
  51. end.

Then you set the Image to stretch and/Or proportional.

But like I said, you get odd stuff happening here and there.  :D

-Peter

Petrus Vorster

  • Sr. Member
  • ****
  • Posts: 261
Re: [SOLVED] Images and controls
« Reply #3 on: September 01, 2026, 10:39:33 am »
NOT SOLVED, but notimportant anymore.
-Peter

Zvoni

  • Hero Member
  • *****
  • Posts: 3532
Re: [SOLVED] Images and controls
« Reply #4 on: September 01, 2026, 11:45:53 am »
You do realize, that if your FileExists above returns False (because it's not a Picture but a color), you can check "Transparent" of the TImage and set it to False?
Resp. the AlphaBlend/AlphaBlendValue of the Form?
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

Petrus Vorster

  • Sr. Member
  • ****
  • Posts: 261
Re: [SOLVED] Images and controls
« Reply #5 on: September 02, 2026, 02:18:07 pm »
Thats good to know.

At first this kind of looked like a great idea, but then I ran into a problem where i wanted my buttons to look like Windows icons.
The LOOK part was not difficult, but Windows Desktop icons text has a little black border around the text and I was unable to replicate that, which made reading the text hard on some backgrounds.

Then there was this weird issue with the DB navigator. I have placed a Pagecontrol with some Tabsheets on it. Worked like a charm except the DBnavigator that would have a little odd border showing some text or whatever was on the screen below the running project.

Too much trouble for a not-so-important project.

But as always, I am most grateful for your inputs.

-Peter

 

TinyPortal © 2005-2018