Board index » delphi » Controls behaving like in Delphi design time (move and sizable)

Controls behaving like in Delphi design time (move and sizable)

Hello!

I want to extend existing controls that they behave like in Delphi design
time, so that they can be moved and resized by mouse.

How can I do that?

Perhaps you've additionaly some code to make components transparent.

Thanks for any help,

Matthias.

 

Re:Controls behaving like in Delphi design time (move and sizable)


Try this :-

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs,
  StdCtrls;

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    procedure Edit1MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure Edit1MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Edit1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
  Var
  Msg : Integer ;
  begin

  Msg := 0 ;

  If Y < 5 Then
     Msg := HTCAPTION ;

  If X > Edit1.Width - 10 Then
     Msg := HTRIGHT ;

  If X < 10 Then
     Msg := HTLEFT ;

  If Y > Edit1.Height - 10 Then
     Msg := HTBOTTOM ;

  If Msg <> 0 Then
     Begin
     ReleaseCapture ;
     SendMessage( Edit1.Handle, WM_NCLBUTTONDOWN, Msg, 0 ) ;
  End;

end;

procedure TForm1.Edit1MouseMove(Sender: TObject; Shift: TShiftState;
X,
  Y: Integer);
  Var
  C : TCursor ;
  begin

  C := crDefault ;
  If Y < 5 Then
     C := crDrag ;

  If Y > ( TEdit( Sender ).Height - 10 ) Then
     C := crSizeNS ;

  If (X < 10) Or ( X > Edit1.Width - 10 ) Then
     C := crSizeWE ;

  Edit1.Cursor := C;

end;

end.

On Sat, 23 Jun 2001 12:14:14 +0200, "Matthias Meinecke"

Quote
<matth...@netmediasystems.de> wrote:
>Hello!

>I want to extend existing controls that they behave like in Delphi design
>time, so that they can be moved and resized by mouse.

>How can I do that?

>Perhaps you've additionaly some code to make components transparent.

>Thanks for any help,

>Matthias.

Re:Controls behaving like in Delphi design time (move and sizable)


Good grief!
I was just going to say "make them dockable"!
Quote
J French wrote in message <3b3490a6.17167...@news.u-net.com>...
>Try this :-

>unit Unit1;

>interface

>uses
>  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
>Dialogs,
>  StdCtrls;

>type
>  TForm1 = class(TForm)
>    Edit1: TEdit;
>    procedure Edit1MouseDown(Sender: TObject; Button: TMouseButton;
>      Shift: TShiftState; X, Y: Integer);
>    procedure Edit1MouseMove(Sender: TObject; Shift: TShiftState; X,
>      Y: Integer);
>  private
>    { Private declarations }
>  public
>    { Public declarations }
>  end;

>var
>  Form1: TForm1;

>implementation

>{$R *.DFM}

>procedure TForm1.Edit1MouseDown(Sender: TObject; Button: TMouseButton;
>  Shift: TShiftState; X, Y: Integer);
>  Var
>  Msg : Integer ;
>  begin

>  Msg := 0 ;

>  If Y < 5 Then
>     Msg := HTCAPTION ;

>  If X > Edit1.Width - 10 Then
>     Msg := HTRIGHT ;

>  If X < 10 Then
>     Msg := HTLEFT ;

>  If Y > Edit1.Height - 10 Then
>     Msg := HTBOTTOM ;

>  If Msg <> 0 Then
>     Begin
>     ReleaseCapture ;
>     SendMessage( Edit1.Handle, WM_NCLBUTTONDOWN, Msg, 0 ) ;
>  End;

>end;

>procedure TForm1.Edit1MouseMove(Sender: TObject; Shift: TShiftState;
>X,
>  Y: Integer);
>  Var
>  C : TCursor ;
>  begin

>  C := crDefault ;
>  If Y < 5 Then
>     C := crDrag ;

>  If Y > ( TEdit( Sender ).Height - 10 ) Then
>     C := crSizeNS ;

