[PARTIALLY SOLVED] BUG: BestFit and vbNewline |
Post Reply |
Author | |
jpbro
Senior Member Joined: 12 January 2007 Status: Offline Points: 1355 |
Post Options
Thanks(0)
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 |
|
jpbro
Senior Member Joined: 12 January 2007 Status: Offline Points: 1355 |
Post Options
Thanks(0)
|
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 |
|
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
this is usual way DrawText make DT_CALRECT-base best fit
|
|
jpbro
Senior Member Joined: 12 January 2007 Status: Offline Points: 1355 |
Post Options
Thanks(0)
|
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 |
|
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
DrawText complains should go to Microsoft I guess. In your case I think you can use markup with will keep extra CR/LF
|
|
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
Btw - this is Excel style of cell text draw
|
|
jpbro
Senior Member Joined: 12 January 2007 Status: Offline Points: 1355 |
Post Options
Thanks(0)
|
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 |
|
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
You right - need to fix this. Btw - I mean Excel 2003 of course.
|
|
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
Please try update: https://forum.codejock.com/uploads/BetaOCX/ReportControlBeta14.rar
|
|
McKloony
Senior Member Joined: 09 January 2007 Location: Germany Status: Offline Points: 340 |
Post Options
Thanks(0)
|
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 |
|
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
jpbro
Senior Member Joined: 12 January 2007 Status: Offline Points: 1355 |
Post Options
Thanks(0)
|
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 |
|
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
RIght - it should be next step - tooltip can be multilined
|
|
jpbro
Senior Member Joined: 12 January 2007 Status: Offline Points: 1355 |
Post Options
Thanks(0)
|
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 |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |