3

I'm Trying to do, in delphi, that when you press a button, I display a drop-down panel with options like this:

Panel Desplegable

Does anyone know how to make this effect with VCL? Now I have a form with 2 panels, the main is always showing and has a side button, and when I press the button the side panel is shown, but I would like to make the effect. Thank you

Sir Rufo
  • 18,395
  • 2
  • 39
  • 73
elcharlie
  • 511
  • 8
  • 25
  • Hard to know where to begin. You don't really mean vlc do you? What have you got so far? In what way are you stuck? – David Heffernan Jan 16 '14 at 11:42
  • I'm using [AnimateWindow](http://msdn.microsoft.com/en-us/library/windows/desktop/ms632669%28v=vs.85%29.aspx) WinAPI command for this when using VCL forms. The downside is that your UI is frozen for the time of the Animation so better use it for short and quick animations. [1]: "AnimateWindow" – Günther the Beautiful Jan 16 '14 at 12:16
  • VLC (VideoLAN client) or VCL (Visual Components Library for Delphi) ??? Perhaps he need a sliding-out panel +non-rectangular window (or two windows). – Arioch 'The Jan 16 '14 at 12:18
  • "Now I have a form with 2 panels, the main is always showing and has a side button, and when I press the button the side panel is shown" - so a panel is hidden and showed when a button is pressed – RBA Jan 16 '14 at 12:23

4 Answers4

9

I dont know your application in detail, with the transparency and other things. However, I think you will have to animate your panels/windows in some sort of loop on your own. I dont know of any VCL function for that.

Here is an example which animates a Window (its quick and dirty though):

enter image description here

Code:

procedure TForm1.Button1Click(Sender: TObject);
var
  I, X: Integer;
begin
  Form2.Width := 1;
  Form2.Height := Form1.Height;
  Form2.Left := Form1.Left + Form1.Width;
  Form2.Top := Form1.Top;
  Form2.Show;

  Timer1.Enabled := true;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  if I < 500 then
  begin
    I := I + 1;
    Form2.Width := I;
  end
  else
  begin
    Timer1.Enabled := false;
  end;
end;

Not perfect, but hopefully good enough to give you an idea.

Andy

DA.
  • 849
  • 6
  • 19
  • 1
    I'd reconsider using `Application.ProcessMessages()`. What if the user clicks the Button again when the Animation is already in Progress? – Günther the Beautiful Jan 16 '14 at 12:14
  • 6
    Don't use `ProcessMessages`. A timer is what you want here. Seeing both `Sleep` and `ProcessMessages` next to each other gives me the creeps! – David Heffernan Jan 16 '14 at 12:32
  • 1
    clear enough how to do this with 2 panels. DA gave the answer who match the OP's desire.Even it is using 2 forms instead of 2 panels as asked. seems that SO and Delphi are became a sort of crystal magic...+1 for the answer and effort of DA – RBA Jan 16 '14 at 17:36
4

you can use TJvRollOut from Jedi JVCL. It acts like a panel which colapse and expand. Also you can take a look at Delphi: sliding (animated) panel and Hide, Slide And Fade Away Controls On A Delphi Form

Community
  • 1
  • 1
RBA
  • 12,337
  • 16
  • 79
  • 126
  • 1
    but he needs that outside the form – Arioch 'The Jan 16 '14 at 12:18
  • From the OP's question I understood that he want that with a panel - 'Now I have a form with 2 panels' – RBA Jan 16 '14 at 12:21
  • @Arioch'The - based on the accepted answer it seems that's what the OP asked.An animated gif and a copy-paste code, this is the right answer, so OP got the desired result from VLC(yes vlc). – RBA Jan 16 '14 at 17:39
2

Finally, I managed to make the effect. I put a panel and I have added a picture. then I used animatedwindows in buton click process.

procedure TFTelefonoSIP.Button1Click(Sender: TObject);
begin
  if  GDPanelLlamadasHidden = False then
  begin
    AnimateWindow(Panel1.Handle, 200, AW_SLIDE or AW_HOR_POSITIVE or AW_HIDE);
    GDPanelLlamadasHidden := True;
  end
  else
  begin
    AnimateWindow(Panel1.Handle, 200, AW_SLIDE or AW_HOR_NEGATIVE or AW_ACTIVATE);
    GDPanelLlamadasHidden := False;
  end;
end;

But the effect is not quite what I wanted, sometimes the image shows a flash, not very aesthetic.

enter image description here

elcharlie
  • 511
  • 8
  • 25
1

you should enable the "Double Buffered" property at the application form's... this should prevent the flashing..

Ricardo
  • 11
  • 1