Solved

after dock,..now drag

Posted on 2008-10-27
8
269 Views
Last Modified: 2012-05-05
How do i code it so that that when the newly docked form, on top, is dragged, the bottom form goes with it?
0
Comment
Question by:mikesExpertExchange
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
8 Comments
 
LVL 13

Expert Comment

by:ThievingSix
ID: 22813229
The code below moves Form2 when Form1 is moved.
type
  TForm1 = class(TForm)
    private
    procedure WMExitSizeMove(var Message: TMessage) ; message WM_EXITSIZEMOVE;
    procedure WMEnterSizeMove(var Message: TMessage) ; message WM_ENTERSIZEMOVE;
    procedure WMMove(var Message: TMessage) ; message WM_MOVE;
  public
  end;
 
var
  RunClip : Boolean;
 
implementation
 
uses 
  Unit2;
 
procedure TForm1.WMMove(var Message: TMessage);
begin
  If Not RunClip Then Exit;
  Form2.Top := Form1.Top - Form2.Height;
  Form2.Left := Form1.Left;
end;
 
procedure TfrmDesigner.WMEnterSizeMove(var Message: TMessage);
begin
  If Not RunClip Then Exit;
  Form2.Top := Form1.Top - Form2.Height;
  Form2.Left := Form1.Left;
end;
 
procedure TfrmDesigner.WMExitSizeMove(var Message: TMessage);
begin
  If Not RunClip Then Exit;
  Form2.Top := Form1.Top - Form2.Height;
  Form2.Left := Form1.Left;
end;
 
procedure TfrmDesigner.FormShow(Sender: TObject);
begin
  Form2.Show;
  RunClip := True;
end;

Open in new window

0
 
LVL 13

Accepted Solution

by:
ThievingSix earned 500 total points
ID: 22813242
Sorry, replace all TfrmDesigner with TForm1.
0
 
LVL 1

Author Comment

by:mikesExpertExchange
ID: 22816798
i put your code in and i had to modifiy it a bit to get it to put the right form on top for me and that part worked. it drags left to right just fine. but not up and down. It does someting weird like it will act as if the top form is going to drag but then when i release it just snaps back and rests on top of the other form. what am i doing wrong. i've included my code segment. also if i set RunClip to true in the onshow event my MainForm doesn't show up on the screen anywhere unless it is directly underneath my CaseListFrm window.
procedure TMainForm.WMMove(var Message: TMessage);
begin
  If Not RunClip Then Exit;
  {CaseListFrm.Top := MainForm.Top - CaseListFrm.Height;
  CaseListFrm.Left := MainForm.Left;}
  MainForm.Top := CaseListFrm.Top - MainForm.Height;
  CaseListFrm.Left := MainForm.Left;
end;
 
procedure TMainForm.WMEnterSizeMove(var Message: TMessage);
begin
  If Not RunClip Then Exit;
  {CaseListFrm.Top := MainForm.Top - CaseListFrm.Height;
  CaseListFrm.Left := MainForm.Left;}
  MainForm.Top := CaseListFrm.Top - MainForm.Height;
  CaseListFrm.Left := MainForm.Left;
end;
 
procedure TMainForm.WMExitSizeMove(var Message: TMessage);
begin
  If Not RunClip Then Exit;
  {CaseListFrm.Top := MainForm.Top - CaseListFrm.Height;
  CaseListFrm.Left := MainForm.Left;}
  MainForm.Top := CaseListFrm.Top - MainForm.Height;
  CaseListFrm.Left := MainForm.Left;
end;

Open in new window

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:mikesExpertExchange
ID: 22817122
disregard that last post. i got it figured out accept for that when the forms move for some reason there is a small gap between the bottom of the top form and the top of the bottom form. i've included a snippet of what the code looks like now but i can't account for the gap in the forms...
procedure TMainForm.WMMove(var Message: TMessage);
begin
  If Not RunClip Then Exit;
  CaseListFrm.Top := MainForm.Top + CaseListFrm.Height + 2;
  CaseListFrm.Left := MainForm.Left;
end;
 
procedure TMainForm.WMEnterSizeMove(var Message: TMessage);
begin
  If Not RunClip Then Exit;
  CaseListFrm.Top := MainForm.Top + CaseListFrm.Height + 2;
  CaseListFrm.Left := MainForm.Left;
end;
 
procedure TMainForm.WMExitSizeMove(var Message: TMessage);
begin
  If Not RunClip Then Exit;
  CaseListFrm.Top := MainForm.Top + CaseListFrm.Height + 2;
  CaseListFrm.Left := MainForm.Left;
end;

Open in new window

0
 
LVL 1

Author Comment

by:mikesExpertExchange
ID: 22817136
i added the " + 2 " at the end to try to close the gap. the " + 2 " i s not causing the gap i meant to remove that before i posted it sorry...
0
 
LVL 37

Expert Comment

by:Geert Gruwez
ID: 23313144
i object to your deleting behaviour !
it seems you are deleting all your last questions.
even with some good answers !
so either accept your own comment or one of the askers.

0
 
LVL 1

Author Closing Comment

by:mikesExpertExchange
ID: 31510327
thanks for your help
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
HTML text in the body of an email (delphi code) 12 258
Convert a string into a TDateTime 5 80
creating threads in delphi 1 202
Delphi Yen format 3 73
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

734 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