Strange ComboBox behavior (Windows)
Original Reporter info from Mantis: RolfW @Rolf_Wetjen
-
Reporter name: Rolf Wetjen
Original Reporter info from Mantis: RolfW @Rolf_Wetjen
- Reporter name: Rolf Wetjen
Description:
There are two issues with a ComboBox (csDropDown) control in Windows:
-
ComboBox.AutoSelect:=false isn't working. I seems that Windows always selects the whole ComboBox.Text at activation of the control.
-
Changing the ComboBox.Font (.Style, .Size or .Color) overwrites the ComboBox.Text with the first matching item of ComboBox.Items.
Look at this code:
procedure TForm1.SpeedButtonTestClick (Sender: TObject);
var
fs: TFontStyles;
begin
ComboBox1.Clear;
ComboBox1.AddItem('Item0',nil);
ComboBox1.AddItem('TestItem1',nil);
ComboBox1.AddItem('Item2',nil);
ComboBox1.Text:='Test';
fs:=ComboBox1.Font.Style;
if fsBold in fs then
fs:=fs-[fsBold]
else
fs:=fs+[fsBold];
ComboBox1.Font.Style:=fs; // Changes ComboBox1.Text to 'TestItem1'
end;
ComboBox1.Text is set to 'TestItem1'.
I'm quite sure that this is a Windows issue and doesn't occur with Linux althought I can't test this.
Additional information:
I've attached a demo and a patch for both issues for win32wsstdctrls.pp.
The ComboBox will behave in the same way as an Edit control for AutoSelect=false (Mouse and Keyboard activation).
The ComboBox.Text (and the cursor position) will not be changed at changes to the font.
Mantis conversion info:
- Mantis ID: 33313
- OS: Windows 10 x64
- Build: 57415
- Platform: Windows
- Version: 1.9 (SVN)