Ver Mensaje Individual
  #7  
Antiguo 20-10-2015
Avatar de aguml
aguml aguml is offline
Miembro
 
Registrado: may 2013
Posts: 885
Reputación: 14
aguml Va por buen camino
Muy bien, guiandome de tu codigo y de otro que encontré por la red en ruso pude sacar este codigo:
En el .h
Código PHP:
private:    // User declarations
   
void __fastcall CatchDrag(TMessage &Msg);
protected:
  
BEGIN_MESSAGE_MAP
  VCL_MESSAGE_HANDLER
(WM_MOVING, TMessage, CatchDrag);
  
END_MESSAGE_MAP(TForm) 
En el .cpp:
Código PHP:
void __fastcall TFormHijo::CatchDrag(TMessage &Msg)
{
   
TForm::Dispatch(&Msg);
   if(
Msg.Msg == WM_MOVING){
      
PRECT pCurrentRec = PRECT(Msg.LParam);

      
//El 5 creo que es por los bordes de la ventana padre
      
if(pCurrentRec->left < FormPadre->Left + 5){
         
pCurrentRec->left = FormPadre->Left + 5;
         
pCurrentRec->right = Left + Width + 5;
      }else if(
pCurrentRec->right > FormPadre->Left + FormPadre->Width - 5){
         
pCurrentRec->left = FormPadre->Left + (FormPadre->Left + FormPadre->Width - (Left + Width) - 5);
         
pCurrentRec->right = FormPadre->Left + FormPadre->Width - 5;
      }
      
//Tengo un Panel alineado arriba y el 32 creo que es porque es lo que mide
      //barra de titulo de la ventana padre
      
if(pCurrentRec->top < FormPadre->Top + FormPadre->Panel->Height + 32){
         
pCurrentRec->top = FormPadre->Top + FormPadre->Panel->Height + 32;
         
pCurrentRec->bottom = Top + Height + 32;
      }else if(
pCurrentRec->bottom > FormPadre->Top + FormPadre->Height - 5){
         
pCurrentRec->top = FormPadre->Top + (FormPadre->Top + FormPadre->Height - (Top + Height)) - 5;
         
pCurrentRec->bottom = FormPadre->Top + FormPadre->Height - 5;
      }
      
Caption = "LeftBeforeMove: " + IntToStr(pCurrentRec->left) +
                
"  TopBeforeMove: " + IntToStr(pCurrentRec->top);
   }
} 
El problema que tengo es que me redimensiona la ventana hija y no veo la manera de solucionarlo. O sea que no me respeta el tamaño que tenia la ventana hija y es porque algo hago mal al darle el right y el bottom.

Última edición por aguml fecha: 20-10-2015 a las 09:45:27.
Responder Con Cita