1 (edited by jihem 2018-01-07 09:55:57)

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.
while(! success=retry());
https://jihem.itch.io

Re: Example Opera Neon window background like - Enjoy ;-)

Thank you for the example!

Dmitry.

Re: Example Opera Neon window background like - Enjoy ;-)

I try it, working good in windows 7 but not working up to windows 7, mean 8, 8.1 and Windows 10 does not support this type of script. Anyone can update this script for windows 10 because it gives me an error invalid floating point.

JUST LEARNING, O GOD HELP ME.

4 (edited by jihem 2019-08-14 00:31:02)

Re: Example Opera Neon window background like - Enjoy ;-)

Hi,
I use this on Windows 10 on a lot of computers (and I nether got this issue !?).
The floating point error involve the calculus. Try to replace

Picture.LoadFromFile(GetBackgroundImage());

by

Picture.LoadFromFile('filepath to a test picture');

. Check the values : Picture.Width and Picture.Height.

The error may be linked to :
- a registry access deny
- a forbiden filepath to the picture
- an unsupported picture file (by LoadFromFile)
- a corrupted picture file (with wrong size values)
- an unsupported screen resolution

Let me know if this helps you.

Regards,
jihem

while(! success=retry());
https://jihem.itch.io

5 (edited by Asifmute 2019-08-14 13:22:00)

Re: Example Opera Neon window background like - Enjoy ;-)

I try the best but got still the same problem, I use windows 10 X64 Education version.
Please check the screenshot.

Post's attachments

Attachment icon Untitled.jpg 10.6 kb, 15 downloads since 2019-08-14 

JUST LEARNING, O GOD HELP ME.

Re: Example Opera Neon window background like - Enjoy ;-)

Hi,
You can add

ShowMessage('procedure name begin');

and

ShowMessage('procedure name end');

at the begin and at the end of the procedures to know where the error occurs.

Then you can add "ShowMessage" inside the procedure to show the values.
So you can see what's wrong.

Have you tried with another background image (ou file format) ?
Which version of My Visual Database are you using ?

Regards,
jihem

while(! success=retry());
https://jihem.itch.io

Re: Example Opera Neon window background like - Enjoy ;-)

Hello Jihem, Hello Asifmute

This project is OK for me (under W 10)
As proposed by Jihem, replacing the instruction Picture.LoadFromFile(GetBackgroundImage());
by the exact path of the image Picture.LoadFromFile('d:\My_prretty_boat.jpg');, no error message
and the background of the form is filled by picture of a boat.

No need to use the flags Showmessage

JB

Re: Example Opera Neon window background like - Enjoy ;-)

Yes this script work perfectly, under win 10, the problem occurs after installing win 10 feature
  updates.

JUST LEARNING, O GOD HELP ME.