How to find out the index of a combo box item by name using WinAPI in Delphi?
-
07-07-2021 - |
Вопрос
I have a Delphi application A, which needs to select a certain item in a combo box of another Delphi application B.
A knows the text of the combo box item to select.
In order to select the combo box item, application A needs to know the index of the item in the combo box.
How can I figure out the index of a combo box item, when I only know its text?
Решение
procedure TForm1.Button1Click(Sender: TObject);
var
SItem: string;
begin
SItem := 'Beta';
Caption := IntToStr(SendMessage(ComboBox1.Handle, CB_FINDSTRINGEXACT,
-1, LPARAM(PChar(SItem))));
end;
(uses CommCtrl
).
Не связан с StackOverflow