Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Report Control
  New Posts New Posts RSS Feed - Text Overflow
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Text Overflow

 Post Reply Post Reply
Author
Message
choochy View Drop Down
Groupie
Groupie
Avatar

Joined: 27 October 2006
Status: Offline
Points: 18
Post Options Post Options   Thanks (0) Thanks(0)   Quote choochy Quote  Post ReplyReply Direct Link To This Post Topic: Text Overflow
    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
Back to Top
Aaron View Drop Down
Senior Member
Senior Member
Avatar

Joined: 29 January 2008
Status: Offline
Points: 2192
Post Options Post Options   Thanks (0) Thanks(0)   Quote Aaron Quote  Post ReplyReply Direct Link To This Post 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 Wink

 
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....
Back to Top
jpbro View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 January 2007
Status: Offline
Points: 1355
Post Options Post Options   Thanks (0) Thanks(0)   Quote jpbro Quote  Post ReplyReply Direct Link To This Post 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

Back to Top
choochy View Drop Down
Groupie
Groupie
Avatar

Joined: 27 October 2006
Status: Offline
Points: 18
Post Options Post Options   Thanks (0) Thanks(0)   Quote choochy Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
jpbro View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 January 2007
Status: Offline
Points: 1355
Post Options Post Options   Thanks (0) Thanks(0)   Quote jpbro Quote  Post ReplyReply Direct Link To This Post 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, "&", "&amp;")
   p_PlainText = Replace$(p_PlainText, "<", "&lt;")
   p_PlainText = Replace$(p_PlainText, ">", "&gt;")
   p_PlainText = Replace$(p_PlainText, "'", "&apos;")
   p_PlainText = Replace$(p_PlainText, """", "&quot;")
   ' 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 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

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.156 seconds.