Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


error delphi whit mousemove function.

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Morph.C
Cheater
Reputation: 0

Joined: 15 Aug 2009
Posts: 29

PostPosted: Sun Sep 20, 2009 3:16 am    Post subject: error delphi whit mousemove function. Reply with quote

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 Crying or Very sad ?

thans in advance see you later!

My error here:



Dibujo.PNG
 Description:
Error
 Filesize:  6.85 KB
 Viewed:  4146 Time(s)

Dibujo.PNG


Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 474

Joined: 09 May 2003
Posts: 25931
Location: The netherlands

PostPosted: Sun Sep 20, 2009 5:07 am    Post subject: Reply with quote

try using screentoclient or clienttoscreen (I always mix those 2 up)

also for your next bug:
you're never setting pDragging to true

You really have to use pMousePosition , assigning to Mouse.CursorPos changes the current cursor position but doesn't store it

and in Button1MouseMove you need to have:
if (mbleft in shift) and pdragging then
...

_________________
Tools give you results. Knowledge gives you control.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites