lcl: fix checklistbox item height under win32 (wince?)

git-svn-id: trunk@15373 -
This commit is contained in:
paul 2008-06-10 01:19:42 +00:00
parent 7f7721db71
commit 31c5d5d91e
4 changed files with 40 additions and 12 deletions

View File

@ -65,6 +65,7 @@ type
procedure ItemClick(const AIndex: Integer); dynamic;
public
constructor Create(AOwner: TComponent); override;
procedure MeasureItem(Index: Integer; var TheHeight: Integer); override;
procedure Toggle(AIndex: Integer);
property AllowGrayed: Boolean read FAllowGrayed write FAllowGrayed default False;
@ -181,6 +182,27 @@ begin
FItemDataOffset := inherited GetCachedDataSize;
end;
procedure TCustomCheckListBox.MeasureItem(Index: Integer; var TheHeight: Integer);
var
B: TBitmap;
begin
if (Style = lbStandard) then
begin
// Paul: This will happen only once if Style = lbStandard then CheckListBox is
// OwnerDrawFixed in real (under windows). Handle is not allocated and we
// cant use Canvas since it will cause recursion but we need correct font height
B := TBitmap.Create;
try
B.Canvas.Font := Font;
TheHeight := B.Canvas.TextHeight('Fj');
finally
B.Free;
end;
end
else
inherited MeasureItem(Index, TheHeight);
end;
procedure TCustomCheckListBox.Toggle(AIndex: Integer);
const
NextStateMap: array[TCheckBoxState] of array[Boolean] of TCheckBoxState =

View File

@ -289,7 +289,7 @@ begin
begin
with TLMDrawItems(Message) do
begin
if Sender is TCheckListBox then
if Sender is TCustomCheckListBox then
begin
// ItemID not UINT(-1)
if DrawItemStruct^.ItemID <> DWORD($FFFFFFFF) then

View File

@ -572,13 +572,16 @@ begin
Flags := Flags or LBS_MULTIPLESEL;
if Columns > 1 then
Flags := Flags or LBS_MULTICOLUMN;
if AWinControl.FCompStyle = csCheckListBox then
if (AWinControl.FCompStyle = csCheckListBox) and (Style = lbStandard) then
Flags := Flags or LBS_OWNERDRAWFIXED
else case Style of
lbOwnerDrawFixed: Flags := Flags or LBS_OWNERDRAWFIXED;
lbOwnerDrawVariable: Flags := Flags or LBS_OWNERDRAWVARIABLE;
end;
if BorderStyle=bsSingle then
else
case Style of
lbOwnerDrawFixed: Flags := Flags or LBS_OWNERDRAWFIXED;
lbOwnerDrawVariable: Flags := Flags or LBS_OWNERDRAWVARIABLE;
end;
if BorderStyle = bsSingle then
FlagsEx := FlagsEx or WS_EX_CLIENTEDGE;
end;
pClassName := 'LISTBOX';

View File

@ -442,12 +442,15 @@ begin
Flags := Flags or LBS_MULTIPLESEL;
if Columns > 1 then
Flags := Flags or LBS_MULTICOLUMN;
if AWinControl.FCompStyle = csCheckListBox then
if (AWinControl.FCompStyle = csCheckListBox) and (Style = lbStandard) then
Flags := Flags or LBS_OWNERDRAWFIXED
else case Style of
lbOwnerDrawFixed: Flags := Flags or LBS_OWNERDRAWFIXED;
lbOwnerDrawVariable: Flags := Flags or LBS_OWNERDRAWVARIABLE;
end;
else
case Style of
lbOwnerDrawFixed: Flags := Flags or LBS_OWNERDRAWFIXED;
lbOwnerDrawVariable: Flags := Flags or LBS_OWNERDRAWVARIABLE;
end;
if BorderStyle=bsSingle then
FlagsEx := FlagsEx or WS_EX_CLIENTEDGE;
end;