View Issue Details

IDProjectCategoryView StatusLast Update
0003833JEDI VCL00 JVCL Componentspublic2007-01-03 12:52
ReporterWerewolfAssigned Toobones 
PrioritynormalSeveritytextReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.20 
Target VersionFixed in Version3.30 
Summary0003833: TJvDBHTLabel doesn't support painting on TDBCtrlGrid
DescriptionWhen you have TJvDBHTLabel on DBCtrlGrid in runtime it always paints last updated record on each DBCtrlGrid's panel.
TagsNo tags attached.

Activities

obones

2006-07-26 00:44

administrator   ~0009857

Please provide the zipped sources of a sample application showing the issue.

2006-07-26 01:19

 

TJvDBHTLabel.zip (378,812 bytes)

Werewolf

2006-07-26 01:19

reporter   ~0009862

sample application contains 2 forms
first form displays data of clientdataset in dbctrlgrid using TJvDBHTLabel
second form is a simple editor for clientdataset
by the way, when mask of TJvDBHTLabel ends with italic text width of label is calculated incorrectly.
To enable normal painting in DBCtrlGrid component must support different painting in dependence on flag csPaintCopy in ControlState while painting
sample:
-------------------------------------------------
type TMycomp = class(TLabel)
    procedure WMPaint(var Message: TWMPaint); message WM_PAINT;
......

procedure TMycomp.WMPaint(var Message: TWMPaint);
begin
  if not (csPaintCopy in ControlState) then inherited else
  begin
//here data must be taken from FDataLink and not from DataSet/DataSource
  end
----------------------------------------------------

also it can get datalink from dbctrlgrid by implementing code for CM_GETDATALINK message
sample:
----------------------------------------------------
type TMycomp= class(TLabel)
    FDataLink: TFieldDataLink;
    procedure CMGetDataLink(var Message: TMessage); message CM_GETDATALINK;

....

procedure TMycomp.CMGetDataLink(var Message: TMessage);
Begin
  Message.Result := Integer(FDataLink);
End;
---------------------------------------------------------------

Werewolf

2006-07-26 01:30

reporter   ~0009863

You can look how borland's TDBText component is implemented:
 TDBText = class(TCustomLabel)
  private
    FDataLink: TFieldDataLink;
    procedure DataChange(Sender: TObject);
-----------------------------
    function GetFieldText: string;
------------------------
    procedure CMGetDataLink(var Message: TMessage); message CM_GETDATALINK;
  protected
    function GetLabelText: string; override;//overriden - used in TCustomLabel.DoDrawText
-------------------------------------
function TDBText.GetFieldText: string;
begin
  if FDataLink.Field <> nil then
    Result := FDataLink.Field.DisplayText
  else
    if csDesigning in ComponentState then Result := Name else Result := '';
end;

procedure TDBText.DataChange(Sender: TObject);
begin
  Caption := GetFieldText;
end;

function TDBText.GetLabelText: string;
begin
  if csPaintCopy in ControlState then ////////////////////this is it
    Result := GetFieldText else
    Result := Caption;
end;

obones

2006-07-26 01:42

administrator   ~0009865

So what is your proposed change?

Werewolf

2006-07-26 07:02

reporter   ~0009868

changes to JvHtControls.pas procedure TJvCustomHTLabel.Paint
------------------------
procedure TJvCustomHTLabel.Paint;
var
  Rect: TRect;
  Text:string;
begin
  Text:=GetLabelText;
  Canvas.Font := Font;
  Canvas.Brush.Color := Color;
  if Transparent then
    Canvas.Brush.Style := bsClear
  else
    Canvas.Brush.Style := bsSolid;
  Canvas.FillRect(ClientRect);
  Rect := ClientRect;
  case Layout of
    tlTop:
      ;
    tlBottom:
      Rect.Top := Rect.Bottom - ItemHTHeight(Canvas, Text);
    tlCenter:
      Rect.Top := (Rect.Bottom - Rect.Top - ItemHTHeight(Canvas, Text)) 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], Text);
    OffsetRect(Rect, -1, -1);
    Canvas.Font.Color := clBtnShadow;
    ItemHTDraw(Canvas, Rect, [odDisabled], Text);
  end
  else
    ItemHTDraw(Canvas, Rect, [], Text);
end;
-----------------------------------------------
changes to JvDBHTLabel.pas methods added
----------------------
 TJvDBHTLabel = class(TJvCustomHTLabel)
private
........................
    procedure CMGetDataLink(var Message: TMessage); message CM_GETDATALINK;
  protected
    function GetLabelText: string; override;
    procedure Notification(AComponent: TComponent;
      Operation: TOperation); override;
