The slider or thumb that usually appears to the right of the combobox. However, I just noticed up/down arrows appearing at the top and bottom of the control, when I click on it.
So, it appears to be working, but not as I expected.
Pic1 shows the initial appearance,
Pic2 shows the appearance when first selected,
Pic3 shows the appearance when an item is selected.
Pic2 is the one that now puzzles me. I can see no reason for the blank items at the top. I would appreciate any comments that help me correct the blank items in Pic2.
The code is:
Procedure TfrmMainScreen.cbSymbolsDrawItem(Control: TWinControl;
Index: Integer; ARect: TRect; State: TOwnerDrawState);
var
ComboBox: TComboBox;
symBitmap: TBitmap;
begin
ComboBox := (Control as TComboBox);
symBitmap := TBitmap.Create;
try
symBitmap.LoadFromLazarusResource(MySymbols[index]);
with ComboBox.Canvas do
begin
ARect := Bounds(ARect.Left, Arect.Top, Arect.Left + 50, Arect.Top + 15);
FillRect(ARect);
if symBitmap.Handle <> 0 then Draw(ARect.Left, ARect.Top, symBitmap);
end;
finally
symBitmap.Free;
end;
End;
The initialization is:
MySymbols := TStringList.Create;
MySymbols.Add('linessquares');
MySymbols.Add('linescircles');
MySymbols.Add('line');
MySymbols.Add('squares');
MySymbols.Add('circles');
MySymbols.Add('points');
{$I ../WindSirf64/WindSirf64.lrs}
The MySymbols string list is freed when the form is closed.
Edit: The FormActivate event should, I believe, clear the combobox items.
Procedure TfrmMainScreen.FormActivate(Sender: TObject);
Var
I: Integer;
Begin
cbSymbols.Clear;
For I := 0 To 5 Do
cbSymbols.Items.Add('');
cbSymbols.ItemIndex := 0;
End;