Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Report Control
  New Posts New Posts RSS Feed - [PARTIALLY SOLVED] BUG: BestFit and vbNewline
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

[PARTIALLY SOLVED] BUG: BestFit and vbNewline

 Post Reply Post Reply
Author
Message
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 Topic: [PARTIALLY SOLVED] BUG: BestFit and vbNewline
    Posted: 17 April 2009 at 10:04pm
When you call the BestFit method (or user double-clicks column separator) on a column with cells that contain vbNewline, the calculation includes the total length of all lines combined instead of the length of the longest individual line.
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3

Language: Visual Basic 6.0 SP6

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: 21 April 2009 at 5:10pm
Can I expect a fix for this in the next release?
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3

Language: Visual Basic 6.0 SP6

Back to Top
mdoubson View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post Posted: 27 January 2010 at 6:08pm
this is usual way DrawText make DT_CALRECT-base best fit
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: 28 January 2010 at 2:22pm
Then either DrawText is broken, or using DrawText to calc the text rect for strings that contain newline characters is not the correct approach. Newline characters break the text rendering onto multiple lines. If DrawText doesn't calculate the best fit width properly, then maybe the item text needs to be split on newline characters, and each line measured independently. The longest width found would be the best fit for the cell.
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3

Language: Visual Basic 6.0 SP6

Back to Top
mdoubson View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post Posted: 28 January 2010 at 2:53pm
DrawText complains should go to Microsoft I guess. In your case I think you can use markup with will keep extra CR/LF
Back to Top
mdoubson View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post Posted: 28 January 2010 at 3:05pm
Btw - this is Excel style of cell text draw
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: 28 January 2010 at 6:12pm
It's not so much a DrawText/MS complaint as a BestFit/Codejock RC complaint. The method is called BestFit, and it clearly doesn't calculate the best fit for the cell. If DrawText wasn't designed to handle newlines in its calculation routines, then it is the incorrect choice for calculating text for an object that supports newline characters. There are simple methods to calculate the best fit for plain text (one approach was mentioned above).

Other grids handle it fine (including VSFlexGrid OCX, OpenOffice.org Calc). And, contrary to what you claim, Excel 2007 calculates best fit with newlines properly too, so your statement about Excel is incorrect at least for contemporary versions of the program.

Excel 2007 after double-clicking the column divider (i.e. calculating best fit for column):



VSFlexGrid OCX using the AutoSize method (i.e. Calculating best fit for a column):





OpenOffice.org after double-clicking the column divider (i.e. calculating best fit for column):




Codejock ReportControl after calling BestFit on a column with RecordItems that have newline characters:


It's obvious which one is the odd man out, and which one is exhibiting unexpected behaviour. It seems excessive to have to add the overhead of Markup to an RC that otherwise doesn't require markup just to get expected best fit behaviour.
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3

Language: Visual Basic 6.0 SP6

Back to Top
mdoubson View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post Posted: 29 January 2010 at 12:25am
You right - need to fix this. Btw - I mean Excel 2003 of course.
Back to Top
mdoubson View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post Posted: 29 January 2010 at 2:11am
Back to Top
McKloony View Drop Down
Senior Member
Senior Member
Avatar

Joined: 09 January 2007
Location: Germany
Status: Offline
Points: 340
Post Options Post Options   Thanks (0) Thanks(0)   Quote McKloony Quote  Post ReplyReply Direct Link To This Post Posted: 29 January 2010 at 3:50am
Do you have also a Beta for CalendarControl?
Product: Xtreme SuitePro (ActiveX) 16.2.5

Platform: XP / Windows 7

Language: Visual Basic 6.0 SP6
Back to Top
mdoubson View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post Posted: 29 January 2010 at 9:23am
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: 30 January 2010 at 12:48pm
Sorry Mark, I didn't see the post with the rebuild - I've tested it and BestFit is performing nicely for all my tests so far, thank you very much.

A side note though - the algorithm that decides whether or not to show tooltip based on the width of the text isn't taking newlines into account, so the automatic tooltip is showing for multi-line items even when all the text appears within the cell boundaries. The automatic tooltip also displays newline characters as boxes instead of wrapping to a new line.

You can kind of work around this by setting the Tooltip property of the recorditem to the recorditem value. This tooltip supports newlines by rendering each line separately. The only issues with this method are that the tooltip always shows on mouse hover, and the tooltip doesn't show over the cell like the automatic tooltip does (it is tracked to the mouse pointer position instead of the cell boundaries).
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3

Language: Visual Basic 6.0 SP6

Back to Top
mdoubson View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post Posted: 30 January 2010 at 8:23pm
RIght - it should be next step - tooltip can be multilined
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: 26 February 2010 at 5:03pm
Will the tooltip be multi-line aware for the next release?

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.234 seconds.