home *** CD-ROM | disk | FTP | other *** search
/ Chip: Shareware for Win 95 / Chip-Shareware-Win95.bin / ostatni / delphi / ruzne / zcd30120.exe / Demo / BarTest1.pas < prev    next >
Pascal/Delphi Source File  |  1997-01-07  |  5KB  |  179 lines

  1.  
  2. Unit Bartest1;
  3.  
  4. {
  5.              A unit for BARTEST.DPR, a testprogram for:
  6.                                                          TzMovePanel
  7.                                                          TzHint
  8.                       The ZieglerCollection one (TM)
  9.                                 Version 1,01
  10.  
  11.            (C) Copyright 1995,96,97 By ZieglerSoft, all rights reserved
  12. }
  13.  
  14. Interface
  15.  
  16. uses
  17.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  18.   Forms, Dialogs, ExtCtrls, Mystd, Buttons, StdCtrls;
  19.  
  20. type
  21.   TForm1 = class(TForm)
  22.     zMovePanel1: TzMovePanel;
  23.     zMovePanel2: TzMovePanel;
  24.     SpeedButton1: TSpeedButton;
  25.     SpeedButton2: TSpeedButton;
  26.     SpeedButton3: TSpeedButton;
  27.     SpeedButton4: TSpeedButton;
  28.     SpeedButton5: TSpeedButton;
  29.     SpeedButton6: TSpeedButton;
  30.     SpeedButton7: TSpeedButton;
  31.     SpeedButton8: TSpeedButton;
  32.     SpeedButton9: TSpeedButton;
  33.     SpeedButton10: TSpeedButton;
  34.     SpeedButton11: TSpeedButton;
  35.     SpeedButton12: TSpeedButton;
  36.     SpeedButton13: TSpeedButton;
  37.     Label1: TLabel;
  38.     zHint1: TzHint;
  39.     procedure Button1Click(Sender: TObject);
  40.     procedure zMovePanel1BeforeUpdate(Sender:TObject;Var X,Y,W,H:Integer);
  41.     procedure FormCreate(Sender: TObject);
  42.     procedure FormResize(Sender: TObject);
  43.     procedure SpeedButton1Click(Sender: TObject);
  44.   private
  45.     ControlA : tPoint;
  46.     Procedure WmVScroll(Var Message:TMessage);Message wm_VScroll;
  47.     Procedure WmHScroll(Var Message:TMessage);Message wm_HScroll;
  48.   end;
  49.  
  50. var
  51.   Form1: TForm1;
  52.  
  53. implementation
  54.  
  55. {$R *.DFM}
  56.  
  57. procedure TForm1.Button1Click(Sender: TObject);
  58. begin
  59.   zMovePanel1.Top:=0;
  60. end;
  61.  
  62. procedure TForm1.zMovePanel1BeforeUpdate(Sender: TObject;VAR X, Y, W,
  63.   H: Integer);
  64. Var
  65.   Pw,Ph : Integer;
  66.   Tal : Integer;
  67.   DoLeft : Boolean;
  68.   DoTop : boolean;
  69.   NLeft,NTop,NHeight,NWidth:Integer;
  70. begin
  71.   Pw:=Form1.ClientWidth;
  72.   Ph:=Form1.ClientHeight;
  73.   DoTop:=False;
  74.   DoLeft:=False;
  75.   With zMovePanel1 Do Begin
  76.     If (X>(PW Div 20)) and (Y<=1) then
  77.       DoTop:=True
  78.     Else If (Y>(PH Div 20)) and (X<=1) then
  79.       DoLeft:=True;
  80.     If Not(DoTop or DoLeft) then
  81.       If (X<2) and (H>PH div 2) then
  82.         DoLeft:=True
  83.       Else If (Y<2) and (W>PW Div 2) then
  84.         DoTop:=True;
  85.     NHeight:=0;
  86.     NWidth:=0;
  87.     If DoLeft then Begin
  88.       NLeft:=0;
  89.       NTop:=0;
  90.       NWidth:=6;
  91.       NHeight:=NHeight+3;
  92.       For Tal:=0 To ControlCount-1 Do
  93.         With Controls[Tal] Do Begin
  94.           If NHeight+Height+3<PH Then Begin
  95.             Left:=3;
  96.             Top:=NHeight;
  97.             NHeight:=NHeight+Height;
  98.             If Width>NWidth-6 then NWidth:=Width+6;
  99.           End Else Left:=0-(Width+2);
  100.         End;
  101.       Nheight:=NHeight+3;
  102.       If Nheight<PH Then NHeight:=PH;
  103.     End Else Begin
  104.       If DoTop Then Begin
  105.         NLeft:=0;
  106.         NTop:=0;
  107.         NHeight:=6;
  108.         Nwidth:=NWidth+3;
  109.         For Tal:=0 to ControlCount-1 Do
  110.           With Controls[Tal] Do Begin
  111.             If NWidth+3+Width<PW Then Begin
  112.               Top:=3;
  113.               Left:=NWidth;
  114.               NWidth:=NWidth+Width;
  115.               If Height>NHeight-6 Then NHeight:=Height+6;
  116.             End Else Top:=0-(Height+2);
  117.           End;
  118.         NWidth:=NWidth+3;
  119.         If NWidth<PW Then NWidth:=PW;
  120.       End Else Begin
  121.         {Set your normal standard here, for a floating toolbar}
  122.         NLeft:=Left;
  123.         NTop:=Top;
  124.         NWidth:=ControlA.X;
  125.         NHeight:=ControlA.Y;
  126.         For Tal:=0 to ControlCount-1 Do Controls[Tal].Top:=3;
  127.         Controls[0].Left:=3;
  128.         Controls[1].Left:=27;
  129.         Controls[2].Left:=51;
  130.         Controls[3].Left:=88;
  131.         Controls[3].Top:=9;
  132.       End;
  133.     End;
  134.   End;
  135.   X:=NLeft;
  136.   Y:=NTop;
  137.   W:=NWidth;
  138.   H:=NHeight;
  139. end;
  140.  
  141. procedure TForm1.FormCreate(Sender: TObject);
  142. begin
  143.   ControlA:=Point(zMovePanel1.Width,zMovePanel1.height);
  144. end;
  145.  
  146. procedure TForm1.FormResize(Sender: TObject);
  147. begin
  148.   zMovePanel1.DoUpdate;
  149. end;
  150.  
  151. procedure TForm1.SpeedButton1Click(Sender: TObject);
  152. begin
  153.   zMovePanel2.Visible:=Not(zMovePanel2.Visible);
  154. end;
  155.  
  156. Procedure TForm1.WMVScroll;
  157. Var
  158.   X,Y : Integer;
  159. Begin
  160.   X:=zMovePanel1.Left;
  161.   Y:=zMovePanel1.Top;
  162.   Inherited;
  163.   zMovePanel1.Left:=X;
  164.   zMovePanel1.Top:=Y;
  165. End;
  166.  
  167. Procedure TForm1.WMHScroll;
  168. Var
  169.   X,Y : Integer;
  170. Begin
  171.   X:=zMovePanel1.Left;
  172.   Y:=zMovePanel1.Top;
  173.   Inherited;
  174.   zMovePanel1.Left:=X;
  175.   zMovePanel1.Top:=Y;
  176. End;
  177.  
  178. end.
  179.