The Delphi Bug List

Entry No.
653
VCL - 一般 - フォーム - TCustomForm
BorderStyle プロパティが bsSizeToolWin の場合、 AutoScroll プロパティは不正確な値を返す。プログラムの実行中、常に True になっている。
1.02 2.01 3.0 3.01 3.02 4.0 4.01 4.02 4.03 5.0 5.01 6.0 6.01 6.02 Kylix 1.0
N/A Absent Absent Absent Absent Exists Exists Exists Exists Exists Exists Exists Exists Exists N/A
解説
Reported by Jordan Russell
BorderStyle プロパティに bsSizeToolWin がセットされている場合、AutoScroll プロパティは不正確な値を返します。プログラムの実行中、常に True になっています。

これは、Delphi 4 以降では、AutoScroll プロパティの後に BorderStyle プロパティがロードされるためです。BorderStyle が bsSizeable または bsSizeToolWin の場合、SetBoderStyle メソッドは AutoScroll を True に変更します。
解決策 / 回避方法
私は、SetBorderStyle(Forms.pas) は以下のようにコーディングされるべきだったと思います(太字 = 追加行)。こうすればコンポーネントのロード中に AutoScroll を変更しようとはしません。
procedure TCustomForm.SetBorderStyle(Value: TFormBorderStyle);
begin
  if FBorderStyle <> Value then
  begin
    FBorderStyle := Value;
    if not (csLoading in ComponentState) then
      AutoScroll := FBorderStyle in [bsSizeable, bsSizeToolWin];
    if not (csDesigning in ComponentState) then RecreateWnd;
  end;
end;

VCL のソースコードを変更したくない場合の回避方法は、フォームの OnCreate ハンドラの中に "AutoScroll := False" を記述することです。

Latest update of this entry: 2002-02-20
本家 The Delphi Bug List のエントリーはこちら
The Delphi Bug List 日本語訳 へ