......................
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.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.CMGetDataLink(var Message: TMessage);
begin
  Message.Result := Integer(FDataLink);
end;

Werewolf

2006-07-27 08:14

reporter   ~0009873

So, what's your opinion?

obones

2006-07-28 14:37

administrator   ~0009882

Please provide a diff file, that would be easier to read for me, and easier to integrate.

Werewolf

2006-07-31 01:59

reporter   ~0009918

With what tool do you want me to produce diff file?

obones

2006-07-31 02:32

administrator   ~0009919

diff -u 3 or with TortoiseSVN as described here:

http://homepages.borland.com/jedi/wiki/index.php?title=Create_a_patch_file

Werewolf

2006-08-01 02:00

reporter   ~0009929

Last edited: 2006-08-01 02:01

Give me a hint to configure TortoiseSVN correctly, pls.
(I don't see Create Patch in context menu...)

obones

2006-08-01 02:46

administrator   ~0009930

You must have checked out the SVN repository as indicated here:

http://homepages.borland.com/jedi/wiki/index.php?title=Repository

and applied your changes in the folder created by the above. Then you will be able to right click on the file and choose "Create Patch" from the Tortoise SVN subdirectory.

2006-08-01 06:59

 

patch.diff (7,600 bytes)
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
patch.diff (7,600 bytes)

Werewolf

2006-08-23 06:37

reporter   ~0010004

I've uploded diff
so whats your opinion

obones

2006-08-25 02:38

administrator   ~0010022

A few questions/remarks then:

- Why did you remove two lines of comment at the start?
- The list of changes are NOT to be added. On top of that some sentences are not even complete. This list is to be provided to us OUTSIDE of the unit file.
- What is this "VDBConst" unit?
- What is the point of DataSourceFixed in the overridden SetAutoSize?
- Please respect the coding guide standard. Especially, spaces around ":="

Until such time we get the answers and an updated diff file, this will stay in the "feedback" state.

Werewolf

2006-08-25 03:32

reporter   ~0010024

>A few questions/remarks then:

>- Why did you remove two lines of comment at the start?

Sorry, it was my first diff =)

>- The list of changes are NOT to be added. On top of that some sentences are >not even complete. This list is to be provided to us OUTSIDE of the unit file.

I'll post changes to issue.

>- What is this "VDBConst" unit?

It's unit that contains resourcestring SDataSourceFixed = 'Operation not allowed in a DBCtrlGrid'; in BDS4

>- What is the point of DataSourceFixed in the overridden SetAutoSize?

DataSourceFixed property of TDataLink indicates whether the DataSource property can be set.
DBCtrlGrid calls Control.Perform(CM_GETDATALINK, 0, 0) to get controls DataLink and Sets it's property DataSourceFixed to true.

So that control can be stil autosized when it's not on DBCtrlGrid
But when you have your control on DBCtrlGrid and set autosize to true DatabaseError(SDataSourceFixed) must be called. (to prevent autosize bug on DBCtrlGrid)

>- Please respect the coding guide standard. Especially, spaces around ":="
I'll do my best =)

>Until such time we get the answers and an updated diff file, this will stay in >the "feedback" state.

2006-08-25 03:51

 

jvHt.patch (3,551 bytes)
Index: JvDBHTLabel.pas
===================================================================
--- JvDBHTLabel.pas	(revision 10916)
+++ JvDBHTLabel.pas	(working copy)
@@ -49,7 +49,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,6 +187,11 @@
 
 //=== { TJvDBHTLabel } =======================================================
 
+procedure TJvDBHTLabel.CMGetDataLink(var Message: TMessage);
+begin
+  Message.Result := Integer(FDataLink);
+end;
+
 constructor TJvDBHTLabel.Create(AOwner: TComponent);
 begin
   inherited Create(AOwner);
@@ -214,6 +225,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;
+  if (csDesigning in ComponentState) then DataChange(Self);
+end;
+
+procedure TJvDBHTLabel.Notification(AComponent: TComponent; Operation: TOperation);
+begin
+  inherited;
+  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;
+  end;
+end;
+
 procedure TJvDBHTLabel.SetDataSource(const Value: TDataSource);
 begin
   FDataLink.DataSource := Value;
Index: JvHtControls.pas
===================================================================
--- JvHtControls.pas	(revision 10916)
+++ JvHtControls.pas	(working copy)
@@ -922,7 +922,9 @@
 procedure TJvCustomHTLabel.Paint;
 var
   Rect: TRect;
+  PaintText: String;
 begin
+  PaintText := GetLabelText;
   Canvas.Font := Font;
   Canvas.Brush.Color := Color;
   if Transparent then
@@ -935,22 +937,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);
jvHt.patch (3,551 bytes)

2006-08-28 00:42

 

