Hallo,
ich habe die folgende Mausfunktion geschrieben:
Leider erhalte ich die Mausereignisse nicht. Warum?
Delphi-Quellcode:
function PollMouseEv(var Msg: TMsg; wnd: HWND; wMsgFilterMin,wMsgFilterMax: UINT): Boolean;
var
wmmou: TWMMOUSE;
moupressed: Boolean;
begin
if PollMouseEvent(Mouse_Event) then GetMouseEvent(Mouse_Event);
case Mouse_Event.Buttons of
MouseLeftButton:
begin
wmmou.msg := WM_LBUTTONDOWN;
moupressed := true;
wmmou.keys := MouseLeftButton;
wmmou.XPos := MouseWhereX;
wmmou.YPos := MouseWhereY;
Msg.message := WM_LBUTTONDOWN;
Msg.WParam := wmmou.keys;
Msg.LParam := (wmmou.YPos shl 16) + wmmou.XPos;
Msg.pt.X := wmmou.XPos;
Msg.pt.Y := wmmou.YPos;
Result := true;
end;
MouseMiddleButton:
begin
wmmou.msg := WM_MBUTTONDOWN;
wmmou.keys := MouseMiddleButton;
wmmou.XPos := MouseWhereX;
wmmou.YPos := MouseWhereY;
moupressed := true;
Msg.message := WM_MBUTTONDOWN;
Msg.WParam := wmmou.keys;
Msg.LParam := (wmmou.YPos shl 16) + wmmou.XPos;
Msg.pt.X := wmmou.XPos;
Msg.pt.Y := wmmou.YPos;
Result := true;
end;
MouseRightButton:
begin wmmou.msg := WM_RBUTTONDOWN;
wmmou.keys := MouseRightButton;
wmmou.XPos := MouseWhereX;
wmmou.YPos := MouseWhereY;
moupressed := true;
Msg.message := WM_RBUTTONDOWN;
Msg.WParam := wmmou.keys;
Msg.LParam := (wmmou.YPos shl 16) + wmmou.XPos;
Msg.pt.X := wmmou.XPos;
Msg.pt.Y := wmmou.YPos;
Result := true;
end;
end;
case Mouse_Event.Action of
MouseActionDown:
begin
case Mouse_Event.buttons of
MouseLeftButton:
begin
wmmou.msg := WM_LBUTTONDOWN; writeln('MouseAction --- WM_LBUTTON------>DOWN');
wmmou.keys := MouseLeftButton;
wmmou.XPos := MouseWhereX;
wmmou.YPos := MouseWhereY;
Msg.message := wmmou.msg;
Msg.WParam := wmmou.keys;
Msg.LParam := (wmmou.YPos shl 16) + wmmou.XPos;
Msg.pt.X := wmmou.XPos;
Msg.pt.Y := wmmou.YPos;
Result := true;
moupressed := true;
end;
MouseMiddleButton:
begin
wmmou.msg := WM_MBUTTONDOWN; writeln('MouseAction --- WM_MBUTTON--->DOWN');
wmmou.keys := MouseMiddleButton;
wmmou.XPos := MouseWhereX;
wmmou.YPos := MouseWhereY;
Msg.message := wmmou.msg;
Msg.WParam := wmmou.keys;
Msg.LParam := (wmmou.YPos shl 16) + wmmou.XPos;
Msg.pt.X := wmmou.XPos;
Msg.pt.Y := wmmou.YPos;
Result := true;
moupressed := true;
end;
MouseRightButton:
begin
wmmou.msg := WM_RBUTTONDOWN; writeln('MouseAction --- WM_RBUTTON--->DOWN');
wmmou.keys := MouseRightButton;
wmmou.XPos := MouseWhereX;
wmmou.YPos := MouseWhereY;
Msg.message := wmmou.msg;
Msg.WParam := wmmou.keys;
Msg.LParam := (wmmou.YPos shl 16) + wmmou.XPos;
Msg.pt.X := wmmou.XPos;
Msg.pt.Y := wmmou.YPos;
Result := true;
moupressed := true;
end;
end;
end;
MouseActionMove:
begin
case Mouse_Event.buttons of
MouseLeftButton:
begin
wmmou.msg := WM_MOUSEMOVE; writeln('MouseAction --- WM_LBUTTON--->Mouse Move');
wmmou.keys := MouseLeftButton;
wmmou.XPos := MouseWhereX;
wmmou.YPos := MouseWhereY;
Msg.message := wmmou.msg;
Msg.WParam := wmmou.keys;
Msg.LParam := (wmmou.YPos shl 16) + wmmou.XPos;
Msg.pt.X := wmmou.XPos;
Msg.pt.Y := wmmou.YPos;
Result := true;
moupressed := true;
end;
MouseMiddleButton:
begin
wmmou.msg := WM_MOUSEMOVE; writeln('MouseAction --- WM_MBUTTON--->Mouse Move');
wmmou.keys := MouseMiddleButton;
wmmou.XPos := MouseWhereX;
wmmou.YPos := MouseWhereY;
Msg.message := wmmou.msg;
Msg.WParam := wmmou.keys;
Msg.LParam := (wmmou.YPos shl 16) + wmmou.XPos;
Msg.pt.X := wmmou.XPos;
Msg.pt.Y := wmmou.YPos;
Result := true;
moupressed := true;
end;
MouseRightButton:
begin
wmmou.msg := WM_MOUSEMOVE; writeln('MouseAction --- WM_RBUTTON--->Mouse Move');
wmmou.keys := MouseRightButton;
wmmou.XPos := MouseWhereX;
wmmou.YPos := MouseWhereY;
Msg.message := wmmou.msg;
Msg.WParam := wmmou.keys;
Msg.LParam := (wmmou.YPos shl 16) + wmmou.XPos;
Msg.pt.X := wmmou.XPos;
Msg.pt.Y := wmmou.YPos;
Result := true;
moupressed := true;
end;
end;
end;
MouseActionUp:
begin
case Mouse_Event.Buttons of
MouseLeftButton:
begin
wmmou.msg := WM_LBUTTONUP; writeln('MouseAction --- WM_LBUTTON--->UP');
wmmou.keys := MouseLeftButton;
wmmou.XPos := MouseWhereX;
wmmou.YPos := MouseWhereY;
Msg.message := wmmou.msg;
Msg.WParam := wmmou.keys;
Msg.LParam := (wmmou.YPos shl 16) + wmmou.XPos;
Msg.pt.X := wmmou.XPos;
Msg.pt.Y := wmmou.YPos;
Result := true;
moupressed := false;
end;
MouseMiddleButton:
begin
wmmou.msg := WM_MBUTTONUP; writeln('MouseAction --- WM_MBUTTON--->UP');
wmmou.keys := MouseMiddleButton;
wmmou.XPos := MouseWhereX;
wmmou.YPos := MouseWhereY;
Msg.message := wmmou.msg;
Msg.WParam := wmmou.keys;
Msg.LParam := (wmmou.YPos shl 16) + wmmou.XPos;
Msg.pt.X := wmmou.XPos;
Msg.pt.Y := wmmou.YPos;
Result := true;
moupressed := false;
end;
MouseRightButton:
begin
wmmou.msg := WM_RBUTTONUP; writeln('MouseAction --- WM_RBUTTON--->UP');
wmmou.keys := MouseRightButton;
wmmou.XPos := MouseWhereX;
wmmou.YPos := MouseWhereY;
Msg.message := wmmou.msg;
Msg.WParam := wmmou.keys;
Msg.LParam := (wmmou.YPos shl 16) + wmmou.XPos;
Msg.pt.X := wmmou.XPos;
Msg.pt.Y := wmmou.YPos;
Result := true;
moupressed := false;
end;
end;
end;
end;
end;
Ich verwende Lazarus 1.6.4 mit Freepascal 3.0.2
.