English 中文(简体)
恢复纽芬兰语
原标题:Resizing buttons so they are all the same width
  • 时间:2010-10-05 13:42:44
  •  标签:
  • delphi

我有一个“全方位”的渠道,上面有几个县(基本上是一种工具条)。 所有县都有Align=Left。 我已经设立了一个职能,将各州面积与面积相差,并计算其宽度,以填补整个梯队。 我将这一职能称为“TPanel的恢复活动手”。

procedure ScaleButtonsOnPanel;
var i: Integer;
begin
  for i:=0 to mPanel.ControlCount-1 do begin
      mPanel.Controls[i].Width := round(mPanel.width/mPanel.ControlCount-1)
  end;
end;

问题在于,如果我尽量减少,然后恢复各州从设计布局变化的形式。

谁能提出解决办法,在能够重新组建但维持设计时间顺序的小组中设立县(从左派到适当位置)?

最佳回答

我看不到你的问题。 当然,你必须确定纽芬兰人的立场,不仅是他们的规模。

procedure TForm1.Panel1Resize(Sender: TObject);
var
  i: Integer;
  btnWidth: integer;
begin
  btnWidth := Panel1.Width div Panel1.ControlCount;
  for i := 0 to Panel1.ControlCount - 1 do
  begin
    Panel1.Controls[i].Left := i * btnWidth;
    Panel1.Controls[i].Width := btnWidth;
  end;
end;

这一工作非常顺利。

https://privat.rejbrand.se/panelresize.wmv

OK,现在我看到。 我认为,<代码>alLeftis实际上是你的问题。 同样的控制往往改变其秩序。 这是众所周知的德尔菲诺。 而是如上。 有理由确保你按照正确的顺序走到各州。 如果你不能依赖<条码>第1号指示。 在每个工具栏目中设定<代码>Tag 财产(0,1,......)

procedure TForm1.Panel1Resize(Sender: TObject);
var
  i: Integer;
  btnWidth: integer;
begin
  btnWidth := Panel1.Width div Panel1.ControlCount;
  for i := 0 to Panel1.ControlCount - 1 do
  begin
    Panel1.Controls[i].Left := Panel1.Controls[i].Tag * btnWidth;
    Panel1.Controls[i].Width := btnWidth;
  end;
end;
问题回答




相关问题
determining the character set to use

my delphi 2009 app has a basic translation system that uses GNUGetText. i had used some win API calls to prepare the fonts. i thought it was working correctly until recently when someone from Malta ...

Help with strange Delphi 5 IDE problems

Ok, I m going nuts here. For the last (almost) four years, I ve been putting up with some extremely bad behavior from my Delphi 5 IDE. Problems include: Seemingly random errors in coride50.bpl ...

How to write a Remote DataModule to run on a linux server?

i would like to know if there are any solution to do this. Does anyone? The big picture: I want to access data over the web, using my delphi thin clients. But i´would like to keep my server/service ...

How convert string to integer in Oxygene

In Delphi, there is a function StrToInt() that converts a string to an integer value; there is also IntToStr(), which does the reverse. These functions doesn t appear to be part of Oxygene, and I can ...

Quick padding of a string in Delphi

I was trying to speed up a certain routine in an application, and my profiler, AQTime, identified one method in particular as a bottleneck. The method has been with us for years, and is part of a "...

热门标签