delphi7 如何判断鼠标左右键事件?

椰子天涯 2011-07-30 03:29:55
delphi7 如何判断鼠标左右键事件?

想实现这个效果
http://hi.baidu.com/%D2%AC%D7%D3%CC%EC%D1%C4/album/item/f3e71eeae613129cb3fb953f.html#

中间点击鼠标左键 两边各点击鼠标右键
...全文
1196 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
椰子天涯 2011-08-01
  • 打赏
  • 举报
回复
自己解决了 结贴了
椰子天涯 2011-08-01
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 hongss 的回复:]

OnMouseDown事件里判断

if button=mbLeft then
showmessage('1');
if button=mbright then
showmessage('2');
[/Quote]
这个我知道啊 可是怎么判断点击右键的时候是左边还是右边呢?像一楼我的代码那样的 该怎么修改呢?
hongss 2011-07-30
  • 打赏
  • 举报
回复
OnMouseDown事件里判断

if button=mbLeft then
showmessage('1');
if button=mbright then
showmessage('2');
山东蓝鸟贵薪 2011-07-30
  • 打赏
  • 举报
回复
占个位置学习学习
五哥 2011-07-30
  • 打赏
  • 举报
回复
你看看keyPress事件中 ,有一个参数是说 左键还是右键 还是中间滑轮的 ;
椰子天涯 2011-07-30
  • 打赏
  • 举报
回复
我是这样实现的 大家帮忙看看哪里出错了

var
poisCenter: TPoint;
poisLine: TPoint;
posiLeft: TPoint;
posiRight: TPoint;
这些是全局变量


procedure TCyUsbCamera_frm.img1MouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);

var point: TPoint;
begin
if Button = mbleft then
begin
begin
with img1, Canvas do
begin
poisCenter := point;
GetCursorPos(poisCenter);
poisCenter := ScreenToClient(poisCenter);
end;
end;
end else
if Button = mbright then
begin
with img1, Canvas do
begin
if ((poisCenter.x <> 0) and (point.X < poisCenter.x)) then
begin
posiLeft := point;
GetCursorPos(posiLeft);
posiLeft := ScreenToClient(posiLeft);
end else
if (poisCenter.X <> 0) then
begin
posiRight := point;
GetCursorPos(posiRight);
posiRight := ScreenToClient(posiRight);
end;
end;
end;
end;

想实现如上图所示的效果 该怎么写?

1,183

社区成员

发帖
与我相关
我的任务
社区描述
Delphi GAME,图形处理/多媒体
社区管理员
  • GAME,图形处理/多媒体社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