Ver Mensaje Individual
  #2  
Antiguo 13-01-2017
Avatar de Angel.Matilla
Angel.Matilla Angel.Matilla is offline
Miembro
 
Registrado: ene 2007
Posts: 1.350
Reputación: 19
Angel.Matilla Va por buen camino
Thumbs up ¡Encontré la solución!

La he tenido todo el tiempo delante y no me había dado cuenta ops:

El código ha quedado así:
Código:
void __fastcall TfTablas::BotAyu(TObject *Sender)
{
     TBitBtn *Boton = dynamic_cast<TBitBtn>(Sender);
     TComponent *Source;
     POINT P1, P2;

    for (nItem = 0; nItem <this>ComponentCount; nItem ++)
     {
          Source = this->FindComponent("AyuLis");
          if (Source != NULL)
               return;
     }

    for (nItem = 0; nItem <this>ComponentCount; nItem ++)
     {
          Source = this->FindComponent(Boton->Name.SubString(2, Boton->Name.Length()));
          if (Source != NULL)
               if (Source->ClassNameIs("TEdit") || Source->ClassNameIs("TLabeledEdit"))
               {
                    AyuEdit = static_cast<TCustomEdit>(Source);
                    break;
               }
     }

     if (Source == NULL)
          return;

     P1.x = AyuEdit->Left;
     P1.y = AyuEdit->Top;
     P2 = this->ScreenToClient(AyuEdit->Parent->ClientToScreen(P1));

     AyuLis              = new TListBox(this);
     AyuLis->Name        = "AyuLis";
     AyuLis->Parent      = this;
     AyuLis->BevelInner  = bvNone;
     AyuLis->BevelKind   = bkFlat;
     AyuLis->BevelOuter  = bvLowered;
     AyuLis->BorderStyle = bsNone;
     AyuLis->Height      = 10 * AyuLis->ItemHeight;
     AyuLis->Left        = P2.x;
     AyuLis->Top         = P2.y + AyuEdit->Height;
     AyuLis->Width       = AyuEdit->Width + Boton->Width;
     AyuLis->OnClick     = AyuLisClick;
}
Hay que usar ClientToScreen para sacar la posición absoluta en píxeles del objeto y convertirla luego a posición relativa referida al formulario con ScreenToClient.
Responder Con Cita