Solved

memo as a docked control

Posted on 2000-05-01
11
612 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to convert wav to mp3 in delphi 9 169
PDF library for Delphi 2 104
How to define IfThen functions in one common unit? 4 44
Delphi inherited method 6 61
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

930 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