Delphi Tips 
-----------------------------

0082  D1   D2   D3   D4   D5   D6   D7   3.1   95   98    作成: 1999/02/08 osamu rev 1.1
   B1   B3   B4   B5   B6   B7   NT3   NT4   2K   XP  更新: 1999/02/08 osamu 編集
StringGrid で マウスのある Cell 内容に応じた Hint を出したい

{Application.OnShowHint イベントハンドラの設定}

procedure TForm1.FormCreate(Sender: TObject);
begin
    Application.OnShowHint := DoShowHint;
end;


{ヒントの表示ルーチン}
{TForm1 の Private で宣言してあります。}

procedure TForm1.DoShowHint( var HintStr: string; var CanShow: Boolean;
                             var HintInfo: THintInfo);
var
  ACol,ARow: Integer;
  ARect: TRect;
begin
  {ストリンググリッドならば}
  if HintInfo.HintControl = StringGrid1 then begin
     with HintInfo do begin
       {ヒントの色の指定}
       HintColor := clAqua;
       {セルの位置を取得}
       StringGrid1.MouseToCell( CursorPos.x, CursorPos.Y, ACol, ARow );
       {セルの範囲の取得}
       ARect := StringGrid1.CellRect( ACol, ARow );
       {ヒントの表示位置}
       HintPos := StringGrid1.ClientToScreen( Point(ARect.Left,ARect.Bottom));
       {ヒントの内容}
       HintStr := 'このセルは('+IntToStr(ACol)+','+IntToStr(ARow)+')';
       {ヒントの有効範囲の設定}
       CursorRect := ARect;
     end;
  end;
end;
参照: [Delphi-ML:19686] <Additional> <その他コンポーネント関連> <コンポーネント >

[新規作成] [最新の情報に更新]

How To
Lounge
KeyWords


Tips
Delphi
Home
Osamu Takeuchi osamu@big.or.jp