View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0004294 | JEDI VCL | 00 JVCL Components | public | 2007-11-14 03:57 | 2007-11-30 13:58 |
Reporter | bhe | Assigned To | AHUser | ||
Priority | normal | Severity | tweak | Reproducibility | always |
Status | resolved | Resolution | fixed | ||
Product Version | |||||
Target Version | Fixed in Version | 3.34 | |||
Summary | 0004294: Avoid dirty cast in TJvDockVSBlock.ResetActiveBlockWidth | ||||
Description | Solution w/o dirty cast could be: procedure TJvDockVSBlock.ResetActiveBlockWidth; var I: Integer; TextWidth: Integer; tHDC: HDC; tS: TSize; begin FActiveBlockWidth := 0; for I := 0 to VSPaneCount - 1 do begin // <(bhe)> tHDC := GetDC(VSChannel.Parent.Handle); try tS.cX := 0; tS.cY := 0; Windows.GetTextExtentPoint32(tHDC, PChar(VSPane[I].FDockForm.Caption), Length(VSPane[I].FDockForm.Caption), tS); TextWidth := tS.cx + InactiveBlockWidth + 10; finally ReleaseDC(VSChannel.Parent.Handle, tHDC); end; // </(bhe)> if TextWidth >= VSChannel.ActivePaneSize then begin FActiveBlockWidth := VSChannel.ActivePaneSize; Exit; end; FActiveBlockWidth := Max(FActiveBlockWidth, TextWidth); end; if FActiveBlockWidth = 0 then FActiveBlockWidth := VSChannel.ActivePaneSize; end; | ||||
Tags | No tags attached. | ||||
|
The GetDC does not garantee that the returned DC has the same font object selected, so the GetTextExtentPoint32 can return a wrong width. Furthermore the DC could be created outside of the for-loop what would make it faster. I have changed the code to use the is-operator before typecasting. In the case of a TCustomForm it typecasts using the valid cracker-typecast. If it can't typecast the parent, the VSChannel.ActivePaneSize will be used. |
Date Modified | Username | Field | Change |
---|---|---|---|
2007-11-14 03:57 | bhe | New Issue | |
2007-11-30 13:57 | AHUser | Status | new => resolved |
2007-11-30 13:57 | AHUser | Fixed in Version | => Daily / SVN |
2007-11-30 13:57 | AHUser | Resolution | open => fixed |
2007-11-30 13:57 | AHUser | Assigned To | => AHUser |
2007-11-30 13:57 | AHUser | Note Added: 0014036 |