Topic: Example Opera Neon window background like - Enjoy ;-)
Hi,
- Create a new project
- Set Form1 (width:640, height:480),
- Add an Image (Image1),
- Set Image1 (Left:0, Top:0, Width:640, Height:480, Anchors:All, Additional\Center: True)
- Add a script file and put the following code inside (to replace the sample included),
- Add Events (OnClose, OnResize and OnShow) on Form1
- Run...
Or simply download the sample project : http://codyssea.com/downloads/019.zip.
In hope this helps,
Regards,
jihem
var
FormRatio,PictureRatio:real;
Picture:TPicture;
procedure Form1_OnResize (Sender: TObject);
var
width,
height:integer;
begin
if PictureRatio>0 then
begin
FormRatio:=Form1.Width/Form1.Height;
if (PictureRatio>FormRatio) then
begin
width:=Round(Form1.Height*PictureRatio);
Form1.Image1.Width:=width;
Form1.Image1.left:=Round((Form1.Width-width)/2);
end;
if (PictureRatio<FormRatio) then
begin
height:=Round(Form1.Width/PictureRatio);
Form1.Image1.Height:=height;
Form1.Image1.top:=Round((Form1.Height-height)/2);
end;
end;
end;
procedure Form1_OnClose (Sender: TObject; Action: string);
begin
Picture.Free;
end;
procedure Form1_OnShow (Sender: TObject; Action: string);
begin
Picture:=TPicture.Create();
Picture.LoadFromFile(GetBackgroundImage());
PictureRatio:=Picture.Width/Picture.Height;
Form1.Image1.Picture:=Picture;
end;
function GetBackgroundImage(): string;
var
Registry: TRegistry;
begin
Registry := TRegistry.Create();
try
Registry.Access := KEY_READ;
Registry.RootKey := HKEY_CURRENT_USER;
Registry.OpenKey('Control Panel\Desktop', False);
Result := Registry.ReadString('Wallpaper');
finally
Registry.Free;
end;
end;
begin
Form1.mniFile.Visible := False;
Form1.mniOptions.Visible := False;
Form1.mniSettings.Visible := False;
Form1.mniReport.Visible := False;
Form1.mniAbout.Visible := False;
end.
https://jihem.itch.io