jvHtnew.patch (3,752 bytes)
Index: JvDBHTLabel.pas
===================================================================
--- JvDBHTLabel.pas	(revision 10917)
+++ JvDBHTLabel.pas	(working copy)
@@ -37,7 +37,7 @@
   {$IFDEF UNITVERSIONING}
   JclUnitVersioning,
   {$ENDIF UNITVERSIONING}
-  Classes, DB, DBCtrls,
+  Classes, DB, DBCtrls, Messages, Controls, VDBConsts,
   JvHTControls;
 
 type
@@ -49,7 +49,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,6 +187,11 @@
 
 //=== { TJvDBHTLabel } =======================================================
 
+procedure TJvDBHTLabel.CMGetDataLink(var Message: TMessage);
+begin
+  Message.Result := Integer(FDataLink);
+end;
+
 constructor TJvDBHTLabel.Create(AOwner: TComponent);
 begin
   inherited Create(AOwner);
@@ -214,6 +225,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;
+  if (csDesigning in ComponentState) then DataChange(Self);
+end;
+
+procedure TJvDBHTLabel.Notification(AComponent: TComponent; Operation: TOperation);
+begin
+  inherited;
+  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;
+  end;
+end;
+
 procedure TJvDBHTLabel.SetDataSource(const Value: TDataSource);
 begin
   FDataLink.DataSource := Value;
Index: JvHtControls.pas
===================================================================
--- JvHtControls.pas	(revision 10917)
+++ JvHtControls.pas	(working copy)
@@ -922,7 +922,9 @@
 procedure TJvCustomHTLabel.Paint;
 var
   Rect: TRect;
+  PaintText: String;
 begin
+  PaintText := GetLabelText;
   Canvas.Font := Font;
   Canvas.Brush.Color := Color;
   if Transparent then
@@ -935,22 +937,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);
jvHtnew.patch (3,752 bytes)

obones

2006-08-28 10:40

administrator   ~0010032

I still don't understand the issue with AutoSize.
I might be dumb, but to me DataSourceFixed is related to the data, AutoSize is related to the user interface.
Why would the data related "fixness" have any impact on the size of the control?

Werewolf

2006-08-29 01:09

reporter   ~0010033

the Main reason to restrict autosize of TJVDBHTLabel on tdbctrlgrid is:
When you have TJVDBHTLabel on tdbctrlgrid and length of text that TJVDBHTLabel must paint differ from record to record then autosize feature will always return size for active record, but changes will be applied for all TJVDBHTLabel
so when we have records:
aaa
bbbbbbb
ccc
and when we select first or last record label that should display bbbbbbb shows only bbb;
so when you design controls on tdbctrlgrid autosize must be disabled and you must spesify the size you want in design time

and DataSourceFixed here is a flag that shows that control is on tdbctrlgrid

obones

2007-01-03 12:52

administrator   ~0010501

This is now fixed in SVN.

Issue History

Date Modified Username Field Change
2006-07-25 05:29 Werewolf New Issue
2006-07-26 00:44 obones Note Added: 0009857
2006-07-26 00:44 obones Status new => feedback
2006-07-26 01:19 Werewolf File Added: TJvDBHTLabel.zip
2006-07-26 01:19 Werewolf Note Added: 0009862
2006-07-26 01:30 Werewolf Note Added: 0009863
2006-07-26 01:42 obones Note Added: 0009865
2006-07-26 07:02 Werewolf Note Added: 0009868
2006-07-27 08:14 Werewolf Note Added: 0009873
2006-07-28 14:37 obones Note Added: 0009882
2006-07-31 01:59 Werewolf Note Added: 0009918
2006-07-31 02:32 obones Note Added: 0009919
2006-08-01 02:00 Werewolf Note Added: 0009929
2006-08-01 02:01 Werewolf Note Edited: 0009929
2006-08-01 02:46 obones Note Added: 0009930
2006-08-01 06:59 Werewolf File Added: patch.diff
2006-08-23 06:37 Werewolf Note Added: 0010004
2006-08-25 02:38 obones Note Added: 0010022
2006-08-25 03:32 Werewolf Note Added: 0010024
2006-08-25 03:51 Werewolf File Added: jvHt.patch
2006-08-28 00:42 Werewolf File Added: jvHtnew.patch
2006-08-28 10:40 obones Note Added: 0010032
2006-08-29 01:09 Werewolf Note Added: 0010033
2007-01-03 12:52 obones Status feedback => resolved
2007-01-03 12:52 obones Fixed in Version => Daily / SVN
2007-01-03 12:52 obones Resolution open => fixed
2007-01-03 12:52 obones Assigned To => obones
2007-01-03 12:52 obones Note Added: 0010501