Index: JvDBHTLabel.pas
===================================================================
--- JvDBHTLabel.pas	(revision 10857)
+++ JvDBHTLabel.pas	(working copy)
@@ -24,6 +24,21 @@
 - You can have more than one FIELD tag in a label, i.e:
   <b>Name:</b><i><FIELD="contact"></i>, <b>Company:</b><i><FIELD="Company"></i>
 - The fieldname *must* be double-quoted!
+
+Changes:
+========
+Werewolf
+  2006-08-01
+  [+] Added procedure TJvDBHTLabel.Notification(AComponent: TComponent; Operation: TOperation);
+      that nils DataSource when it is
+  [+] Added function TJvDBHTLabel.GetLabelText: string; override;
+      to display correct label caption on TDBCtrlGrid
+  [+] Added procedure TJvDBHTLabel.CMGetDataLink(var Message: TMessage); message CM_GETDATALINK;
+      Gets DataSource from TDBCtrlGrid
+  [+] Added procedure TJvDBHTLabel.Loaded; override;
+      to dispay data after loading
+  [+] Added procedure TJvDBHTLabel.SetAutoSize(Value: Boolean); override;
+      It doesn't allow setting AutoSize to true
 -----------------------------------------------------------------------------}
 // $Id$
 
@@ -37,7 +52,7 @@
   {$IFDEF UNITVERSIONING}
   JclUnitVersioning,
   {$ENDIF UNITVERSIONING}
-  Classes, DB, DBCtrls,
+  Classes, DB, DBCtrls, Messages, Controls, VDBConsts,
   JvHTControls;
 
 type
@@ -49,7 +64,13 @@
     procedure SetDataSource(const Value: TDataSource);
     procedure DataChange(Sender: TObject);
     procedure SetMask(const Value: string);
+    procedure CMGetDataLink(var Message: TMessage); message CM_GETDATALINK;
   protected
+    function GetLabelText: string; override;
+    procedure Loaded; override;
+    procedure Notification(AComponent: TComponent;
+      Operation: TOperation); override;
+    procedure SetAutoSize(Value: Boolean); override;
   public
     constructor Create(AOwner: TComponent); override;
     destructor Destroy; override;
@@ -181,9 +202,15 @@
 
 //=== { TJvDBHTLabel } =======================================================
 
+procedure TJvDBHTLabel.CMGetDataLink(var Message: TMessage);
+begin
+  Message.Result := Integer(FDataLink);
+end;
+
 constructor TJvDBHTLabel.Create(AOwner: TComponent);
 begin
   inherited Create(AOwner);
+  AutoSize:=false;
   FDataLink := TFieldDataLink.Create;
   with FDataLink do
   begin
@@ -214,6 +241,42 @@
   Result := FDataLink.DataSource;
 end;
 
+function TJvDBHTLabel.GetLabelText: string;
+begin
+  if csPaintCopy in ControlState then
+  begin
+    if (Assigned(FDataLink) and Assigned(FDataLink.DataSet)) then
+      Result := ReplaceFieldNameTag(FMask, FDataLink.DataSet)
+    else
+      Result := ReplaceFieldNameTag(Mask, nil);
+  end
+  else
+    Result := Caption;
+end;
+
+procedure TJvDBHTLabel.Loaded;
+begin
+  inherited Loaded;
+  if (csDesigning in ComponentState) then DataChange(Self);
+end;
+
+procedure TJvDBHTLabel.Notification(AComponent: TComponent; Operation: TOperation);
+begin
+  inherited Notification(AComponent, Operation);
+  if (Operation = opRemove) and (FDataLink <> nil) and
+    (AComponent = DataSource) then
+    DataSource := nil;
+end;
+
+procedure TJvDBHTLabel.SetAutoSize(Value: Boolean);
+begin
+  if AutoSize <> Value then
+  begin
+    if Value and FDataLink.DataSourceFixed then DatabaseError(SDataSourceFixed);
+    inherited SetAutoSize(Value);
+  end;
+end;
+
 procedure TJvDBHTLabel.SetDataSource(const Value: TDataSource);
 begin
   FDataLink.DataSource := Value;
Index: JvHtControls.pas
===================================================================
--- JvHtControls.pas	(revision 10857)
+++ JvHtControls.pas	(working copy)
@@ -34,6 +34,12 @@
 
 Changes:
 ========
+Werewolf
+  2006-08-01
+  [*] procedure TJvCustomHTLabel.Paint was changed to use
+      virtual function TCustomLabel.GetLabelText: string;
+      that can be overriden by descendents
+      (used by TJvDBHTLabel to display correct label caption on TDBCtrlGrid)
 Peter Thornqvist:
   2004-01-279
     + Moved implementations to TJvCustomXXX classed
@@ -835,8 +841,8 @@
 begin
   if AutoSize then
   begin
