Accueil > > > PANEL DÉPLAÇABLE ET REDIMENSIONNABLE
PANEL DÉPLAÇABLE ET REDIMENSIONNABLE
Information sur la source
Description
Panel déplaçable et redimensionnable. J'ai fait ce composant car il va me servir pour un autre composant. C'est donc un étape mais ça peut intéresser des gens alors je poste le composant.
Source
- mponent of WinEssential project (http://php4php.free.fr/winessential/)
- *
- * This program is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) any later
- * version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE.See the GNU LESSER GENERAL PUBLIC LICENSE for more
- * details.
- *
- * You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE along
- * with this program; if not, write to the Free Software Foundation, Inc., 59
- * Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- *******************************************************************************
- * Version 1.0 by MARTINEAU Emeric (php4php.free.fr) - 20/01/2008
- ******************************************************************************}
-
- interface
-
- uses
- Windows, Messages, SysUtils, Classes, Controls, ExtCtrls, Forms;
-
- type
- TMovableAndResisablePanel = class(TPanel)
- private
- { Déclarations privées }
- protected
- { Déclarations protégées }
- { Taille en pixel pour faire apparaitre le curseur de redimensionnement oblique }
- FSizeBorderOfObliqueArrow : Integer ;
- { Indique si la hauteur peut être redimenssionnée }
- FHeightResizable : Boolean ;
- { Indique si la largeur peur être redimensionnée }
- FWidthResizable : Boolean ;
- { Mémorise le curseur d'origine }
- FOriginalCursor : TCursor ;
- { Indique si le composant est déplaçable }
- FMovable : Boolean ;
- { Indique le hauteur minimum }
- FMinimumHeight : Integer ;
- { Indique le hauteur minimum }
- FMinimumWidth : Integer ;
- { Indique où est le curseur }
- Nord, Sud, Est, West : boolean ;
- NordEst, NordWest, SudEst, SudWest : boolean ;
- procedure GetCursorPosition(X, Y : Integer; var Nord, Sud, Est, West, NordEst, NordWest, SudEst, SudWest : boolean) ;
- procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
- procedure SetDefaultCursor(NewCursor : TCursor) ;
- procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override ;
- procedure SetMovable(value : boolean) ;
- public
- constructor Create(Owner:TComponent); override;
- destructor Destroy; override;
- property DockManager;
- published
- property Align;
- property Alignment;
- property Anchors;
- property AutoSize;
- property BevelInner;
- property BevelOuter;
- property BevelWidth;
- property BiDiMode;
- property BorderWidth;
- property BorderStyle;
- property Caption;
- property Color;
- property Constraints;
- property Ctl3D;
- property UseDockManager default True;
- property DockSite;
- property DragCursor;
- property DragKind;
- property DragMode;
- property Enabled;
- property FullRepaint;
- property Font;
- property Locked;
- property ParentBiDiMode;
- property ParentColor;
- property ParentCtl3D;
- property ParentFont;
- property ParentShowHint;
- property PopupMenu;
- property ShowHint;
- property TabOrder;
- property TabStop;
- property Visible;
- property OnCanResize;
- property OnClick;
- property OnConstrainedResize;
- property OnContextPopup;
- property OnDockDrop;
- property OnDockOver;
- property OnDblClick;
- property OnDragDrop;
- property OnDragOver;
- property OnEndDock;
- property OnEndDrag;
- property OnEnter;
- property OnExit;
- property OnGetSiteInfo;
- property OnMouseDown;
- property OnMouseMove;
- property OnMouseUp;
- property OnResize;
- property OnStartDock;
- property OnStartDrag;
- property OnUnDock;
- //
- property SizeBorderOfObliqueArrow : Integer read FSizeBorderOfObliqueArrow write FSizeBorderOfObliqueArrow default 5 ;
- property HeightResizable : Boolean read FHeightResizable write FHeightResizable default true ;
- property WidthResizable : Boolean read FWidthResizable write FWidthResizable default true ;
- property Cursor : TCursor read FOriginalCursor write SetDefaultCursor default crDefault ;
- property Movable : Boolean read FMovable write SetMovable default true ;
- property MinimumHeight : Integer read FMinimumHeight write FMinimumHeight default 2 ;
- property MinimumWidth : Integer read FMinimumWidth write FMinimumWidth default 2 ;
- end;
-
- procedure Register;
-
- implementation
-
- {*******************************************************************************
- * Constructeur
- ******************************************************************************}
- constructor TMovableAndResisablePanel.Create(Owner:TComponent);
- begin
- inherited ;
-
- FSizeBorderOfObliqueArrow := 5 ;
- FHeightResizable := True ;
- FWidthResizable := True ;
-
- FOriginalCursor := crDefault ;
-
- FMinimumWidth := 2 ;
- FMinimumHeight := 2 ;
-
- FMovable := True ;
- end ;
-
- {*******************************************************************************
- * Destructeur
- ******************************************************************************}
- destructor TMovableAndResisablePanel.Destroy;
- begin
- // instruction avant
- inherited;
- end;
-
- {*******************************************************************************
- * Définit le curseur par défaut
- ******************************************************************************}
- procedure TMovableAndResisablePanel.SetDefaultCursor(NewCursor : TCursor) ;
- begin
- FOriginalCursor := NewCursor ;
- inherited Cursor := NewCursor ;
- end ;
-
- {*******************************************************************************
- * procedure qui indique la position du cursor sur la bordure
- ******************************************************************************}
- procedure TMovableAndResisablePanel.GetCursorPosition(X, Y : Integer; var Nord, Sud, Est, West, NordEst, NordWest, SudEst, SudWest : boolean) ;
- begin
- Nord := (Y = 0) ;
- Sud := (Y = (Self.ClientHeight - 1));
- Est := (X = (Self.ClientWidth - 1)) ;
- West := (X = 0) ;
- NordEst := (Nord and (X > (Self.ClientWidth - 1 - SizeBorderOfObliqueArrow)) or (Est and (Y < SizeBorderOfObliqueArrow))) ;
- NordWest := (Nord and (X < SizeBorderOfObliqueArrow)) or (West and (Y < SizeBorderOfObliqueArrow)) ;
- SudEst := (Est and ((Y > (Self.ClientHeight - 1 - SizeBorderOfObliqueArrow)))) or
- (Sud and (X > (Self.ClientWidth - 1 - SizeBorderOfObliqueArrow))) ;
-
- SudWest := (West and (Y > (Self.ClientHeight - 1 - SizeBorderOfObliqueArrow))) or
- (Sud and (X < SizeBorderOfObliqueArrow)) ;
- end ;
-
- {*******************************************************************************
- * Définit si le control est déplaçable
- ******************************************************************************}
- procedure TMovableAndResisablePanel.SetMovable(value : boolean) ;
- begin
- FMovable := Value ;
-
- if Value
- then
- Self.Cursor := crSizeAll
- else
- Self.Cursor := FOriginalCursor ;
- end ;
-
- {*******************************************************************************
- * Procédure appelé lorsqu'on passe la souris sur le contrôle.
- * Se charge d'afficher les curseurs qui vont bien.
- ******************************************************************************}
- procedure TMovableAndResisablePanel.MouseMove(Shift: TShiftState; X, Y: Integer);
- var
- P : Tpoint ;
- NewTop : Integer ;
- NewHeight : Integer ;
- NewLeft : Integer ;
- NewWidth : Integer ;
- begin
- GetCursorPos(P) ;
-
- inherited ;
-
- { On rafraicit la position du curseur que si on ne clique pas car sinon, si
- on clique et qu'on déplace on va être hors du panel et donc toutes les
- variable de direction seront à false }
- if not (ssLeft in Shift)
- then
- GetCursorPosition(X, Y, Nord, Sud, Est, West, NordEst, NordWest, SudEst, SudWest) ;
-
- { Désactive le curseur si on ne peut pas redimensionner la hauteur }
- if not FHeightResizable
- then begin
- Nord := False ;
- Sud := False ;
- end ;
-
- { Désactive le curseur si on ne peut pas redimensionner la largeur }
- if not FWidthResizable
- then begin
- Est := False ;
- West := False ;
- end ;
-
- { Désactive les cuseurs obliques si on ne peut pas redimenssionner en hauteur }
- if not (FHeightResizable and FWidthResizable) and (NordEst or NordWest or SudEst or SudWest)
- then begin
- NordEst := False ;
- NordWest := False ;
- SudEst := False ;
- SudWest := False ;
- end ;
-
- { Désactive les curseurs pour l'affichage des curseurs obliques }
- if NordEst or NordWest
- then begin
- Nord := False ;
- end ;
-
- if SudEst or SudWest
- then begin
- Sud := False ;
- end ;
-
- if NordEst or SudEst
- then begin
- Est := False ;
- end ;
-
- if SudWest or NordWest
- then begin
- West := False ;
- end ;
-
- NewTop := Self.Top ;
- NewHeight := Self.Height ;
- NewLeft := Self.Left ;
- NewWidth := Self.Width ;
-
- { -1 car le premier point est 0 et non 1 }
- if (Nord or Sud)
- then begin
- inherited Cursor := crSizeNS ;
-
- if ssLeft in Shift
- then begin
- if Nord
- then begin
- NewTop := Self.Top - (Self.ClientOrigin.Y - P.Y) ;
-
- if NewTop >= 0
- then
- NewHeight := Self.Top - NewTop + Self.Height ;
- end
- else begin
- NewHeight := P.Y - Self.ClientOrigin.Y ;
- end ;
- end ;
- end
- else if (Est or West)
- then begin
- inherited Cursor := crSizeWE ;
-
- if ssLeft in Shift
- then begin
- if West
- then begin
- NewLeft := Self.Left - (Self.ClientOrigin.X - P.X) ;
-
- if P.X > (Parent.Left + ((Parent.Width - Parent.ClientWidth) div 2))
- then
- NewWidth := Self.Width - (P.X - Self.ClientOrigin.X) ;
- end
- else begin
- NewWidth := P.X - Self.ClientOrigin.X ;
- end ;
- end ;
- end
- else if NordEst or SudWest
- then begin
- inherited Cursor := crSizeNESW ;
-
- if ssLeft in Shift
- then begin
- if NordEst
- then begin
- NewTop := Self.Top - (Self.ClientOrigin.Y - P.Y) ;
-
- if NewTop >= 0
- then
- NewHeight := Self.Top - NewTop + Self.Height ;
-
- NewWidth := P.X - Self.ClientOrigin.X ;
- end
- else begin
- NewHeight := P.Y - Self.ClientOrigin.Y ;
-
- NewLeft := Self.Left - (Self.ClientOrigin.X - P.X) ;
-
- if P.X > (Parent.Left + ((Parent.Width - Parent.ClientWidth) div 2))
- then
- NewWidth := Self.Width - (P.X - Self.ClientOrigin.X) ;
- end;
- end ;
- end
- else if NordWest or SudEst
- then begin
- inherited Cursor := crSizeNWSE ;
-
- if ssLeft in Shift
- then begin
- if NordWest
- then begin
- NewTop := Self.Top - (Self.ClientOrigin.Y - P.Y) ;
-
- if NewTop >= 0
- then
- NewHeight := Self.Top - NewTop + Self.Height ;
-
- NewLeft := Self.Left - (Self.ClientOrigin.X - P.X) ;
-
- if P.X > (Parent.Left + ((Parent.Width - Parent.ClientWidth) div 2))
- then
- NewWidth := Self.Width - (P.X - Self.ClientOrigin.X) ;
- end
- else begin
- NewHeight := P.Y - Self.ClientOrigin.Y ;
- NewWidth := P.X - Self.ClientOrigin.X ;
- end ;
- end ;
- end
- else begin
- if FMovable
- then
- Cursor := crSizeAll
- else
- inherited Cursor := FOriginalCursor ;
- end ;
-
- if (NewTop >= 0) and (NewTop <= Self.Top + Self.Height) and (NewTop < Self.Top + Self.Height - FMinimumHeight)
- then
- Self.Top := NewTop ;
-
- if Assigned(Parent)
- then
- if (Parent.ClientHeight >= NewHeight + Self.Top) and (NewHeight >= FMinimumHeight)
- then
- Self.Height := NewHeight ;
-
- if Assigned(Parent)
- then
- if (NewLeft > 0) and (NewLeft + Self.Width < Parent.ClientWidth) and (NewLeft < (Self.Left + Self.Width - FMinimumWidth))
- then
- Self.Left := NewLeft ;
-
- if Assigned(Parent)
- then
- if (NewWidth <= Parent.ClientWidth - Self.Left) and (NewWidth >= FMinimumWidth)
- then
- Self.Width := NewWidth ;
- end;
-
- {*******************************************************************************
- * Procédure appelé lorsqu'on clique sur le contrôle.
- ******************************************************************************}
- procedure TMovableAndResisablePanel.MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- var
- Action: Integer;
- Msg: TMessage;
- P : TPoint ;
- begin
- { Si on est sur la bordure et qu'on clique, cette fonction est appelée et
- le controle est déplacé alors qu'on veut qu'il soit redimensionné }
- if not (Nord or Sud or Est or West or NordEst or NordWest or SudEst or SudWest)
- then begin
- inherited;
-
- if FMovable
- then begin
- Action := HTCAPTION;
- Msg.Msg := WM_NCLBUTTONDOWN;
- Msg.WParam := Action;
- SetCaptureControl(nil);
-
- SendMessage(Self.Handle, Msg.Msg, Msg.wParam, Msg.lParam) ;
- end ;
- end ;
- end;
-
- procedure Register;
- begin
- RegisterComponents('WinEssential', [TMovableAndResisablePanel]);
- end;
-
- end.
mponent of WinEssential project (http://php4php.free.fr/winessential/)
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE.See the GNU LESSER GENERAL PUBLIC LICENSE for more
* details.
*
* You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE along
* with this program; if not, write to the Free Software Foundation, Inc., 59
* Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*
*******************************************************************************
* Version 1.0 by MARTINEAU Emeric (php4php.free.fr) - 20/01/2008
******************************************************************************}
interface
uses
Windows, Messages, SysUtils, Classes, Controls, ExtCtrls, Forms;
type
TMovableAndResisablePanel = class(TPanel)
private
{ Déclarations privées }
protected
{ Déclarations protégées }
{ Taille en pixel pour faire apparaitre le curseur de redimensionnement oblique }
FSizeBorderOfObliqueArrow : Integer ;
{ Indique si la hauteur peut être redimenssionnée }
FHeightResizable : Boolean ;
{ Indique si la largeur peur être redimensionnée }
FWidthResizable : Boolean ;
{ Mémorise le curseur d'origine }
FOriginalCursor : TCursor ;
{ Indique si le composant est déplaçable }
FMovable : Boolean ;
{ Indique le hauteur minimum }
FMinimumHeight : Integer ;
{ Indique le hauteur minimum }
FMinimumWidth : Integer ;
{ Indique où est le curseur }
Nord, Sud, Est, West : boolean ;
NordEst, NordWest, SudEst, SudWest : boolean ;
procedure GetCursorPosition(X, Y : Integer; var Nord, Sud, Est, West, NordEst, NordWest, SudEst, SudWest : boolean) ;
procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
procedure SetDefaultCursor(NewCursor : TCursor) ;
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override ;
procedure SetMovable(value : boolean) ;
public
constructor Create(Owner:TComponent); override;
destructor Destroy; override;
property DockManager;
published
property Align;
property Alignment;
property Anchors;
property AutoSize;
property BevelInner;
property BevelOuter;
property BevelWidth;
property BiDiMode;
property BorderWidth;
property BorderStyle;
property Caption;
property Color;
property Constraints;
property Ctl3D;
property UseDockManager default True;
property DockSite;
property DragCursor;
property DragKind;
property DragMode;
property Enabled;
property FullRepaint;
property Font;
property Locked;
property ParentBiDiMode;
property ParentColor;
property ParentCtl3D;
property ParentFont;
property ParentShowHint;
property PopupMenu;
property ShowHint;
property TabOrder;
property TabStop;
property Visible;
property OnCanResize;
property OnClick;
property OnConstrainedResize;
property OnContextPopup;
property OnDockDrop;
property OnDockOver;
property OnDblClick;
property OnDragDrop;
property OnDragOver;
property OnEndDock;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnGetSiteInfo;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
property OnResize;
property OnStartDock;
property OnStartDrag;
property OnUnDock;
//
property SizeBorderOfObliqueArrow : Integer read FSizeBorderOfObliqueArrow write FSizeBorderOfObliqueArrow default 5 ;
property HeightResizable : Boolean read FHeightResizable write FHeightResizable default true ;
property WidthResizable : Boolean read FWidthResizable write FWidthResizable default true ;
property Cursor : TCursor read FOriginalCursor write SetDefaultCursor default crDefault ;
property Movable : Boolean read FMovable write SetMovable default true ;
property MinimumHeight : Integer read FMinimumHeight write FMinimumHeight default 2 ;
property MinimumWidth : Integer read FMinimumWidth write FMinimumWidth default 2 ;
end;
procedure Register;
implementation
{*******************************************************************************
* Constructeur
******************************************************************************}
constructor TMovableAndResisablePanel.Create(Owner:TComponent);
begin
inherited ;
FSizeBorderOfObliqueArrow := 5 ;
FHeightResizable := True ;
FWidthResizable := True ;
FOriginalCursor := crDefault ;
FMinimumWidth := 2 ;
FMinimumHeight := 2 ;
FMovable := True ;
end ;
{*******************************************************************************
* Destructeur
******************************************************************************}
destructor TMovableAndResisablePanel.Destroy;
begin
// instruction avant
inherited;
end;
{*******************************************************************************
* Définit le curseur par défaut
******************************************************************************}
procedure TMovableAndResisablePanel.SetDefaultCursor(NewCursor : TCursor) ;
begin
FOriginalCursor := NewCursor ;
inherited Cursor := NewCursor ;
end ;
{*******************************************************************************
* procedure qui indique la position du cursor sur la bordure
******************************************************************************}
procedure TMovableAndResisablePanel.GetCursorPosition(X, Y : Integer; var Nord, Sud, Est, West, NordEst, NordWest, SudEst, SudWest : boolean) ;
begin
Nord := (Y = 0) ;
Sud := (Y = (Self.ClientHeight - 1));
Est := (X = (Self.ClientWidth - 1)) ;
West := (X = 0) ;
NordEst := (Nord and (X > (Self.ClientWidth - 1 - SizeBorderOfObliqueArrow)) or (Est and (Y < SizeBorderOfObliqueArrow))) ;
NordWest := (Nord and (X < SizeBorderOfObliqueArrow)) or (West and (Y < SizeBorderOfObliqueArrow)) ;
SudEst := (Est and ((Y > (Self.ClientHeight - 1 - SizeBorderOfObliqueArrow)))) or
(Sud and (X > (Self.ClientWidth - 1 - SizeBorderOfObliqueArrow))) ;
SudWest := (West and (Y > (Self.ClientHeight - 1 - SizeBorderOfObliqueArrow))) or
(Sud and (X < SizeBorderOfObliqueArrow)) ;
end ;
{*******************************************************************************
* Définit si le control est déplaçable
******************************************************************************}
procedure TMovableAndResisablePanel.SetMovable(value : boolean) ;
begin
FMovable := Value ;
if Value
then
Self.Cursor := crSizeAll
else
Self.Cursor := FOriginalCursor ;
end ;
{*******************************************************************************
* Procédure appelé lorsqu'on passe la souris sur le contrôle.
* Se charge d'afficher les curseurs qui vont bien.
******************************************************************************}
procedure TMovableAndResisablePanel.MouseMove(Shift: TShiftState; X, Y: Integer);
var
P : Tpoint ;
NewTop : Integer ;
NewHeight : Integer ;
NewLeft : Integer ;
NewWidth : Integer ;
begin
GetCursorPos(P) ;
inherited ;
{ On rafraicit la position du curseur que si on ne clique pas car sinon, si
on clique et qu'on déplace on va être hors du panel et donc toutes les
variable de direction seront à false }
if not (ssLeft in Shift)
then
GetCursorPosition(X, Y, Nord, Sud, Est, West, NordEst, NordWest, SudEst, SudWest) ;
{ Désactive le curseur si on ne peut pas redimensionner la hauteur }
if not FHeightResizable
then begin
Nord := False ;
Sud := False ;
end ;
{ Désactive le curseur si on ne peut pas redimensionner la largeur }
if not FWidthResizable
then begin
Est := False ;
West := False ;
end ;
{ Désactive les cuseurs obliques si on ne peut pas redimenssionner en hauteur }
if not (FHeightResizable and FWidthResizable) and (NordEst or NordWest or SudEst or SudWest)
then begin
NordEst := False ;
NordWest := False ;
SudEst := False ;
SudWest := False ;
end ;
{ Désactive les curseurs pour l'affichage des curseurs obliques }
if NordEst or NordWest
then begin
Nord := False ;
end ;
if SudEst or SudWest
then begin
Sud := False ;
end ;
if NordEst or SudEst
then begin
Est := False ;
end ;
if SudWest or NordWest
then begin
West := False ;
end ;
NewTop := Self.Top ;
NewHeight := Self.Height ;
NewLeft := Self.Left ;
NewWidth := Self.Width ;
{ -1 car le premier point est 0 et non 1 }
if (Nord or Sud)
then begin
inherited Cursor := crSizeNS ;
if ssLeft in Shift
then begin
if Nord
then begin
NewTop := Self.Top - (Self.ClientOrigin.Y - P.Y) ;
if NewTop >= 0
then
NewHeight := Self.Top - NewTop + Self.Height ;
end
else begin
NewHeight := P.Y - Self.ClientOrigin.Y ;
end ;
end ;
end
else if (Est or West)
then begin
inherited Cursor := crSizeWE ;
if ssLeft in Shift
then begin
if West
then begin
NewLeft := Self.Left - (Self.ClientOrigin.X - P.X) ;
if P.X > (Parent.Left + ((Parent.Width - Parent.ClientWidth) div 2))
then
NewWidth := Self.Width - (P.X - Self.ClientOrigin.X) ;
end
else begin
NewWidth := P.X - Self.ClientOrigin.X ;
end ;
end ;
end
else if NordEst or SudWest
then begin
inherited Cursor := crSizeNESW ;
if ssLeft in Shift
then begin
if NordEst
then begin
NewTop := Self.Top - (Self.ClientOrigin.Y - P.Y) ;
if NewTop >= 0
then
NewHeight := Self.Top - NewTop + Self.Height ;
NewWidth := P.X - Self.ClientOrigin.X ;
end
else begin
NewHeight := P.Y - Self.ClientOrigin.Y ;
NewLeft := Self.Left - (Self.ClientOrigin.X - P.X) ;
if P.X > (Parent.Left + ((Parent.Width - Parent.ClientWidth) div 2))
then
NewWidth := Self.Width - (P.X - Self.ClientOrigin.X) ;
end;
end ;
end
else if NordWest or SudEst
then begin
inherited Cursor := crSizeNWSE ;
if ssLeft in Shift
then begin
if NordWest
then begin
NewTop := Self.Top - (Self.ClientOrigin.Y - P.Y) ;
if NewTop >= 0
then
NewHeight := Self.Top - NewTop + Self.Height ;
NewLeft := Self.Left - (Self.ClientOrigin.X - P.X) ;
if P.X > (Parent.Left + ((Parent.Width - Parent.ClientWidth) div 2))
then
NewWidth := Self.Width - (P.X - Self.ClientOrigin.X) ;
end
else begin
NewHeight := P.Y - Self.ClientOrigin.Y ;
NewWidth := P.X - Self.ClientOrigin.X ;
end ;
end ;
end
else begin
if FMovable
then
Cursor := crSizeAll
else
inherited Cursor := FOriginalCursor ;
end ;
if (NewTop >= 0) and (NewTop <= Self.Top + Self.Height) and (NewTop < Self.Top + Self.Height - FMinimumHeight)
then
Self.Top := NewTop ;
if Assigned(Parent)
then
if (Parent.ClientHeight >= NewHeight + Self.Top) and (NewHeight >= FMinimumHeight)
then
Self.Height := NewHeight ;
if Assigned(Parent)
then
if (NewLeft > 0) and (NewLeft + Self.Width < Parent.ClientWidth) and (NewLeft < (Self.Left + Self.Width - FMinimumWidth))
then
Self.Left := NewLeft ;
if Assigned(Parent)
then
if (NewWidth <= Parent.ClientWidth - Self.Left) and (NewWidth >= FMinimumWidth)
then
Self.Width := NewWidth ;
end;
{*******************************************************************************
* Procédure appelé lorsqu'on clique sur le contrôle.
******************************************************************************}
procedure TMovableAndResisablePanel.MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
Action: Integer;
Msg: TMessage;
P : TPoint ;
begin
{ Si on est sur la bordure et qu'on clique, cette fonction est appelée et
le controle est déplacé alors qu'on veut qu'il soit redimensionné }
if not (Nord or Sud or Est or West or NordEst or NordWest or SudEst or SudWest)
then begin
inherited;
if FMovable
then begin
Action := HTCAPTION;
Msg.Msg := WM_NCLBUTTONDOWN;
Msg.WParam := Action;
SetCaptureControl(nil);
SendMessage(Self.Handle, Msg.Msg, Msg.wParam, Msg.lParam) ;
end ;
end ;
end;
procedure Register;
begin
RegisterComponents('WinEssential', [TMovableAndResisablePanel]);
end;
end.
Sources du même auteur
Sources de la même categorie
Commentaires et avis
Discussions en rapport avec ce code source dans le forum
StatusBar et largeur Panel [ par apz ]
Salut,Comment, dans un StatusBar, definir la largeur des Panels selon leurs continue ?par exemple pour affichier le jour de la date, lundi n'a pas la
Création dynamiqe [ par bougste ]
Voilà mon problème..je voudrais créer dynamiquement une image pour la mettre sur différent panel (pas en même temps justement) sur celui qui est actif
Problemes d'affichage dans une DBCtrlgrid [ par balstrom ]
Bonjour j' ai un gros problemme d'affichage avec ma DBCtrlgrid: je vous explique:dans le panel de ma DBCtrlgrid je met une DBCombobox que je rempli av
Form non déplaçable [ par Bruto ]
Salut,j'aurais voulu savoir s'il y avait moyen de rendre une form non bougeable comme en VB ? bien sûr il y a la propriété BorderStyle à None qui fais
Générer des cliques ou avoir acces a ... [ par stage ]
Salut ! Mon probleme est le suivant :jai plusieurs panel ( qui se trouve a être un composant que jme suis créé ) sur ma form1 qui sont créés dynamique
statusbar comment recuperer des infos? [ par noyax ]
salut, j'aimerai recuperer le texte d'un panel de la statusbar d'une application en execution. Je recupere le handle facilement, puis via ce handle et
Personnalisation de la barre de titre [ par holomina ]
Bonjour à tous!Faisant mes premiers pas en delphi, j'aimerais personnaliser la barre de titre de mon application (notamment la couleur). Pour cela, j'
panel en canvas? [ par lupoo ]
salut à tous,g un prog qui dessine une ligne elastique sur la Form, avec deux cliques de la souris, mais lorsque je rajoute un Panel, les cliques ne f
Panel qui ne change pas de couleur [ par etrix ]
Salut !voilà je tourne sous delphi 7 et lorsque je met un panel sur ma form et que je personnalise la couleur, elle ne change pas :/ j'ai déja eu souv
Focus d'un bouton quand MouseDown [ par Caribensila ]
Slt et merci à tous! Je suis novice en Delphi et j'ai un petit problème qui me donne des boutons :D J'ai fouillé le site en vain... Voilà ce que je vo
|
Derniers Blogs
UNE JOLIE-HORLOGE ET PAS QU'UN PEU !UNE JOLIE-HORLOGE ET PAS QU'UN PEU ! par neodante
Pour les possesseurs d'iPhone, ça y est Bijin Tokei - qui se traduit littéralement en Français par " Jolie Horloge " - est arrivé et GRATUITEMENT s'il vous plaît ! Après la version Tokyo, Hokkaido, night club, racing, Gal, "pour les mademoiselles'", . voi...
Cliquez pour lire la suite de l'article par neodante TECHDAYS PARIS 2010 : CONNECTEZ VOS DONNéES à SHAREPOINT 2010 AVEC LES BUSINESS CONNECTIVITY SERVICESTECHDAYS PARIS 2010 : CONNECTEZ VOS DONNéES à SHAREPOINT 2010 AVEC LES BUSINESS CONNECTIVITY SERVICES par ROMELARD Fabrice
Animé par: Gaetan Bouveret et Julien Chomarat Business Connectivity Services (BCS) est dans SharePoint 2010 la version 2 de Business Data Catalog (BDC dans SharePoint 2007). Il s'agit de la solution permettant de visualiser des données provenan...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice [DIVERS] SUIVRE VOS SéRIES PRéFéRéS SUR LA TOILE[DIVERS] SUIVRE VOS SéRIES PRéFéRéS SUR LA TOILE par orion
Comme de nombreux geek, je suis un grand amateur de série TV et je rate régulièrement des épisodes de mes séries préférés. Une solution s'offre à vous avec ce merveilleux site : Tv Gorge - www.tvgorge.com Moteur de recherche à l'appui, vous pouvez ...
Cliquez pour lire la suite de l'article par orion TECHDAYS PARIS 2010 : LA BI DANS SHAREPOINT 2010TECHDAYS PARIS 2010 : LA BI DANS SHAREPOINT 2010 par ROMELARD Fabrice
Animé par: Vincent Bellet et Baptiste Giraudier La BI dans SharePoint 2010, Les nouveaux services d'application dans SP2010 et SQL Server Reporting services 2008 R2. La BI dans SharePoint est généralisée pour tous afin de permettre à tous les coll...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice
Logiciels
DB-MAIN (9.1.0)DB-MAIN (9.1.0)DB-MAIN is a data-modeling and data-architecture tool. It is designed to help developers and anal... Cliquez pour télécharger DB-MAIN Xilisoft DPG Convertisseur (5.1.37.0120)XILISOFT DPG CONVERTISSEUR (5.1.37.0120)Xilisoft DPG Convertisseur offre aux fans de Nintendo DS une bonne solution leur permettant de dé... Cliquez pour télécharger Xilisoft DPG Convertisseur GraphicsGale (2.01.01)GRAPHICSGALE (2.01.01)GraphicsGale est un logiciel de PixelArt avec de nombreuse fonctionnalités permettant de réalisé ... Cliquez pour télécharger GraphicsGale Architecte 3D (Platinum 2010)ARCHITECTE 3D (PLATINUM 2010)Architecte 3D Platinium vous permet de concevoir facilement les plans votre future maison, de l'é... Cliquez pour télécharger Architecte 3D TeamViewer 5 (TeamViewer 5)TEAMVIEWER 5 (TEAMVIEWER 5)Dépanner un ami,expliquer une manipulation devient un jeu d'enfant.
Prise en main d'un autre ord... Cliquez pour télécharger TeamViewer 5
|