Hola Jose:Puedes hacerlo usando el evento WM_MOVING, por ejemplo:
//--- Unit1.h ---//
code:
//---------------------------------------------------------------------------
#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
void __fastcall FormShow(TObject *Sender);
private:
// Añadimos aqui la función que es llamada al
// producirse el evento WM_MOVING
void __fastcall WMMoving(TMessage &Msg);
public: // User declarations
__fastcall TForm1(TComponent* Owner);
protected:
// Enlazamos la función WMMoving con el evento WM_MOVING
BEGIN_MESSAGE_MAP
VCL_MESSAGE_HANDLER(WM_MOVING, TMessage, WMMoving)
END_MESSAGE_MAP(TForm)
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
//--- Unit1.cpp ---//
code:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop#include "Unit1.h"
#include "Unit2.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormShow(TObject *Sender)
{
Form2->Show();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::WMMoving(TMessage &Msg)
{
// Más detalles sobre WM_MOVING en la ayuda
Form2->Left = (LPRECT(Msg.LParam))->left + Width;
Form2->Top = (LPRECT(Msg.LParam))->top;
}
//---------------------------------------------------------------------------
Saludos.