편집 : VCL은 오른쪽 드래그를해도 문제가 없으며 아래의 샘플 프로그램은 완벽하게 작동합니다. 마우스 제스처 유틸리티로 문제가 발생합니다. 내가 끝 컨트롤을 마우스 오른쪽 버튼으로 드래그의을 감지 할TControl의 오른쪽 드래그 끝을 감지하는 방법은 무엇입니까?
(아마도 그것은 & 요격 WM_RBUTTONUP 이벤트 ... 후크).
왼쪽 드래그의 경우 MouseUp 이벤트를 사용할 수 있지만 오른쪽 드래그 후에는 발생하지 않습니다.
아래의 테스트 프로그램 (양식의 오른쪽에 메모를 넣고 양식을 드래그하십시오)에서 마우스 오른쪽 단추를 누른 후 마우스 커서를 재설정하고 싶습니다.
어떻게하면됩니까? (WM_RBUTTONUP이 오지 않습니다.)
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Memo1: TMemo;
procedure FormMouseDown(Sender: TObject; Button: TMouseButton; Shift:
TShiftState; X, Y: Integer);
procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
procedure FormMouseUp(Sender: TObject; Button: TMouseButton; Shift:
TShiftState; X, Y: Integer);
procedure WMRButtonUp(var Message: TWMRButtonUp); message WM_RBUTTONUP;
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function ShiftStateToStr(Shift: TShiftState): string;
begin
if ssShift in Shift then
Result := Result + 'S-';
if ssCtrl in Shift then
Result := Result + 'C-';
if ssAlt in Shift then
Result := Result + 'A-';
if ssDouble in Shift then
Result := Result + 'D-';
if ssLeft in Shift then
Result := Result + 'L';
if ssRight in Shift then
Result := Result + 'R';
if ssMiddle in Shift then
Result := Result + 'M';
end;
function MouseButtonToStr(Btn: TMouseButton): string;
begin
if Btn = mbLeft then
Result := 'Left'
else if Btn = mbRight then
Result := 'Right'
else if Btn = mbMiddle then
Result := 'Middle';
end;
procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton; Shift:
TShiftState; X, Y: Integer);
begin
SetCapture(Handle);
Memo1.Lines.Add(Format('Down(Btn=%s, Shift=[%s])', [MouseButtonToStr(Button), ShiftStateToStr(Shift)]));
if Button = mbLeft then
Screen.Cursor := crDrag
else if Button = mbRight then
Screen.Cursor := crSize;
end;
procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y:
Integer);
begin
Memo1.Lines.Add(Format('Move(Shift=[%s])', [ShiftStateToStr(Shift)]));
end;
procedure TForm1.FormMouseUp(Sender: TObject; Button: TMouseButton; Shift:
TShiftState; X, Y: Integer);
begin
ReleaseCapture;
Memo1.Lines.Add(Format('Up(Btn=%s, Shift=[%s])', [MouseButtonToStr(Button), ShiftStateToStr(Shift)]));
Screen.Cursor := crDefault;
end;
procedure TForm1.WMRButtonUp(var Message: TWMRButtonUp);
begin
Memo1.Lines.Add('WMRbuttonUp');
inherited;
end;
end.
왜 컨트롤/양식의 OnDrag ... 이벤트를 사용하지 않습니까? –
실제 상황에서 3D 공간의 시점을 회전 및 변환하고 싶습니다. 단순한 샘플 일뿐입니다. – benok