| View previous topic :: View next topic |
| Author |
Message |
AylinCE Grandmaster Cheater Supreme
Reputation: 37
Joined: 16 Feb 2017 Posts: 1532
|
Posted: Tue Feb 04, 2020 6:57 pm Post subject: What is "Item Click" code in Form Designer? |
|
|
I think, this question for @DarkByte:
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)
_________________
|
|
| Back to top |
|
 |
Corroder Grandmaster Cheater Supreme
Reputation: 75
Joined: 10 Apr 2015 Posts: 1668
|
Posted: Tue Feb 04, 2020 8:14 pm Post subject: |
|
|
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 |
|
 |
AylinCE Grandmaster Cheater Supreme
Reputation: 37
Joined: 16 Feb 2017 Posts: 1532
|
Posted: Wed Feb 05, 2020 1:10 am Post subject: |
|
|
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"?
_________________
|
|
| Back to top |
|
 |
Corroder Grandmaster Cheater Supreme
Reputation: 75
Joined: 10 Apr 2015 Posts: 1668
|
Posted: Wed Feb 05, 2020 2:41 am Post subject: |
|
|
@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 |
|
 |
AylinCE Grandmaster Cheater Supreme
Reputation: 37
Joined: 16 Feb 2017 Posts: 1532
|
Posted: Wed Feb 05, 2020 4:54 am Post subject: |
|
|
| 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.
_________________
|
|
| Back to top |
|
 |
AylinCE Grandmaster Cheater Supreme
Reputation: 37
Joined: 16 Feb 2017 Posts: 1532
|
Posted: Thu Feb 06, 2020 5:53 pm Post subject: |
|
|
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; |
_________________
|
|
| Back to top |
|
 |
|