Link to home
Start Free TrialLog in
Avatar of abulka
abulka

asked on

memo as a docked control

I simply have a TControlBar with 1 memo sitting on it. TControlBar.Align=top

TControlbar is autosize=true
The memo: dragkind=auto, dragmode=docksite

When the memo is dragged away, it forms a floating 'window' with a titlebar and small close icon. So far so good.

1. How do I put a name on the titlebar?  Usually I set the caption property of a toolbar to do this - Toolbars have a caption property, but memos do not.

2. How do I reopen the memo once the user has closed the memo by clicking on the 'x' of the floating undocked memo?

3. I want to resize my memo when it docks and resize the floating undocked window whilst the memo is floating.  How do I do this?  The dockDrop event passes a TDragDockObject which I don't know what to do with.

I am using Delphi 4

thanks for all 3 questions,
-Andy
Avatar of Lischke
Lischke

Hi Andy,

mmmmh, 3 question for 1 and then only 80 points :-/ This is not very fair but since I had recently to do with docking quite a lot I will give you the answers.

1) Use the parent of the floating memo. It is a TForm (if you have not changed that) and has therefor a Caption property.

2) Memo.Visible := True;

3) This question is unclear. You want to resize the memo, right? But to what size? There're some properties you can use to control the size for docking. Look for UndockWidth, UndockHeight, LRDockWidth and TBDockHeight.

Ciao, Mike
Avatar of abulka

ASKER

I'll try out your answers - thanks.  

Re Q1 - I wouldn't want the floating memo window to take on the form's caption.  Can I embed the memo in another type of control so that I can have a unique caption for it?

-Andy
Hi Andy,

of course you can have your own floating host. Either use TControl.FloatingDockSiteClass to set a control of your choice or use the default floating dock class defined in Controls.pas. The latter needs only one assignment and works then for all controls in an application.

Ciao, Mike
Avatar of abulka

ASKER

Adjusted points from 80 to 100
Avatar of abulka

ASKER

Sorry to be dumb, but I designed the form visually - with a TMemo sitting in a TControlBar.  

Are you saying I need to write some code that alters the above situation in order to get a proper caption for my floating memo?  

Or should I squeeze another visual component in between the memo and the tcontrolbar component?
Well, you must design the memo sitting on an own form not already docked to the control bar. This will give you the desired unique caption. Dock the form manually on program startup if you want it docked initially.

Ciao, Mike
Avatar of abulka

ASKER

Mmm - that'l mean I have to change all my references to memo2 to frmFloat.memo2

Any chance of some actual code to achieve all this?
Would this be so hard? I think not. The major issue is that docking support in the VCL is limited to TForm, TPanel and TPageControl (well, TControl already has some basic stuff too, but this is only really used within the mentioned components). From this follows the best way to use docking (and to get the expected behavior) is to use TForm as floating host. I have seen strange effects (even not correctly painted docking handles etc.) when not using a TForm.

Handling a control on a TForm used as floating host is very simple because you must only dock the form (yes, I know, this adds another layer between the control and the real dock host). All controls on the form being docked are then automatically placed correctly. For manual docking use TControl.ManualDock.

Ciao, Mike
Avatar of abulka

ASKER

Ok thanks.  Could I give you some more points for some code?

Basically
 1. At start up dock the form with the memo on it.
 2. On undock, size the form to 200x200
 3. On dock, size the form back to its original length and snap it back to the leftmost edge.
ASKER CERTIFIED SOLUTION
Avatar of Lischke
Lischke

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of abulka

ASKER

Comment accepted as answer