如何使用Delphi隐藏WS_SIZEBOX创建的边框?

时间:2018-10-31 08:54:24

标签: delphi winapi delphi-10.2-tokyo

我创建具有运行时调整大小功能的自定义面板(TMyPanel)。有什么方法可以隐藏边框而不丢失调整大小功能吗?

if  (   (!isset($_SESSION['loggedin']) || (filter_var($_SESSION['loggedin']) == false)) ||
        (filter_var($_SESSION['REMOTE_ADDR']) != filter_input(INPUT_SERVER,'REMOTE_ADDR')) ||
        (!isset($_SESSION['loggedin']) || (filter_var($_SESSION['loggedin']) == false)) || 
        (filter_var($_SESSION['HTTP_USER_AGENT']) != filter_input(INPUT_SERVER,'HTTP_USER_AGENT') ) 
    ) {
    header("Location: ../login.php");
}

1 个答案:

答案 0 :(得分:2)

从您的问题中可以看出,即使没有非客户边界,您也希望实现TPanel的树脂化。如果我答对了,我可以与您分享解决方案之一。对于我的某些控制,我使用了此技术,它可以起作用。 实际上,这里不需要WS_SIZEBOX样式。

unit PanelEx;

interface

uses
  Windows,
  Messages,
  ExtCtrls;

type
  TPanelEx = class(TPanel)
  protected
    procedure WMNCHITTEST(var Message: TMessage); message WM_NCHITTEST;
  end;


implementation


procedure TPanelEx.WMNCHITTEST(var Message: TMessage);
const
  BorderSize = 10;
var
  P: TPoint;
begin
  Inherited;

  if not Assigned(Parent) then
    Exit;

  P.X := LOWORD(Message.LParam);
  P.Y := HIWORD(Message.LParam);

  // Convert screen coordinates into client
  P := Parent.ScreenToClient(P);

  // Decide what result message should have
  if (Abs(Left + Width - P.X) < BorderSize) and (Abs(Top + Height - P.Y) < BorderSize) then
    Message.Result := HTBOTTOMRIGHT
  else
  if (Abs(Left - P.X) < BorderSize) and (Abs(Top + Height - P.Y) < BorderSize) then
    Message.Result := HTBOTTOMLEFT
  else
  if (Abs(Left + Width - P.X) < BorderSize) and (Abs(Top - P.Y) < BorderSize) then
    Message.Result := HTTOPRIGHT
  else
  if (Abs(Left - P.X) < BorderSize) and (Abs(Top - P.Y) < BorderSize) then
    Message.Result := HTTOPLEFT
  else
  if Abs(Left - P.X) < BorderSize then
    Message.Result := HTLEFT
  else
  if Abs(Top - P.Y) < BorderSize then
    Message.Result := HTTOP
  else
  if Abs(Left + Width - P.X) < BorderSize then
    Message.Result := HTRIGHT
  else
  if Abs(Top + Height - P.Y) < BorderSize then
    Message.Result := HTBOTTOM;
end;


end.