可不可以取得窗体边框的消息。就是说当鼠标移到窗体边框时会触发什么事件。

解决方案 »

  1.   

    边框??是标题栏还是窗体的左、右、下方的地方?建议你通过使用hittest消息(大概是这样写的)判断你的鼠标移动在什么范围内,然后再做处理。当然你需要自己计算这几个区域就是了。
      

  2.   

    procedure ManipulateControl(Control: TControl; Shift: TShiftState; X, Y, Precision: integer);
    var
      SC_MANIPULATE: Word;
    begin
      //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      //光标在控件的最左侧**********************************************************
      //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      if (X <= Precision) and (Y > Precision) and (Y < Control.Height - Precision)
        then begin
        SC_MANIPULATE := $F001;
        Control.Cursor := crSizeWE;
        ShowMessage('左边');
      end
      //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      //光标在控件的最右侧**********************************************************
      //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      else if (X >= Control.Width - Precision) and (Y > Precision) and (Y < Control.Height - Precision)
        then begin
        SC_MANIPULATE := $F002;
        Control.Cursor := crSizeWE;
        ShowMessage('右边');
      end
      //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      //光标在控件的最上侧**********************************************************
      //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      else if (X > Precision) and (X < Control.Width - Precision) and (Y <= Precision)
        then begin
        SC_MANIPULATE := $F003;
        Control.Cursor := crSizeNS;
        ShowMessage('上边');
      end
      //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      //光标在控件的左上角**********************************************************
      //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      else if (X <= Precision) and (Y <= Precision)
        then begin
        SC_MANIPULATE := $F004;
        Control.Cursor := crSizeNWSE;
      end
      //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      //光标在控件的右上角**********************************************************
      //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      else if (X >= Control.Width - Precision) and (Y <= Precision)
        then begin
        SC_MANIPULATE := $F005;
        Control.Cursor := crSizeNESW;
      end
      //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      //光标在控件的最下侧**********************************************************
      //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      else if (X > Precision) and (X < Control.Width - Precision) and (Y >= Control.Height - Precision)
        then begin
        SC_MANIPULATE := $F006;
        Control.Cursor := crSizeNS;
      end
      //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      //光标在控件的左下角**********************************************************
      //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      else if (X <= Precision) and (Y >= Control.Height - Precision)
        then begin
        SC_MANIPULATE := $F007;
        Control.Cursor := crSizeNESW;
      end
      //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      //光标在控件的右下角**********************************************************
      //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      else if (X >= Control.Width - Precision) and (Y >= Control.Height - Precision)
        then begin
        SC_MANIPULATE := $F008;
        Control.Cursor := crSizeNWSE;
      end
      //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      //光标在控件的客户区(移动整个控件)******************************************
      //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      else if (X > 5) and (Y > 5) and (X < Control.Width - 5) and (Y < Control.Height - 5)
        then begin
        SC_MANIPULATE := $F012;
        Control.Cursor := crDefault;
      end
      else begin
        SC_MANIPULATE := $F000;
        Control.Cursor := crDefault;
      end;
      //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      if Shift = [ssLeft] then
      begin
        ReleaseCapture;
        Control.Perform(WM_SYSCOMMAND, SC_MANIPULATE, 0);
      end;
    end;
    =====================
    demo:procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    begin
      ManipulateControl(Self,Shift,x,y,10);
    end;
      

  3.   

    Windows 发 送“wM_NCHitTest” 消 息 来 确 定 鼠 标 操 作 是 否 发 生 在 窗 体 的 客 户 区, 或 边 框 的 特 殊 区 上( 非 客 户 区)。
      

  4.   


     protected
      procedure WMNCHITTEST(var msg: TWMNCHITTEST); message WM_NCHitTest;implementationprocedure TForm1.WMNCHITTEST(var Msg: TWMNCHITTEST);
    begin
      inherited;
      if HTLEFT = Msg.Result then
      begin
        ShowMessage('左边');
      end
      else
      if HTRIGHT = Msg.Result then
      begin
        ShowMessage('右边');
      end;
      ///...后面判断自己写:)end;
    =============
    //现在移动到窗体边上看看