unit UMove2;

interface

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

type
  TForm2 = class(TForm)
    Label1: TLabel;
    RichEdit1: TRichEdit;
    Edit1: TEdit;
    GroupBox1: TGroupBox;
    Button1: TButton;
    Button2: TButton;
    ListBox1: TListBox;
    Image1: TImage;
    procedure FormCreate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure Edit1KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure Edit1KeyUp(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure RichEdit1KeyUp(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure RichEdit1KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button1KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure Button1KeyUp(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure RichEdit1EndDock(Sender, Target: TObject; X, Y: Integer);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form2: TForm2;

implementation

uses UMove;

{$R *.dfm}

procedure TForm2.FormCreate(Sender: TObject);
begin
 Image1.ManualFloat(Rect(Form2.Left+Image1.Left, Form2.Top+Image1.Top,
                         Form2.Left+Image1.Left+Image1.Width,
                         Form2.Top+Image1.Top+Image1.Height));
 Image1.ManualDock(Form2,nil,alLeft);
end;

procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction);
begin
 Application.Terminate;
end;

procedure TForm2.Edit1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
 if (Key = VK_MENU)
 then (Sender as TEdit).DragMode := dmAutomatic;
end;

procedure TForm2.Edit1KeyUp(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
 if (Key = VK_MENU)
 then (Sender as TEdit).DragMode := dmManual;
end;

procedure TForm2.RichEdit1KeyUp(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
 if (Key = VK_MENU)
 then (Sender as TRichEdit).DragMode := dmManual;
end;

procedure TForm2.RichEdit1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
 if (Key = VK_MENU)
 then (Sender as TRichEdit).DragMode := dmAutomatic;
end;

procedure TForm2.Button1Click(Sender: TObject);
begin
 SendMessage(Handle,WM_SYSCOMMAND,SC_SCREENSAVE,0);
end;

procedure TForm2.Button2Click(Sender: TObject);
begin
 SendMessage(Handle,WM_SYSCOMMAND,SC_TASKLIST,0);
end;

procedure TForm2.Button1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
 if (Key = VK_MENU)
 then (Sender as TButton).DragMode := dmAutomatic;
end;

procedure TForm2.Button1KeyUp(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
 if (Key = VK_MENU)
 then (Sender as TButton).DragMode := dmManual;
end;

procedure TForm2.RichEdit1EndDock(Sender, Target: TObject; X, Y: Integer);
begin
 (Sender as TControl).BringToFront;
end;

end.