>  If (X < 10) Or ( X > Edit1.Width - 10 ) Then
>     C := crSizeWE ;

>  Edit1.Cursor := C;

>end;

>end.

>On Sat, 23 Jun 2001 12:14:14 +0200, "Matthias Meinecke"
><matth...@netmediasystems.de> wrote:

>>Hello!

>>I want to extend existing controls that they behave like in Delphi design
>>time, so that they can be moved and resized by mouse.

>>How can I do that?

>>Perhaps you've additionaly some code to make components transparent.

>>Thanks for any help,

>>Matthias.

Re:Controls behaving like in Delphi design time (move and sizable)


On Mon, 25 Jun 2001 23:36:36 +1000, "Tristan" <moonsh...@apex.net.au>
wrote:

Quote
>Good grief!
>I was just going to say "make them dockable"!

Eh ?  But that would make them 'snap to fit'
Actually I have rather avoided 'docking' it narks me in the IDE.
Quote

>J French wrote in message <3b3490a6.17167...@news.u-net.com>...
>>Try this :-

>>unit Unit1;

>>interface

>>uses
>>  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
>>Dialogs,
>>  StdCtrls;

>>type
>>  TForm1 = class(TForm)
>>    Edit1: TEdit;
>>    procedure Edit1MouseDown(Sender: TObject; Button: TMouseButton;
>>      Shift: TShiftState; X, Y: Integer);
>>    procedure Edit1MouseMove(Sender: TObject; Shift: TShiftState; X,
>>      Y: Integer);
>>  private
>>    { Private declarations }
>>  public
>>    { Public declarations }
>>  end;

>>var
>>  Form1: TForm1;

>>implementation

>>{$R *.DFM}

>>procedure TForm1.Edit1MouseDown(Sender: TObject; Button: TMouseButton;
>>  Shift: TShiftState; X, Y: Integer);
>>  Var
>>  Msg : Integer ;
>>  begin

>>  Msg := 0 ;

>>  If Y < 5 Then
>>     Msg := HTCAPTION ;

>>  If X > Edit1.Width - 10 Then
>>     Msg := HTRIGHT ;

>>  If X < 10 Then
>>     Msg := HTLEFT ;

>>  If Y > Edit1.Height - 10 Then
>>     Msg := HTBOTTOM ;

>>  If Msg <> 0 Then
>>     Begin
>>     ReleaseCapture ;
>>     SendMessage( Edit1.Handle, WM_NCLBUTTONDOWN, Msg, 0 ) ;
>>  End;

>>end;

>>procedure TForm1.Edit1MouseMove(Sender: TObject; Shift: TShiftState;
>>X,
>>  Y: Integer);
>>  Var
>>  C : TCursor ;
>>  begin

>>  C := crDefault ;
>>  If Y < 5 Then
>>     C := crDrag ;

>>  If Y > ( TEdit( Sender ).Height - 10 ) Then
>>     C := crSizeNS ;

>>  If (X < 10) Or ( X > Edit1.Width - 10 ) Then
>>     C := crSizeWE ;

>>  Edit1.Cursor := C;

>>end;

>>end.

>>On Sat, 23 Jun 2001 12:14:14 +0200, "Matthias Meinecke"
>><matth...@netmediasystems.de> wrote:

>>>Hello!

>>>I want to extend existing controls that they behave like in Delphi design
>>>time, so that they can be moved and resized by mouse.

>>>How can I do that?

>>>Perhaps you've additionaly some code to make components transparent.

>>>Thanks for any help,

>>>Matthias.

Re:Controls behaving like in Delphi design time (move and sizable)


Quote
"J French" <je...@iss.u-net.com> wrote in message

news:3b379e6c.32691188@news.u-

Quote
> Actually I have rather avoided 'docking' it narks me in the IDE.

Me too. Especially since thats the default and one has to keep turning it
off.

Other Threads