
Originally Posted by
Bad Boy JH
Q1. Forms have a TComboBox, where you can select an item, or type one in, is there one which you can only select one?
Use the OnKeyDown Event.
PascalScript := FAIL;
so we don't get the ReadOnly property...
Simba Code:
program new;
procedure Pressed(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
DebugLn(IntToStr(Key));
if (not (InIntArray([8, 9, 13, 16, 17, 18, 37, 38, 39, 40, 46], Key))) then
Key := 0;
if ((Key = 8) or (Key = 46)) then
TComboBox(Sender).Text := '';
end;
procedure ShowForm;
var
I: integer;
begin
with TComboBox.Create(nil) do
try
Parent := TForm.Create(nil);
Top := 50;
Left := 50;
Sorted := True;
OnKeyDown := @Pressed;
for I := 1 to 25 do
Items.Add('Randomness ' + IntToStr(I));
with TForm(Parent) do
try
Width := 200;
Height := 125;
ShowModal;
finally
Free;
end;
finally
Free;
end;
end;
var
V: TVariantArray;
begin
ThreadSafeCall('ShowForm', V);
end.
E, E2: Updated Pressed Function