1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::WMVScroll(TMessage &Msg)
{
int a = Panel1->Top; // doit etre place imperativement avant la ligne suivante
// afin de conserver la position sur l'ecran
TForm::Dispatch(&Msg); // imperatif sinon le ScrollBar ne defile pas
// (Form1->VertScrollBar->Increment / (Form1->VertScrollBar->Range - Form1->ClientHeight))
// formule permettant de calculer la position en hauteur dans la Form quelque soit
// la position du SCrollBar afin d'avoir le ou les composants toujours a l'ecra
Button1->Top = GetScrollPos(Form1->Handle, SB_VERT) * (Form1->VertScrollBar->Increment / (Form1->VertScrollBar->Range - Form1->ClientHeight));
Label1->Top = GetScrollPos(Form1->Handle, SB_VERT) * (Form1->VertScrollBar->Increment / (Form1->VertScrollBar->Range - Form1->ClientHeight));
Panel1->Top = a + GetScrollPos(Form1->Handle, SB_VERT) * (Form1->VertScrollBar->Increment / (Form1->VertScrollBar->Range - Form1->ClientHeight));
Label1->Caption = Msg.WParamLo;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Panel1MouseDown(TObject *Sender,
TMouseButton Button, TShiftState Shift, int X, int Y)
{
// permet de deplacer le Panel
ReleaseCapture();
SendMessage(Panel1->Handle, WM_SYSCOMMAND, 0xF012, 0);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
// affiche le Panel avec un effet ascenseur
Panel1->BringToFront();
Panel1->Top = 30;
Panel1->Left = 10;
Panel1->Height = 0;
for(int i = 0; i <= 130; i++)
{
Panel1->Height = i;
Panel1->Repaint();
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
// le Button2 est place sur le Panel
// efface le Panel avec un effet ascenseur
for(int i = 130; i >= 0; i--)
{
Panel1->Height = i;
Panel1->Repaint();
}
Panel1->Height = 0;
}
//--------------------------------------------------------------------------- |
Partager