限制鼠标移出的方法不难,但偶最近要限制鼠标进入某个区域,该如何是好?例如:
╭═════════════════════════════╮
║ ║
║ A区 ║
║ ╭═══════════════╮ ║
║ ║ ║ ║
║ ║ ║ ║
║ ║ B区 ║ ║
║ ║ ║ ║
║ ╰═══════════════╯ ║
║ ║
║ ║
╰═════════════════════════════╯让Mouse只能在A区而不能进入B区,请不吝赐教。在线等候中……
╭═════════════════════════════╮
║ ║
║ A区 ║
║ ╭═══════════════╮ ║
║ ║ ║ ║
║ ║ ║ ║
║ ║ B区 ║ ║
║ ║ ║ ║
║ ╰═══════════════╯ ║
║ ║
║ ║
╰═════════════════════════════╯让Mouse只能在A区而不能进入B区,请不吝赐教。在线等候中……
begin
end;
procedure TForm1.Button1Click(Sender: TObject);
const
oldh : DWORD = 0;
begin
if not boolean(oldh) then
begin
oldh := GetWindowLong(treeview1.handle,GWL_WNDPROC);
SetWindowLong(treeview1.handle,GWL_WNDPROC,integer(@s));
end
else
begin
SetWindowLong(treeview1.handle,GWL_WNDPROC,oldh);
oldh := 0;
end;
end;
oldh : DWORD = 0;
……
oldh := GetWindowLong(treeview1.handle,GWL_WNDPROC);??????????
Y: Integer);
var
l, r, t, b: integer;
begin
//Shape的大小(Left, Top, Width, Height)可为你的B区域, 试一下, 呵呵!
l := Shape1.Left;
r := l+shape1.Width;
t := shape1.Top;
b := t+shape1.Height;
if ((x>=l) and (x<=r)) and ((y>=t) and (y<=b)) then
begin
// caption := 'test';
SetCurSorPos(left, 16+top);
end
else
begin
//Label1.Caption := inttostr(Mouse.CursorPos.x)+':'+inttostr(Mouse.cursorPos.y);
//你自己的代码
end;
end;
只是一进去就让你给SetCurSorPos出去而已。还有没有其它高见。
只是一进去就让你给SetCurSorPos出去而已。还有没有其它高见。