@@ -321,6 +321,7 @@ TLabeledDbGrid = class(TDBGrid)
321321 FRowMargin: Integer;
322322 FWrapAllText: Boolean;
323323 FColMoving: Boolean;
324+ FTitleMouseDown: boolean;
324325 function TitleOffset : Integer;
325326 procedure OnSearchTimer (Sender : TObject);
326327 procedure SetBoundCaption (const Value : TCaption);
@@ -381,12 +382,17 @@ TLabeledDbGrid = class(TDBGrid)
381382 procedure MouseMove (Shift: TShiftState; X, Y: Integer); override;
382383 procedure MouseDown (Button: TMouseButton; Shift: TShiftState;
383384 X, Y: Integer); override;
385+ procedure MouseUp (Button: TMouseButton; Shift: TShiftState; X: Integer; Y: Integer); override;
386+
384387 function GetBorderStyle : TBorderStyle;
385388 { $IF DEFINE DXE8+}
386389 procedure ChangeScale (M, D: Integer; isDpiChange: Boolean); override;
387390 { $ELSE}
388391 procedure ChangeScale (M, D: Integer); override;
389392 { $ENDIF}
393+
394+ function CreateColumns : TDBGridColumns; override;
395+
390396 public
391397 procedure DefaultDrawColumnCell (const Rect: TRect; DataCol: Integer;
392398 Column: TColumn; State: TGridDrawState);
@@ -452,6 +458,14 @@ implementation
452458 DBActns, UxTheme, UITypes,
453459 // Labeled components
454460 Vcl.DbAwareLabeledUtils, Vcl.LabeledCtrls;
461+
462+ type
463+ TXColumn = class (TColumn)
464+ private
465+ FTitleCaption: string;
466+ public
467+ property TitleCaption: string read FTitleCaption write FTitleCaption;
468+ end ;
455469
456470var
457471 DbGridPrintSupport: TStringList;
@@ -1209,6 +1223,11 @@ constructor TLabeledDbGrid.Create(AOwner: TComponent);
12091223 FColMoving := True;
12101224end ;
12111225
1226+ function TLabeledDbGrid.CreateColumns : TDBGridColumns;
1227+ begin
1228+ Result := TDBGridColumns.Create(Self, TXColumn)
1229+ end ;
1230+
12121231procedure TLabeledDbGrid.VisibleChanging ;
12131232begin
12141233 inherited ;
@@ -1341,6 +1360,8 @@ procedure TLabeledDbGrid.DrawCell(ACol, ARow: Longint; ARect: TRect; AState: TGr
13411360 SortOrder: TCBSortOrder;
13421361 LRect: TRect;
13431362 LDataLinkActive: Boolean;
1363+
1364+ Text: string;
13441365begin
13451366 dxGridSortedShapeMinWidth := ARect.Bottom - ARect.Top; // 16
13461367 // se è il record corrente aggiorno il flag in modo tale che nell'evento
@@ -1355,6 +1376,26 @@ procedure TLabeledDbGrid.DrawCell(ACol, ARow: Longint; ARect: TRect; AState: TGr
13551376 FDrawingCurrentRecord := True
13561377 else
13571378 FDrawingCurrentRecord := False;
1379+
1380+ // artifizio per avere i puntini di sospensione anche in caso di troncatura del testo sul titolo
1381+ if not FTitleMouseDown and (gdFixed in AState) and (ACol > 0 ) and not (csDesigning in ComponentState) then
1382+ begin
1383+ DrawColumn := Columns[ACol];
1384+ Text := TXColumn(DrawColumn).TitleCaption;
1385+
1386+ if Text = ' ' then
1387+ begin
1388+ Text := DrawColumn.Title.Caption;
1389+ TXColumn(DrawColumn).TitleCaption := Text; // prima assegnazione della caption originale
1390+ end ;
1391+
1392+ if (StrRicercaIncrementale <> ' ' ) and (SelectedIndex = ACol) then
1393+ Text := ' [' + StrRicercaIncrementale + ' ] ' +Text;
1394+
1395+ DrawColumn.Title.Caption := TruncStringInRect(Canvas, ARect, Text, 2 ) ;
1396+ end ;
1397+ // --ale
1398+
13581399 finally
13591400 Inc(ACol, IndicatorOffset);
13601401 end ;
@@ -1623,6 +1664,9 @@ procedure TLabeledDbGrid.SetOnBkCellColorAssign(const Value: TCBBkCellColorAssig
16231664procedure TLabeledDbGrid.MouseDown (Button: TMouseButton; Shift: TShiftState; X,
16241665 Y: Integer);
16251666begin
1667+ FTitleMouseDown := (Button = mbLeft) and (Shift = [ssLeft])
1668+ and isMouseOverTitleColumn(X,Y) and not Sizing(X,Y);
1669+
16261670 inherited ;
16271671 if (Button = mbLeft) and (Shift = [ssLeft]) then
16281672 begin
@@ -2309,6 +2353,13 @@ procedure TLabeledDbGrid.MouseMove(Shift: TShiftState; X, Y: Integer);
23092353 end ;
23102354end ;
23112355
2356+ procedure TLabeledDbGrid.MouseUp (Button: TMouseButton; Shift: TShiftState;
2357+ X, Y: Integer);
2358+ begin
2359+ FTitleMouseDown := False;
2360+ inherited ;
2361+ end ;
2362+
23122363procedure TLabeledDbGrid.SetCheckBoxedFields (const Value : string);
23132364begin
23142365 if FCheckBoxedFields <> Value then
0 commit comments