-    Height := ItemHTHeight(Canvas, Caption);
-    Width := ItemHTWidth(Canvas, ClientRect, [], Caption) + 2;
+    Height := ItemHTHeight(Canvas, GetLabelText);
+    Width := ItemHTWidth(Canvas, ClientRect, [], GetLabelText) + 2;
   end;
   Invalidate;
 end;
@@ -890,8 +896,8 @@
     try
       Canvas.Handle := DC;
       Canvas.Font.Assign(Font);
-      Rect.Bottom := ItemHTHeight(Canvas, Caption);
-      MaxWidth := ItemHTWidth(Canvas, Bounds(0, 0, 0, 0), [], Caption);
+      Rect.Bottom := ItemHTHeight(Canvas, GetLabelText);
+      MaxWidth := ItemHTWidth(Canvas, Bounds(0, 0, 0, 0), [], GetLabelText);
     finally
       Canvas.Handle := 0;
       ReleaseDC(HWND_DESKTOP, DC);
@@ -899,8 +905,8 @@
     {$ENDIF VCL}
     {$IFDEF VisualCLX}
     Canvas.Font.Assign(Font);
-    Rect.Bottom := ItemHTHeight(Canvas, Caption);
-    MaxWidth := ItemHTWidth(Canvas, Bounds(0, 0, 0, 0), [], Caption) + 2;
+    Rect.Bottom := ItemHTHeight(Canvas, GetLabelText);
+    MaxWidth := ItemHTWidth(Canvas, Bounds(0, 0, 0, 0), [], GetLabelText) + 2;
     {$ENDIF VisualCLX}
     Rect.Right := Rect.Left + MaxWidth;
     X := Left;
@@ -922,7 +928,9 @@
 procedure TJvCustomHTLabel.Paint;
 var
   Rect: TRect;
+  PaintText: String;
 begin
+  PaintText:=GetLabelText;
   Canvas.Font := Font;
   Canvas.Brush.Color := Color;
   if Transparent then
@@ -935,22 +943,22 @@
     tlTop:
       ;
     tlBottom:
-      Rect.Top := Rect.Bottom - ItemHTHeight(Canvas, Caption);
+      Rect.Top := Rect.Bottom - ItemHTHeight(Canvas, PaintText);
     tlCenter:
-      Rect.Top := (Rect.Bottom - Rect.Top - ItemHTHeight(Canvas, Caption)) div 2;
+      Rect.Top := (Rect.Bottom - Rect.Top - ItemHTHeight(Canvas, PaintText)) div 2;
   end;
   Canvas.Font.Style := []; // only font name and font size is important
   if not Enabled then
   begin
     OffsetRect(Rect, 1, 1);
     Canvas.Font.Color := clBtnHighlight;
-    ItemHTDraw(Canvas, Rect, [odDisabled], Caption);
+    ItemHTDraw(Canvas, Rect, [odDisabled], PaintText);
     OffsetRect(Rect, -1, -1);
     Canvas.Font.Color := clBtnShadow;
-    ItemHTDraw(Canvas, Rect, [odDisabled], Caption);
+    ItemHTDraw(Canvas, Rect, [odDisabled], PaintText);
   end
   else
-    ItemHTDraw(Canvas, Rect, [], Caption);
+    ItemHTDraw(Canvas, Rect, [], PaintText);
 end;
 
 procedure TJvCustomHTLabel.MouseMove(Shift: TShiftState; X, Y: Integer);
@@ -964,11 +972,11 @@
     tlTop:
       ;
     tlBottom:
-      R.Top := R.Bottom - ItemHTHeight(Canvas, Caption);
+      R.Top := R.Bottom - ItemHTHeight(Canvas, GetLabelText);
     tlCenter:
-      R.Top := (R.Bottom - R.Top - ItemHTHeight(Canvas, Caption)) div 2;
+      R.Top := (R.Bottom - R.Top - ItemHTHeight(Canvas, GetLabelText)) div 2;
   end;
-  if IsHyperLink(Canvas, R, Caption, X, Y, LinkName) then
+  if IsHyperLink(Canvas, R, GetLabelText, X, Y, LinkName) then
     Cursor := crHandPoint
   else
     Cursor := crDefault;
@@ -986,11 +994,11 @@
     tlTop:
       ;
     tlBottom:
-      R.Top := R.Bottom - ItemHTHeight(Canvas, Caption);
+      R.Top := R.Bottom - ItemHTHeight(Canvas, GetLabelText);
     tlCenter:
-      R.Top := (R.Bottom - R.Top - ItemHTHeight(Canvas, Caption)) div 2;
+      R.Top := (R.Bottom - R.Top - ItemHTHeight(Canvas, GetLabelText)) div 2;
   end;
-  if IsHyperLink(Canvas, R, Caption, X, Y, LinkName) then
+  if IsHyperLink(Canvas, R, GetLabelText, X, Y, LinkName) then
   begin
     if (Pos(cURLTYPE, LinkName) > 0) or // ftp:// http:// e2k://
        (Pos(cMAILTO, UpperCase(LinkName)) > 0) then // ex: mailto:name@server.com
