Solved

memo as a docked control

Posted on 2000-05-01
11
614 Views
Last Modified: 2008-02-01
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
0
Comment
Question by:abulka
  • 6
  • 5
11 Comments
 
LVL 10

Expert Comment

by:Lischke
ID: 2768515
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
0
 

Author Comment

by:abulka
ID: 2786505
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
0
 
LVL 10

Expert Comment

by:Lischke
ID: 2787520
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
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

Author Comment

by:abulka
ID: 2808120
Adjusted points from 80 to 100
0
 

Author Comment

by:abulka
ID: 2808121
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?
0
 
LVL 10

Expert Comment

by:Lischke
ID: 2808785
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
0
 

Author Comment

by:abulka
ID: 2808995
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?
0
 
LVL 10

Expert Comment

by:Lischke
ID: 2809754
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
0
 

Author Comment

by:abulka
ID: 2812682
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.
0
 
LVL 10

Accepted Solution

by:
Lischke earned 100 total points
ID: 2813508
Oh, this is quite easy:

1) FormWithMemo.ManualDoc(MainForm.DockHost);
Put this into a piece of code where both forms are already existent. I often use OnActivate of the main form with a flag like FirstRun: Boolean, which is set to True in the main forms's OnCreate event and check it in the mentioned OnActivate event (where it is also reset after a successfull initialization).

2) Initialize the form's UndockWidth and UndockHeight properties in it's OnCreate event.

3) This happens automatically, because each TControl keeps its last docked height and width in its properties TBHeight (top-bottom height) and LRWidth (left-right width). To give the docked control an initial dock size use these properties to set it.

Ciao, Mike
0
 

Author Comment

by:abulka
ID: 2888982
Comment accepted as answer
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Delphi 2010 Export to pdf 2 330
FMX enumerated colours 2 98
Intraweb download file link ? 1 132
Delphi Form ownership 4 85
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

815 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now