View Issue Details

IDProjectCategoryView StatusLast Update
0004034JEDI VCL00 JVCL Componentspublic2007-06-19 08:11
ReportermartinalexAssigned Toobones 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionwon't fix 
Product VersionDaily / GIT 
Target VersionFixed in Version 
Summary0004034: JvgCheckListBox multi line error
DescriptionFor multiline display JvgCheckListBox works ok when I display data the first time with FormShow. For all data added later only the first line for each entry is shown. The data for e.g. a second line in one entry is there but the drawing rectangle is not high enough.


TJvgListBox.CNMeasureItem
In procedure TJvgListBox.CNMeasureItem the text height is calculated with
Windows function DrawText and DT_CALCRECT

There is already a workaround in place if DrawText returns zero height - use
14 then.

    Windows.DrawText(Canvas.Handle, PChar(Items[itemID]),
      Length(Items[itemID]), R, DT_CALCRECT or WordBreak[fboWordWrap in Options]);

    if R.Bottom = 0 then
      R.Bottom := 14

This workaround is ok only for single line items and for default font size 8
pt, otherwise the item field is not high enough.

DrawText ALWAYS returns ZERO when called after FormShow. I don't know why,
but I think the canvas handle is invalid.

My fix uses CreateCompatibleDC to have a valid device context. This DC is
used instead of Canvas.Handle. Now DrawText never returns zero height. Multi
line items or items with larger font are now displayed correctly.

Unfortunately the calculated height differs by +1 or +2 pixels per line to
the prior method, but all data is visible.



Var
  DC: HDC;

...

    DC := CreateCompatibleDC(0);
    Windows.DrawText(DC, PChar(Items[itemID]),
      Length(Items[itemID]), R, DT_CALCRECT or WordBreak[fboWordWrap in
Options]);
    DeleteDC(DC);


Fixed module attached


Martin

TagsNo tags attached.

Activities

2007-01-09 15:08

 

JvgListBox.pas (32,058 bytes)

obones

2007-01-27 14:15

administrator   ~0010681

The Globus components are progressively phased out (starting with TJvg) and you should not use them.
Please use components from other tabs. If they are lacking features from the Globus ones, please try to implement them and let us know.

martinalex

2007-02-14 03:59

reporter   ~0010811

For the moment the (fixed) TJvxCheckListBox is ok for me.

Which JVCL checkListBox is maintained in the future? I have found four others
TJvCheckListBox
TJvTextListBox
TJvxCheckListBox
TJvHTListBox

obones

2007-02-16 00:57

administrator   ~0010887

All of them, only the TJvg (notice the g at the end of the prefix) will be progressively phased out.
Shall I close this issue then?

martinalex

2007-02-24 13:36

reporter   ~0011160

Yes, can be closed

obones

2007-06-19 08:10

administrator   ~0013455

As indicated to original poster

Issue History

Date Modified Username Field Change
2007-01-09 15:08 martinalex New Issue
2007-01-09 15:08 martinalex File Added: JvgListBox.pas
2007-01-27 14:15 obones Note Added: 0010681
2007-01-27 14:15 obones Status new => feedback
2007-02-14 03:59 martinalex Note Added: 0010811
2007-02-16 00:57 obones Note Added: 0010887
2007-02-24 13:36 martinalex Note Added: 0011160
2007-06-19 08:10 obones Status feedback => resolved
2007-06-19 08:10 obones Resolution open => won't fix
2007-06-19 08:10 obones Assigned To => obones
2007-06-19 08:10 obones Note Added: 0013455