1. Home
  2. Computing & Technology
  3. Delphi Programming

Creating a roll up form (with animation)

By , About.com Guide

Here's a handy piece of code that will create a roll-down and roll-up effect for a form object when a user right-clicks its title bar:

~~~~~~~~~~~~~~~~~~~~~~~~~
type
   TForm1 = class(TForm)
   private
    fOldClientHeight: Integer;
    procedure WMNCRButtonDown(var Msg: TWMNCRButtonDown) ; message WM_NCRBUTTONDOWN;
   public
   end;

var
   Form1: TForm1;

implementation
{$R *.dfm}

procedure TForm1.WMNCRButtonDown(var Msg: TWMNCRButtonDown) ;
var
   h : integer;
begin
   if (Msg.HitTest = HTCAPTION) then
   begin
     if (ClientHeight = 0) then
     begin
       for h := 0 to fOldClientHeight do ClientHeight := h;
       Application.ProcessMessages;
     end
     else
     begin
       fOldClientHeight := ClientHeight;
       for h := fOldClientHeight downto 0 do ClientHeight := h;
       Application.ProcessMessages;
     end;
   end;
end;
~~~~~~~~~~~~~~~~~~~~~~~~~

Delphi tips navigator:
» Using TWebBrowser to preview (and print) Microsoft Word documents
« How to track a user's idle time

Explore Delphi Programming
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Delphi Programming
  4. Coding Delphi Applications
  5. Delphi Tips and Tricks
  6. 2004 Delphi Tips
  7. Creating a roll up Delphi form (with animation)

©2009 About.com, a part of The New York Times Company.

All rights reserved.