Confine popup form to client of SDI main form

I tried WM_WINDOWPOSChanging, it does not work either.

Qestion:
(1)Message.WindowPos->x and Message.WindoPos->y are constant while the dialog moving.?
So I compared Left, Top property.

(2)While debugging, this->Left and this->Top are always limited in Owner Form Rectangle, however it is moved outside of owner.

Regards
Robin

void __fastcall TProgStatusForm::WMWindowPosChanging(TWMWindowPosChanging& Message)
{
    TForm* DlgOwner = dynamic_cast<TForm*>(this->Owner);
    if (DlgOwner)
    {
        if ( this->Left < DlgOwner->Left )
        {
            this->Left = DlgOwner->Left;
        }

        if ( this->Top < DlgOwner->Top )
        {
            this->Top =  DlgOwner->Top;
        }

        if ( this->Left + this->Width > DlgOwner->Left + DlgOwner->Width )
        {
            this->Left = DlgOwner->Width - this->Width;
        }

        if ( this->Top + this->Height > DlgOwner->Top + DlgOwner->Height )
        {
            this->Top = DlgOwner->Height - this->Height;
        }
        Message.Result = 0;
    }

Quote
}