win32: implementing combobox readonly property

git-svn-id: branches/comboboxreadonly@63238 -
This commit is contained in:
dmitry 2020-05-28 12:54:25 +00:00
parent bc8507e6b6
commit dbeeed9c09

View File

@ -99,6 +99,7 @@ type
class procedure SetItemIndex(const ACustomComboBox: TCustomComboBox; NewIndex: integer); override;
class procedure SetMaxLength(const ACustomComboBox: TCustomComboBox; NewLength: integer); override;
class procedure SetStyle(const ACustomComboBox: TCustomComboBox; NewStyle: TComboBoxStyle); override;
class procedure SetReadOnly(const ACustomComboBox: TCustomComboBox; NewReadOnly: boolean); override;
class function GetItems(const ACustomComboBox: TCustomComboBox): TStrings; override;
class procedure Sort(const ACustomComboBox: TCustomComboBox; AList: TStrings; IsSorted: boolean); override;
@ -1058,6 +1059,20 @@ begin
RecreateWnd(ACustomComboBox);
end;
class procedure TWin32WSCustomComboBox.SetReadOnly(const ACustomComboBox: TCustomComboBox;
NewReadOnly: boolean);
var
Info: TComboboxInfo;
begin
if not ACustomComboBox.HandleAllocated then
Exit;
Info.cbSize := SizeOf(Info);
Win32Extra.GetComboBoxInfo(ACustomComboBox.Handle, @Info);
if (info.hwndItem<>0) and (info.hwndItem<>INVALID_HANDLE_VALUE) then
SendMessage(info.hwndItem, EM_SETREADONLY, WParam(NewReadOnly), 0);
end;
class function TWin32WSCustomComboBox.GetItemIndex(const ACustomComboBox: TCustomComboBox): integer;
begin
Result := SendMessage(ACustomComboBox.Handle, CB_GETCURSEL, 0, 0);