http://www.ten-design.net/c.jpgGrid列宽度不够时,出现提示框。谢谢。
解决方案 »
- 我很在意BORLAND,金色的BORLAND,详见下文
- 请问一下管道中的数据要不要强制刷新?
- 一个SQL Server与Delphi 结合的疑问?
- 打开应用程序用何函数?
- 我在delphi下做的控件,为什么在vb下用不了?
- 那兒有dephi5.0或6.0的教程下載.謝謝.
- 我用ClientDataSet操作扩展名为cds的数据文件,怎么进行SQL查询呢?
- toolbar的toolbutton设置哪个属性可以让Caption和Image位置上是左右关系?
- 浮动控件?是不是啊?
- 由于使用Access数据库越来越大,在程序中如何压缩Access的数据库文件,把它压小呢?
- 高手请进:怎样用Delphi把EXCEL表导入数据库?
- 子form 删除的问题?
自己做个Grid控件,从StringGrid继承
uses
forms;type
TLssStringGrid = class(TStringGrid)
private
FLastHintPos: TPoint;
procedure CMHintShow(var Msg: TMessage); message CM_HINTSHOW; protected
procedure ShowHintProc(var HintStr: string; var CanShow: Boolean; var HintInfo: THintInfo);
procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
end;//实现部分Procedure TLssStringGrid.CMHintShow(Var Msg: TMessage);
var
CanShow: Boolean;
hi: PHintInfo;
Begin
CanShow := False;
hi := PHintInfo(Msg.LParam);
ShowHintProc(hi.HintStr,CanShow,hi^);
Msg.Result := Ord(Not CanShow);
end;
procedure TLssStringGrid.ShowHintProc(var HintStr: string; var CanShow: Boolean; var HintInfo: THintInfo);
var
ACol,ARow: Integer;
HintPos: TRect;
begin
MouseToCell(HintInfo.CursorPos.x,HintInfo.CursorPos.y,ACol,ARow);
if (ACol >= FixedCols) and (ARow >= FixedRows) and
(ACol < ColCount) and (ARow < RowCount) then
begin
HintStr := Cells[ACol,ARow];
if Canvas.TextWidth(HintStr) > ColWidths[ACol] then
begin
FLastHintPos := Point(ACol,ARow);
HintPos := CellRect(ACol,ARow);
HintInfo.HintPos := ClientToScreen(HintPos.TopLeft);
CanShow := True;
end;
end;
end;procedure TLssStringGrid.MouseMove(Shift: TShiftState; X, Y: Integer);
var
ACol,ARow: integer;
begin
inherited;
if (FLastHintPos.x >= 0) and (FLastHintPos.y >= 0) then
begin
MouseToCell(x,y,ACol,ARow);
if (ACol <> FLastHintPos.x) or (ARow <> FLastHintPos.y) then
begin
Application.CancelHint;
FLastHintPos := Point(-1,-1);
end;
end;
end;