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 


What is "Item Click" code in Form Designer?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
AylinCE
Grandmaster Cheater Supreme
Reputation: 37

Joined: 16 Feb 2017
Posts: 1532

PostPosted: Tue Feb 04, 2020 6:57 pm    Post subject: What is "Item Click" code in Form Designer? Reply with quote

I think, this question for @DarkByte: Smile
I need this code for a CE based project.
How can I specify the item (Button, Label etc.) that we click to edit the location in the form designer?
Can I get a sample?
With the transport code if possible. Click (select) and move (DragNow)

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1668

PostPosted: Tue Feb 04, 2020 8:14 pm    Post subject: Reply with quote

If you mean is draggable form components, here the example code:

Code:
local down = false

function ObjMouseDown(sender, x, y)
 down = true
end

function ObjMouseMove(sender, x, y)
 if down == true then
 local x,y = getMousePos()
 x,y = UDF1.ScreenToClient(x,y) --- change form name here
 sender.Top = y
 sender.Left = x
 end
end

function ObjMouseUp(sender, x, y)
 down = false
end

UDF1.show()

UDF1.CELabel1.onMouseDown = ObjMouseDown
UDF1.CEButton1.onMouseDown = ObjMouseDown
UDF1.CEEdit1.onMouseDown = ObjMouseDown

UDF1.CELabel1.onMouseMove = ObjMouseMove
UDF1.CEButton1.onMouseMove = ObjMouseMove
UDF1.CEEdit1.onMouseMove = ObjMouseMove

UDF1.CELabel1.onMouseUp = ObjMouseUp
UDF1.CEButton1.onMouseUp = ObjMouseUp
UDF1.CEEdit1.onMouseUp = ObjMouseUp



Or if ypu want to edit CE Form Designer default, find file: \jvdesign\jvdesignsurface.pas

https://github.com/cheat-engine/cheat-engine/blob/master/Cheat%20Engine/jvdesign/jvdesignsurface.pas#L99

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 37

Joined: 16 Feb 2017
Posts: 1532

PostPosted: Wed Feb 05, 2020 1:10 am    Post subject: Reply with quote

Thanks @Corroder.
I will keep this code you created in my archive. A useful code.
The logic and approach is correct, but I want to handle this event in the "Forms Designer".
For example:
Code:
TCEForm.TCELabel.onDown
--or
TCEForm.TCEButton.onMove

--etc.

I want to learn:
What is the built-in selection and transport code with "TCE"? Smile

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1668

PostPosted: Wed Feb 05, 2020 2:41 am    Post subject: Reply with quote

@Aylin, thanks, but I don't really understand what exactly do you want with CE Form Designer components such as TCEButton, TCELabel, etc.
Because CE Form Designer has built using Lazarus which you can find it at the provided link I gave you. Are you try to make a custom Form Designer?

In Lazarus it say Dragging and Resizing Form Controls at runtime, should be like this:

Code:
procedure TForm1.ControlMouseDown(
Sender: TObject;
Button: TMouseButton;
Shift: TShiftState;
X, Y: Integer);
begin
if (chkPositionRunTime.Checked) AND
(Sender is TWinControl) then
begin
inReposition:=True;
SetCapture(TWinControl(Sender).Handle);
GetCursorPos(oldPos);
end;
end;


procedure TForm1.ControlMouseMove(
Sender: TObject;
Shift: TShiftState;
X, Y: Integer);
const
minWidth = 20;
minHeight = 20;
var
newPos: TPoint;
frmPoint : TPoint;
begin
if inReposition then
begin
with TWinControl(Sender) do
begin
GetCursorPos(newPos);
if ssShift in Shift then
begin //resize
Screen.Cursor := crSizeNWSE;
frmPoint := ScreenToClient(Mouse.CursorPos);
if frmPoint.X > minWidth then
Width := frmPoint.X;
if frmPoint.Y > minHeight then
Height := frmPoint.Y;
end
else //move
begin
Screen.Cursor := crSize;
Left := Left - oldPos.X + newPos.X;
Top := Top - oldPos.Y + newPos.Y;
oldPos := newPos;
end;
end;
end;
end;

procedure TForm1.ControlMouseUp(
Sender: TObject;
Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if inReposition then
begin
Screen.Cursor := crDefault;
ReleaseCapture;
inReposition := False;
end;
end;


_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 37

Joined: 16 Feb 2017
Posts: 1532

PostPosted: Wed Feb 05, 2020 4:54 am    Post subject: Reply with quote

Corroder wrote:
Are you try to make a custom Form Designer?


You're so close.
I'm just going to add a new feature to "Form Designer".
If the project is completed; there may be an idea to be added to CE in the future.
I need; The move code of the item in the Form Designer.
I think we should expect an example from @DB. Rolling Eyes

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
AylinCE
Grandmaster Cheater Supreme
Reputation: 37

Joined: 16 Feb 2017
Posts: 1532

PostPosted: Thu Feb 06, 2020 5:53 pm    Post subject: Reply with quote

DarkByte,
Is it possible to code the following code as a function for the CE Autorun ".lua" extension?
How to encode into a "example.lua" plugin?

Code:
procedure TForm1.ControlMouseDown(
Sender: TObject;
Button: TMouseButton;
Shift: TShiftState;
X, Y: Integer);
begin
if (chkPositionRunTime.Checked) AND
(Sender is TWinControl) then
begin
inReposition:=True;
SetCapture(TWinControl(Sender).Handle);
GetCursorPos(oldPos);
end;
end;


procedure TForm1.ControlMouseMove(
Sender: TObject;
Shift: TShiftState;
X, Y: Integer);
const
minWidth = 20;
minHeight = 20;
var
newPos: TPoint;
frmPoint : TPoint;
begin
if inReposition then
begin
with TWinControl(Sender) do
begin
GetCursorPos(newPos);
if ssShift in Shift then
begin //resize
Screen.Cursor := crSizeNWSE;
frmPoint := ScreenToClient(Mouse.CursorPos);
if frmPoint.X > minWidth then
Width := frmPoint.X;
if frmPoint.Y > minHeight then
Height := frmPoint.Y;
end
else //move
begin
Screen.Cursor := crSize;
Left := Left - oldPos.X + newPos.X;
Top := Top - oldPos.Y + newPos.Y;
oldPos := newPos;
end;
end;
end;
end;

procedure TForm1.ControlMouseUp(
Sender: TObject;
Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if inReposition then
begin
Screen.Cursor := crDefault;
ReleaseCapture;
inReposition := False;
end;
end;
Rolling Eyes Rolling Eyes Rolling Eyes
_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting 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