특히 C++ 빌더, GUI 프로그래밍에 먼저 떨어져, 나에 대해 릴, 나는 아주 새로운 해요 런타임
에서 tframe의 크기를 변경. 위의 그림처럼 셀의 행을 포함하는 tframe이 있습니다. + 버튼이 있으며, 누를 때 셀은 그림과 같이 마지막 열에 만 추가됩니다. 마지막 열이 커지면 런타임 동안 tframe의 크기를 변경할 수 있는지 궁금합니다. tframe은 셀의 한 행 크기만큼 시작해야합니다. 이 tframe에 대한 스크롤바가 없을 수 있습니다. 셀이 마지막 열에 추가되면 단순히 높이를 확장해야합니다.
고맙습니다.
자세히.
여기에 빨간색 셀을 추가하는 tframe 자체의 코드가 있습니다 (또 다른 tframe jsut fyi입니다). 이 tframe도 스크롤 상자에 추가됩니다. 더 나은 이해를 위해 Tree Structure with TFrames의 그림을 참조하십시오. 궁극적 인 목표는 tframes의 트리 구조를 만드는 것입니다.
이 특정 퀘스트의 tframe은 다른 질문의 그림에서 가장 오른쪽에있는 tframe입니다.
__fastcall TTreeTframe::TTreeTframe(TComponent* Owner)
: TFrame(Owner)
{
AddCells();
}
//---------------------------------------------------------------------------
void __fastcall TTreeTframe::AddCells()
{
//this part adds the cells in the tframe (red boxes in the picture)
int tempCellRow = 0;
TCells* NewCellRow = new TCells (this);
NewCellRow->Parent=this;
TComponentEnumerator * ParentEnum = this->GetEnumerator();
while(ParentEnum->MoveNext())
{
tempCellRow++;
}
NewCellRow->SetIndex(tempCellRow);
NewCellRow->Name = "Cell" + IntToStr(tempCellRow);
NewCellRow->Top = (NewCellRow->Height) * (tempCellRow-9);
NewCellRow->Left = 213;
NewCellRow->OnClose = &DeleteCell;
}
void __fastcall TTreeTframe::DeleteCell(TObject *Sender)
{
//this part deletes the cells when the delete button is pressed. As
//mentioned the red boxes themselves are also tframe, and in that
//tframe is a TEdit with a delete button. just so u know where the
//delete button is located
TCells* TCurrent = NULL;
int CellRow = 0;
TCells* NewCellRow = (TCells*)Sender;
CellRow = NewCellRow->GetIndex();
NewCellRow->Name = "";
TComponentEnumerator * ParentEnum = NewCellRow->Parent->GetEnumerator();
while(ParentEnum->MoveNext())
{
TCurrent = (TCells*)ParentEnum->GetCurrent();
if(TCurrent->GetIndex() > CellRow)
{
TCurrent->SetIndex(TCurrent->GetIndex() - 1);
TCurrent->Top -= (NewCellRow->Height);
TCurrent->Name = "DistIPCell" + IntToStr(TCurrent->GetIndex());
}
}
}
//---------------------------------------------------------------------------
void __fastcall TTreeTframe::btnAddCellsClick(TObject *Sender)
{
// this is what the red + does
AddCells();
}
//---------------------------------------------------------------------------
// the rest of this is for the propose of deleting this tframe from the tree structure
void __fastcall TTreeTframe::btnRemoveClick(TObject *Sender)
{
if (FOnClose != NULL)
{
FOnClose(this);
}
PostMessage(Handle, CM_RELEASE, 0, 0);
}
//---------------------------------------------------------------------------
void __fastcall TTreeTframe::WndProc(TMessage &Message)
{
if (Message.Msg == CM_RELEASE)
{
delete this;
return;
}
TFrame::WndProc(Message);
}
//---------------------------------------------------------------------------
void __fastcall TTreeTframe::SetIndex(int TypeRow)
{
this->TypeRow = TypeRow;
}
int __fastcall TTreeTframe::GetIndex()
{
return this->TypeRow;
}
//---------------------------------------------------------------------------
설명이 약간 까다 롭습니다. 명확한 설명이 필요하면 알려주세요. 감사합니다.
o TFrame-> Height와 비슷하지만 추가를 클릭하면 설정됩니까? 이 프로젝트에 많은 도움을 주셔서 감사합니다. 나는 바보처럼 어지럽게 많은 질문을하며 나를 도울 필요가 있다고 느낀다. 그러나 나는 전에 이것에 기초하지 않았다고 말했고, 나를 위해 정말 거대한 학습 경험이었다. – livelaughlove
'TFrame'은 또한'AutoSize'를 가지고있다. 대신 'true'로 설정할 수있는 속성을 사용할 수 있습니다. 그런 다음 '높이'를 수동으로 조정할 필요가 없습니다. –
이봐, 내가 이걸 작동 시키려고 노력해 왔어. tframe에서 AutoSize를 확인했지만 런타임 중에 크기가 조정되지 않습니다. 세포가 제대로 추가되면 프레임이 더 커지지 않습니다. OnResize() 이벤트에 대해 뭔가를 구현해야합니까 아니면 다른 뭔가를 놓치고 있습니까? – livelaughlove