How to fade some components in the background to highlight a TPanel on them?

1

I have a main screen, with some TPanels and other components, and one of these TPanels would like to create a login screen. When calling this login TPanel over the other components of the form I am disabling the components from below, as if it were a "modal" used in websites. But I would also like to leave the low-dimmed components (darkened). Is there any simple way to do this using Delphi 7? I already researched a lot and did not find, just methods of animation.

Here's an example of what I'd like to do:

Thank you in advance for your help!

    
asked by anonymous 14.06.2017 / 16:47

1 answer

1

Hello, after the image you sent, I broke my head.

The simplest solution I found was to use Project Jedi that adds many components.

The idea was to put a Panel with transparent alClient and inside it a semitransparent image and looked like this:

The code:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, pngimage, ExtCtrls, JvExExtCtrls, JvExtComponent, JvPanel,
  StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    btn1: TButton;
    jvpnl1: TJvPanel;
    Button2: TButton;
    Image1: TImage;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure btn1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  jvpnl1.Align := alClient;
  jvpnl1.Visible := True;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  jvpnl1.Visible := False;
end;

procedure TForm1.btn1Click(Sender: TObject);
begin
  Close;
end;

end.

File Unit1.dmf

object Form1: TForm1
  Left = 192
  Top = 117
  Width = 829
  Height = 413
  Caption = 'Form1'
  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 Button1: TButton
    Left = 152
    Top = 40
    Width = 75
    Height = 25
    Caption = 'Button1'
    TabOrder = 0
    OnClick = Button1Click
  end
  object btn1: TButton
    Left = 256
    Top = 152
    Width = 75
    Height = 25
    Caption = 'btn1'
    TabOrder = 1
    OnClick = btn1Click
  end
  object jvpnl1: TJvPanel
    Left = 456
    Top = 80
    Width = 337
    Height = 201
    Transparent = True
    BevelOuter = bvNone
    TabOrder = 2
    Visible = False
    object Image1: TImage
      Left = 0
      Top = 0
      Width = 337
      Height = 201
      Align = alClient
      Picture.Data = {
        0A54504E474F626A65637489504E470D0A1A0A0000000D49484452000000F000
        0000C80806000000D67C6C52000002424944415478DAEDD3010D00301003A1BE
        7F6B13351D9780076EDB1B90741318B204863081214C60081318C20486308121
        4C60081318C204863081214C60081318C204863081214C60081318C204863081
        214C60081318C204863081214C60081318C204863081214C60081318C2048630
        81214C60081318C204863081214C60081318C204863081214C60081318C20486
        3081214C60081318C204863081214C60081318C204863081214C60081318C204
        863081214C60081318C204863081214C60081318C204863081214C60081318C2
        04863081214C60081318C204863081214C60081318C204863081214C60081318
        C204863081214C60081318C204863081214C60081318C204863081214C600813
        18C204863081214C60081318C204863081214C60081318C204863081214C6008
        1318C204863081214C60081318C204863081214C60081318C204863081214C60
        081318C204863081214C60081318C204863081214C60081318C204863081214C
        60081318C204863081214C60081318C204863081214C60081318C20486308121
        4C60081318C204863081214C60081318C204863081214C60081318C204863081
        214C60081318C204863081214C60081318C204863081214C60081318C2048630
        81214C60081318C204863081214C60081318C204863081214C60081318C20486
        3081214C60081318C204863081214C60081318C204863081214C60081318C204
        863081214C60081318C204863081214C60081318C204863081214C60081318C2
        04863081214C60081318C20486308121EC030928A029907BE5A9000000004945
        4E44AE426082}
      Stretch = True
      Transparent = True
    end
    object Button2: TButton
      Left = 64
      Top = 32
      Width = 75
      Height = 25
      Caption = 'Button2'
      TabOrder = 0
      OnClick = Button2Click
    end
  end
end
    
23.06.2017 / 16:37