窗体锁定在屏幕内 不可超出桌面屏幕边缘

procedure WMWindowPosChanging(var Message: TWMWindowPosChanging); message WM_WINDOWPOSCHANGING;
procedure TFmBack.WMWindowPosChanging(var Message: TWMWindowPosChanging);
begin
  inherited;
  if (Message.WindowPos.y + Message.WindowPos.cy  > Screen.WorkAreaHeight) then begin
    Message.WindowPos.Y := Screen.WorkAreaHeight - Height ;
  end;
  if (Message.WindowPos.x + Message.WindowPos.cx > Screen.WorkAreaWidth) then begin
    Message.WindowPos.X := Screen.WorkAreaWidth - Width ;
  end;

  if Message.WindowPos.x < 0 then
    Message.WindowPos.x := 0;

  if Message.WindowPos.y < 0 then
    Message.WindowPos.y := 0;
end;

展开阅读全文

没有更多推荐了,返回首页