1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
//---------------------------------------------------------------------------
__fastcall jEdit::jEdit(TComponent *AOwner)
: TEdit(AOwner)
{
StringList = new TStringList;
// pour lui donner vie
StringList->Add("Coucou 1");
StringList->Add("Coucou 2");
StringList->Add("Coucou 3");
StringList->Add("Coucou 4");
if(AOwner->InheritsFrom(__classid(TWinControl)))
{
Parent = (TWinControl*)AOwner;
}
ListBox = NULL;
}
//---
__fastcall jEdit::~jEdit()
{
delete StringList;
}
//---
void __fastcall jEdit::SetListVisible(bool Value)
{
if(ListBox == NULL)
{
if(Value == true)
{
ListBox = new TListBox(this);
ListBox->Parent = Parent;
ListBox->Visible = false;
for(int j=0; j < StringList->Count; j++)
{
ListBox->Items->Add(StringList->Strings[j]);
}
ListBox->Left = Left;
ListBox->Top = Top + Height;
TWinControl *P = Parent;
while(P->InheritsFrom(__classid(TForm)) == false)
{
ListBox->Left = ListBox->Left + P->Left;
ListBox->Top = ListBox->Top + P->Top;
P = P->Parent;
}
ListBox->Parent = P;
ListBox->Visible = true;
ListBox->BringToFront();
}
}
else
{
if(Value == false)
{
delete ListBox;
ListBox = NULL;
}
}
}
//---
bool __fastcall jEdit::GetListVisible()
{
return (ListBox != NULL );
}
//--- |
Partager