brimountain
asked on
Get out of a routine being executed!
Assume that I have a routine below:
// Global variable
var EscapeKey : boolean; // Whether the escape key is being
// pressed or not
procedure TForm1.Image1MouseDown(Sen der: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
.........
If EscapeKey = true then
begin
Some Code;
end;
......
end;
I tried to write Some Code that releases the mouse being down when user presses Escape key without physically release the left mouse button by hand. However, I can't do this.
Anyone here know how to do this, please help me!
Bri
// Global variable
var EscapeKey : boolean; // Whether the escape key is being
// pressed or not
procedure TForm1.Image1MouseDown(Sen
begin
.........
If EscapeKey = true then
begin
Some Code;
end;
......
end;
I tried to write Some Code that releases the mouse being down when user presses Escape key without physically release the left mouse button by hand. However, I can't do this.
Anyone here know how to do this, please help me!
Bri
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
use it in OnMouseMove:
if ssLeft in Shift then
begin
Mouse_Event(MOUSEEVENTF_LE FTUP, 0, 0, 0, 0);
end;
Bogdan
if ssLeft in Shift then
begin
Mouse_Event(MOUSEEVENTF_LE
end;
Bogdan
ASKER
Hi Bpana
Your answer is nearly what's I need. What I actually want is that:
While I am holding the left mouse button down, I press the Escape key (still keep holding the left mouse button down). It functions exactly as I physically release my index fingure holding down the left mouse button.
Brimountain
Your answer is nearly what's I need. What I actually want is that:
While I am holding the left mouse button down, I press the Escape key (still keep holding the left mouse button down). It functions exactly as I physically release my index fingure holding down the left mouse button.
Brimountain
But You must be aware that MouseUp will be fired once more when the left mouse button will be really released
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key = VK_ESCAPE then
begin
Mouse_Event(MOUSEEVENTF_LE FTUP, 0, 0, 0, 0);
end;
end;
procedure TForm1.FormKeyDown(Sender:
Shift: TShiftState);
begin
if Key = VK_ESCAPE then
begin
Mouse_Event(MOUSEEVENTF_LE
end;
end;
hi,
on the OnKeyDown event:
if Key = VK_ESCAPE then
if csLButtonDown in Button1.ControlState then
Mouse_Event(MOUSEEVENTF_LE FTUP, 0, 0, 0, 0);
Bogdan
on the OnKeyDown event:
if Key = VK_ESCAPE then
if csLButtonDown in Button1.ControlState then
Mouse_Event(MOUSEEVENTF_LE
Bogdan
change Button1 with (Sender as TControl)
if Key = VK_ESCAPE then
if csLButtonDown in (Sender as TControl).ControlState then
Mouse_Event(MOUSEEVENTF_LE FTUP, 0, 0, 0, 0);
Bogdan
if Key = VK_ESCAPE then
if csLButtonDown in (Sender as TControl).ControlState then
Mouse_Event(MOUSEEVENTF_LE
Bogdan
You need to
SetCaptureControl(nil);
or
Mouse.Capture:=0;
I.E.
if Key = VK_ESCAPE then
SetCaptureControl(nil);
This cancels mouse capture mode -> Mouse events will be sended to control where mouse cursor moved.
SetCaptureControl(nil);
or
Mouse.Capture:=0;
I.E.
if Key = VK_ESCAPE then
SetCaptureControl(nil);
This cancels mouse capture mode -> Mouse events will be sended to control where mouse cursor moved.
ASKER
Thank you so much, but i am pretty busy nowadays. I'll try your comments when free and get back soon.
ASKER
Sorry, but none of your solution fully answers my question.
Could you please open Paint pgrogram (Start/All programs/Accessories/Paint ) then click on the Pecil icon on the left hand side toolbar then draw something and press Escape key while still hold the left mouse button down to see how it works? I want the solution like that.
Bri
Could you please open Paint pgrogram (Start/All programs/Accessories/Paint
Bri
You've got such a solution from me.:)
This is the line.
// Your code
There are no other possibilities. You must undo all changes done during the operation.
This is the line.
// Your code
There are no other possibilities. You must undo all changes done during the operation.
But in any case You sould do it rather here
procedure TForm1.FormKeyDown(Sender:
Shift: TShiftState);
begin
if Key = VK_ESCAPE then
begin
// Your code
end;
end;
Set
Form1.KeyPreview := True;