限制鼠标移出的方法不难,但偶最近要限制鼠标进入某个区域,该如何是好?例如:              
               
  ╭═════════════════════════════╮
  ║                                                      ║
 ║    A区                                               ║
  ║           ╭═══════════════╮           ║
  ║           ║                            ║           ║
  ║           ║                            ║           ║
  ║           ║           B区              ║           ║
  ║           ║                            ║           ║
  ║           ╰═══════════════╯           ║
  ║                                                      ║
 ║                                                      ║
  ╰═════════════════════════════╯让Mouse只能在A区而不能进入B区,请不吝赐教。在线等候中……

解决方案 »

  1.   

    procedure s;
    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;
      

  2.   

    const
       oldh : DWORD = 0;
    ……
    oldh := GetWindowLong(treeview1.handle,GWL_WNDPROC);??????????
      

  3.   

    procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
      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;
      

  4.   

    好像没有什么好办法,可以通过在鼠标移动时,重新计算ClipCursor的矩形,得到你要求的近似效果
      

  5.   

    to bluebilly(蓝色天使):你误会我的意思了,我不是要在我的Form上限制,是整个屏幕,再说用这种方法还是能移进去的。
    只是一进去就让你给SetCurSorPos出去而已。还有没有其它高见。
      

  6.   

    讲个思路把~~~~当鼠标移动到某个区域的时候,你就用SetCursorPos来将它移开
      

  7.   

    to  Eastunfail(恶鱼杀手):没看到我这个贴吗?:to bluebilly(蓝色天使):你误会我的意思了,我不是要在我的Form上限制,是整个屏幕,再说用这种方法还是能移进去的。
    只是一进去就让你给SetCurSorPos出去而已。还有没有其它高见。