Morph.C Cheater
Reputation: 0
Joined: 15 Aug 2009 Posts: 29
|
Posted: Sun Sep 20, 2009 3:16 am Post subject: error delphi whit mousemove function. |
|
|
C# CODE:
| Code: | bool pDragging = false;
Point pMousePosition = Point.Empty;
private void button1_MouseDown(object sender, MouseEventArgs e)
{
pMousePosition = button1.PointToClient(Control.MousePosition);
pDragging = true;
}
private void button1_MouseUp(object sender, MouseEventArgs e)
{
pDragging = false;
}
private void button1_MouseMove(object sender, MouseEventArgs e)
{
if (pDragging && e.Button == MouseButtons.Left)
{
Point theFormPosition = this.PointToClient(Control.MousePosition);
theFormPosition.X -= pMousePosition.X;
theFormPosition.Y -= pMousePosition.Y;
button1.Location = theFormPosition;
}
} |
I Do this:
| Code: | unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure Button1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure Button1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
pDragging: boolean;
implementation
{$R *.dfm}
procedure TForm1.Button1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
Mouse.CursorPos := Button1.ParentToClient(mouse.CursorPos)
end;
procedure TForm1.Button1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
var theformposition: TPoint;
begin
theFormPosition := form1.ParentToClient(Mouse.CursorPos);
theFormPosition.X := mouse.CursorPos.x; //it is the line what have the error i belive o.o
theFormPosition.Y := mouse.CursorPos.y;
Button1.Left := theFormPosition.X;
Button1.Top := theFormPosition.Y;
end;
procedure TForm1.Button1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
pDragging := false;
end;
end. |
please, someone can fix this error ?
thans in advance see you later!
My error here:
| Description: |
|
| Filesize: |
6.85 KB |
| Viewed: |
4145 Time(s) |

|
|
|