Recent

Author Topic: Problems with Slide in/out Effect on Form  (Read 4368 times)

dbcbos

  • Newbie
  • Posts: 6
Problems with Slide in/out Effect on Form
« on: February 28, 2012, 10:08:14 pm »
Hi People,

I'm trying too make a simple slide in/out effect after I press a button the form's Height is extended. Press it again and it returns to the original height. Problem is with this code the form top for some reason flickers a few pixels higher and after the animation it returns to its original position. Anyone knows a solution too that? Here is the code behind the button.

procedure TfrmLogin.butOptionsClick(Sender: TObject);
var
  R: TRect;
  h: integer;
begin
     if t then
     begin
        t:=false;
        R:=BoundsRect;
        h:=ClientHeight;
        repeat
           //InflateRect(R,0,-5);
           //BoundsRect := R;
           h := h - 10;
           ClientHeight := h;
         until ClientHeight <= 200;
     end
     else
     begin
       t:=true;
       R:=BoundsRect;
       h:=ClientHeight;
       repeat
          //InflateRect(R,0,5);
          //BoundsRect := R;
          h := h + 10;
          ClientHeight := h;
        until ClientHeight >= 400;
     end;
end;

Explanation:

t is a global boolean variable to check if the button has been pressed before or not.

I also tried to use BoundsRect and InflateRect. Unfortunately the effect then is that it doesn't slide down, but up and down. I only want down.
« Last Edit: February 28, 2012, 10:23:58 pm by dbcbos »

Shebuka

  • Sr. Member
  • ****
  • Posts: 427
Re: Problems with Slide in/out Effect on Form
« Reply #1 on: February 29, 2012, 10:06:41 am »
try with self.Heght += 10

User137

  • Hero Member
  • *****
  • Posts: 1791
    • Nxpascal home
Re: Problems with Slide in/out Effect on Form
« Reply #2 on: February 29, 2012, 11:01:36 am »
Problem is with this code the form top for some reason flickers a few pixels higher and
Weird, i tried your code in new project, on a TButton click. No flickering.
Windows 7, 32bit.

Also, that kind of animation scales with CPU speed. So slow computers have slow animation, and fast computers may do it so fast it's hardly noticable.

dbcbos

  • Newbie
  • Posts: 6
Re: Problems with Slide in/out Effect on Form
« Reply #3 on: February 29, 2012, 11:06:08 am »
Unfortunately that has the same effect. I think it may be a bug.

Anyone tried out my code for themselves and see what effect it had?

Note if I set the Borderstyle form property to bsnone. It works as it should, but I lose the close, minimize and maximize buttons then ofcourse. So not really a solution. Might this also be a carbon issue?

@User137: If you've got an alternative, I'm open for that.

Shebuka

  • Sr. Member
  • ****
  • Posts: 427
Re: Problems with Slide in/out Effect on Form
« Reply #4 on: February 29, 2012, 02:56:20 pm »
tested on Mac OS X 10.6.8, SVN Lazarus, 4.6.0 FPC, same issue.

btw try use timer to make this animation, it will be same speed on all cpu speeds AND your interface will not be blocked during animation execution.
« Last Edit: February 29, 2012, 02:58:24 pm by Shebuka »

 

TinyPortal © 2005-2018