 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Mauro Tronto Guest
|
Posted: Tue Apr 25, 2006 11:03 am Post subject: Using FlowPanel |
|
|
Hello,
I'm using flowpanel inside scrollbox parent component with align set to none
(flowpanel component seems that does not support scrollbars, so some
controls might be chopped off or completely hidden when dinamically add
components). When I add controls to flowpanel, height doesn't increase (I
cannot set autosize to true) and the scrollbox parent doesn't show the
scrollbars (correctly) because the flowpanel area doesn't override the
parent canvas area. Is there a way to know the REAL height of flowpanel so
that I can programmatically set during resizing of scrollbox parent?
Thanks in advance for any help
Mauro |
|
| Back to top |
|
 |
Leroy Casterline Guest
|
Posted: Fri May 26, 2006 7:42 am Post subject: Re: Using FlowPanel |
|
|
| Quote: | components). When I add controls to flowpanel, height doesn't increase (I
cannot set autosize to true) and the scrollbox parent doesn't show the
scrollbars (correctly) because the flowpanel area doesn't override the
parent canvas area. Is there a way to know the REAL height of flowpanel so
that I can programmatically set during resizing of scrollbox parent?
|
I'm doing exactly this in a current project. The 'real' height of the
flowpanel doesn't change when adding components. You have to tell it
what its height should be.
The way I handle this is to register a callback function when I create
a new item to be displayed on the flowpanel as follows (all of the
items I display are identical):
(code generalized from my app...certainly not complete)
for(int i = 0; i < fNumberOfItems; ++i) {
TFormItem *Unit = new TFormItem(NULL, i + 1, &ResizeCallback);
Unit->Parent = FlowPanel;
Unit->Show();
// code to keep track of items here...
// for example...
ItemList->Add(Unit);
}
void __fastcall TFormItems::ResizeCallback(int ItemNo)
{
int NewHeight = 0;
int ItemPosition = 0;
// sum heights of all items
for(int i = 0; i < ItemList->Count; ++i) {
TFormItem *Panel = (TFormItem *)ItemList->Items[i];
if(Panel != (TFormItem *)NULL) {
NewHeight += Panel->Height + 1;
if(ItemNo - 1 == i) {
ItemPosition = NewHeight;
}
}
}
// if sum of panel heights greater than FlowPanel height,
// set alignment to top of its parent (the ScrollBox) so
// the sizing will carry over to it and resize the panel.
// if not, set the flow panel alignment to alClient so it
// will fill its parent.
if(NewHeight > BaseHeight) {
FlowPanel->Align = alTop;
FlowPanel->Height = NewHeight + 1;
} else {
FlowPanel->Align = alClient;
}
int NewWidth;
// check to see if the scrollbar is visible and
// adjust the width as necessary
if(ScrollBox->VertScrollBar->Range > 0) {
// scrollbar showing
NewWidth = BaseWidth + ScrollBarWidth;
// adjust width of other stuff here
} else {
// scrollbar not showing
NewWidth = BaseWidth;
// adjust width of other stuff here
}
// set new width and prevent horizontal resizing
Constraints->MaxWidth = NewWidth;
Constraints->MinWidth = NewWidth;
ClientWidth = NewWidth;
// make sure this item is fully displayed
if(ItemPosition > ScrollBox->Height) {
ScrollBox->VertScrollBar->Position =
(ItemPosition - ScrollBox->Height) + 3;
}
}
When I create the parent form, I do something like
this in the constructor:
ScrollBarWidth = GetSystemMetrics(SM_CXVSCROLL);
// base width represents the width of the form without
// the scrollbar showing, so we check to see if it is
// showing here, and adjust basewidth as necessary
BaseWidth = Width - (ScrollBox->VertScrollBar->Range > 0
? ScrollBarWidth : 0);
// base height represents the height of the scroll box
BaseHeight = ScrollBox->Height;
Hope this helps! |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|