2006. november 21., kedd

Disable the close button on a floating dock form


Problem/Question/Abstract:

I want to know how to prevent an undocked control from destroying when I clicked on the X shaped close button on the right corner.

Answer:

You have to create your own docksite form:

type
  TNoCloseDockform = class(TCustomDockForm)
  private
    procedure WMSysCommand(var msg: TWMSyscommand); message WM_SYSCOMMAND;
  end;

  { TNoCloseDockform }

procedure TNoCloseDockform.WMSysCommand(var msg: TWMSyscommand);
begin
  if (msg.CmdType and $FFF0) = SC_CLOSE then
    Msg.result := 0
  else
    inherited;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  panel1.FloatingDockSiteClass := TNoCloseDockform;
end;

Nincsenek megjegyzések:

Megjegyzés küldése