Text Overflow
Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Report Control
Forum Description: Topics Related to Codejock Report Control
URL: http://forum.codejock.com/forum_posts.asp?TID=17693
Printed Date: 15 November 2024 at 7:26pm Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com
Topic: Text Overflow
Posted By: choochy
Subject: Text Overflow
Date Posted: 17 December 2010 at 2:45am
I have setup a Report Control with a number of columns. 3 of the columns contain text that is much larger then there is room for. A Fully Qualified Process Name is one of the example. Currently the data overflow is handled by the ReportControl displaying the first (left) part of the text and adding ... to signify overflow. Is there a way I can control how this is done? In this case I want to start the colum with the ... and then have the right hand side of the text displayed instead. As the most meaniful data is at the end. So it will go from C:\Windows\Sys.... to ...System32\some.dll Thanks
------------- Product: Xtreme SuitePro (ActiveX) version 13.4.2
Platform: Windows 7 (32bit)
Language: Visual Basic 6.0 & Delphi XE
|
Replies:
Posted By: Aaron
Date Posted: 17 December 2010 at 11:19am
Hi,
I know this a problem and always will be... But there is hope at least in your case
Add the Record items that need to be wrapped with Markup (and set wndReportControl.PaintManager.FixedRowHeight = False):
With .Records.Add With .AddItem("") .Caption = "<StackPanel Margin = '10'><TextBlock Padding='30,10,0,15' TextWrapping='Wrap' FontWeight='Bold'>C:\Program Files\Codejock Software\ActiveX\XtremeSuiteProActiveXv13.4.0\Help</TextBlock></StackPanel>" End With End With
Output:
------------- Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2
Language: Visual Basic 6.0
Zero replies is not an option....
|
Posted By: jpbro
Date Posted: 17 December 2010 at 12:51pm
You could also use the DrawText API with the DT_PATH_ELLIPSIS flag to get internal ellipsis if you don't want any wrapping.
It would be better if CJ added a PathEllipsis value for the TextTrimming attribute, then we wouldn't need the API.
Put a ReportControl (ReportControl1) on a form and try this:
Option Explicit
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Const DT_PATH_ELLIPSIS As Long = &H4000
Private Const DT_MODIFYSTRING As Long = &H10000
Private Const DT_CALCRECT As Long = &H400
Private Const DT_NOPREFIX As Long = &H800
Private Declare Function DrawText Lib "user32.dll" Alias "DrawTextA"
(ByVal hdc As Long, ByVal lpStr As String, ByVal nCount As Long, ByRef
lpRect As RECT, ByVal wFormat As Long) As Long
Private Sub Form_Load()
With Me.ReportControl1
.SetCustomDraw xtpCustomBeforeDrawRow
.Columns.Add .Columns.Count, "Test", 100, True
.Columns.Add .Columns.Count, "Test", 100, True
With .Records.Add
.AddItem "C:\Program Files\Program Something or other\SomeProgram.exe"
.AddItem ""
End With
.Populate
End With
End Sub
Private Sub ReportControl1_BeforeDrawRow(ByVal Row As
XtremeReportControl.IReportRow, ByVal Item As
XtremeReportControl.IReportRecordItem, ByVal Metrics As
XtremeReportControl.IReportRecordItemMetrics)
Dim lt_Rect As RECT
Dim l_Left As Long
Dim l_Top As Long
Dim l_Text As String
Dim l_Null As Long
Select Case Item.Index
Case 0 ' First Column
Row.GetItemRect Item, lt_Rect.Left, lt_Rect.Top, lt_Rect.Right, lt_Rect.Bottom
lt_Rect.Right = lt_Rect.Right - 8 ' Why this magic number?? Prevents ReportControl from adding its own end ellipsis
l_Text = Item.Value
DrawText Me.hdc, l_Text, -1, lt_Rect, DT_PATH_ELLIPSIS + DT_MODIFYSTRING + DT_CALCRECT + DT_NOPREFIX
l_Null = InStr(1, l_Text, vbNullChar) - 1
If l_Null >= 0 Then
l_Text = Left$(l_Text, l_Null)
End If
Metrics.Text = l_Text
End Select
End Sub
|
Output:
Questions for CJ:
1) Why do I need to use the magic number 8 to subtract from the Right value for the cell width in order to prevent your end ellipsis from showing? 2) Can we get a PathEllipsis value for the TextTrimming attribute in Markup?
------------- Product: Xtreme SuitePro (ActiveX) version 16.2.6 Platform: Windows XP - SP3
Language: Visual Basic 6.0 SP6
|
Posted By: choochy
Date Posted: 19 December 2010 at 8:47pm
Thanks guys for the replies! jpbro's solution is definitly what I was after. Its strange though the magic number on my system is actually bigger for me, I needed to put in 20 and even then occasionally it is still out. Anyone know why this is, or how to calculate this value properly?
------------- Product: Xtreme SuitePro (ActiveX) version 13.4.2
Platform: Windows 7 (32bit)
Language: Visual Basic 6.0 & Delphi XE
|
Posted By: jpbro
Date Posted: 22 December 2010 at 10:16am
Turns out that the ReportControl font was different than the Form font,
which accounts for most of the difference - however, I still have to use
a 5px magic number when the fonts are matched.
If I enclose the modified path in a XAML TextBlock tag, I get this down
to a 3px magic number (still a magic number, but getting closer!).
To anyone at Codejock - is this a problem with my code, or does the
GetItemRect method return values too large (not accounting for some kind
of internal margin). If this is a GetItemRect issue, maybe we need a
GetItemRectClient method that returns the values accounting for the
internal margin?
Anyway, here's the updated code:
Option Explicit
Private Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type
Private Const DT_PATH_ELLIPSIS As Long = &H4000 Private Const DT_MODIFYSTRING As Long = &H10000 Private Const DT_CALCRECT As Long = &H400 Private Const DT_NOPREFIX As Long = &H800
Private Declare Function DrawText Lib "user32.dll" Alias "DrawTextA" (ByVal hdc As Long, ByVal lpStr As String, ByVal nCount As Long, ByRef lpRect As RECT, ByVal wFormat As Long) As Long
Private Sub Form_Load() With Me.ReportControl1 .SetCustomDraw xtpCustomBeforeDrawRow .EnableMarkup = True ' Enable Markup .PaintManager.ForceDynamicMarkupForCell = True ' Make Metrics.Text render markup .Columns.Add .Columns.Count, "Test", 100, True .Columns.Add .Columns.Count, "Test", 100, True
With .Records.Add .AddItem "C:\Program Files\Program Something or other\SomeProgram.exe" .AddItem "" End With .Populate End With End Sub
Private Sub ReportControl1_BeforeDrawRow(ByVal Row As XtremeReportControl.IReportRow, ByVal Item As XtremeReportControl.IReportRecordItem, ByVal Metrics As XtremeReportControl.IReportRecordItemMetrics) Dim lt_Rect As RECT Dim l_Left As Long Dim l_Top As Long Dim l_Text As String Dim l_Null As Long Dim lo_OldFont As StdFont Select Case Item.Index Case 0 ' First Column Row.GetItemRect Item, lt_Rect.Left, lt_Rect.Top, lt_Rect.Right, lt_Rect.Bottom lt_Rect.Right = lt_Rect.Right - 3 ' Why this magic number?? Prevents ReportControl from adding its own end ellipsis
l_Text = Item.Value
Set lo_OldFont = Me.Font Set Me.Font = Me.ReportControl1.PaintManager.TextFont DrawText Me.hdc, l_Text, -1, lt_Rect, DT_PATH_ELLIPSIS + DT_MODIFYSTRING + DT_CALCRECT + DT_NOPREFIX Set Me.Font = lo_OldFont
l_Null = InStr(1, l_Text, vbNullChar) - 1 If l_Null >= 0 Then l_Text = Left$(l_Text, l_Null) End If
Metrics.Text = "<TextBlock TextTrimming='None'>" & EncodePlainTextForXaml(l_Text) & "</TextBlock>" End Select End Sub
Private Function EncodePlainTextForXaml(ByVal p_PlainText As String) As String ' Convert illegal characters to XAML entities p_PlainText = Replace$(p_PlainText, "&", "&") p_PlainText = Replace$(p_PlainText, "<", "<") p_PlainText = Replace$(p_PlainText, ">", ">") p_PlainText = Replace$(p_PlainText, "'", "'") p_PlainText = Replace$(p_PlainText, """", """) ' Normalize CRLF and CR to LF, then expand LF characters to XAML <LineBreak/> tags p_PlainText = Replace$(p_PlainText, vbNewLine, vbLf) p_PlainText = Replace$(p_PlainText, vbCr, vbLf) p_PlainText = Replace$(p_PlainText, vbLf, "<LineBreak/>") EncodePlainTextForXaml = p_PlainText End Function
|
Choochy - maybe you could open a support ticket at http://support.codejock.com - http://support.codejock.com to get to the bottom of this issue?
------------- Product: Xtreme SuitePro (ActiveX) version 16.2.6 Platform: Windows XP - SP3
Language: Visual Basic 6.0 SP6
|
|