Board index » delphi » floating frame (using TCustomDockForm) without a caption...

floating frame (using TCustomDockForm) without a caption...

Hi,

I have a frame that can float or be docked to different dock sites on my
main form. Everything works fine regarding the docking stuff. The problem I
have is with the floating bit.

The FloatingDockSiteClass property of the frame is set to the name of a
class that inherits from TCustomDockForm. In that class, I do nothing but
create a handler for the OnClose event and it works fine.

The problem is that the floating frame window doesn't have a caption...

I know that if instead of a frame I wanted to make a panel floatable, I
would just have to set the Caption property of the panel and that would be
directly used for the caption of the floating panel window.

I guess I could create a panel, set its caption property to what I want and
then use the panel as a container for the frame. Well, the problem with this
solution is that I don't think it's neat.

So question: how does one can set the caption of a floating frame window?

I have tried to set it in the constructor, within a handler for the OnCreate
event, and even in AfterConstruction, but this doesn't make any
difference... for some reason the value is overridden somewhere...

    Any help would be much appreciated, Alan.

 

Re:floating frame (using TCustomDockForm) without a caption...


Quote
> So question: how does one can set the caption of a floating frame

window?

Instead of changing the caption of the frame's dock form i suggest
that you implement handling of the windows messages WM_GETTEXTLENGTH
and WM_GETTEXT in your frame. The default dock form class uses these
to setup its caption. Here's an example:

type
  TMyFrame = class(TFrame)
  private
    procedure WMGetText(var Message: TWMGetText); message WM_GETTEXT;
    procedure WMGetTextLength(var Message: TWMGetTextLength); message
WM_GETTEXTLENGTH;
  end;

const
  sCaption: string = 'MyFrame';

procedure TMyFrame.WMGetText(var Message: TWMGetText);
begin
  Message.Result := StrLen(StrPLCopy(Message.Text, sCaption,
Message.TextMax-1));
end;

procedure TMyFrame.WMGetTextLength(var Message: TWMGetTextLength);
begin
  Message.Result := Length(sCaption);
end;

Re:floating frame (using TCustomDockForm) without a caption...


Quote
> > So question: how does one can set the caption of a floating frame
> window?

> Instead of changing the caption of the frame's dock form i suggest
> that you implement handling of the windows messages WM_GETTEXTLENGTH
> and WM_GETTEXT in your frame. The default dock form class uses these
> to setup its caption. Here's an example:

Efharisto' poli' Constantine! This works VERY nicely!

    Alan.

Other Threads