![]() |
![]() |
| Paypal | FTP | CCD | Buscar | Trucos | Trabajo | Foros |
|
#1
|
||||
|
||||
|
Ayuda dinámica
Tengo este formulario
![]() El cuadro gris que se ve abajo a la derecha es un TListBox que sea crea de forma dinámica al pulsar el BitBtn que se ve a la izquierda. Par ello uso este código: 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->Parent->Left + AyuEdit->Left;
P1.y = AyuEdit->Parent->Top + AyuEdit->Top + AyuEdit->Height;
P2 = 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->Color = clSilver;
AyuLis->Height = 10 * AyuLis->ItemHeight;
AyuLis->Left = P2.x;
AyuLis->Top = P2.y;
AyuLis->Width = AyuEdit->Width + Boton->Width;
AyuLis->OnClick = AyuLisClick;
}
|
|
#2
|
||||
|
||||
|
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;
}
|
![]() |
|
|
Temas Similares
|
||||
| Tema | Autor | Foro | Respuestas | Último mensaje |
| clave dinámica | cmfab | Varios | 2 | 26-03-2012 16:02:57 |
| Pagina Web Dinamica | Rabata | Varios | 8 | 31-10-2005 18:00:08 |
| Grilla dinamica | zugazua2001 | OOP | 1 | 04-10-2004 18:52:02 |
| Construcción de SQL dinámica | Aprendiz | SQL | 2 | 10-10-2003 14:39:35 |
|