Solved

memo as a docked control

Posted on 2000-05-01
11
610 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
 

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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

747 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

10 Experts available now in Live!

Get 1:1 Help Now