|
@@ -29,7 +29,6 @@ type
|
|
|
published
|
|
published
|
|
|
property Button: TBCButton read FButton write FButton;
|
|
property Button: TBCButton read FButton write FButton;
|
|
|
property ListBox: TListBox read FListBox write FListBox;
|
|
property ListBox: TListBox read FListBox write FListBox;
|
|
|
- property Form: TForm read FForm write FForm;
|
|
|
|
|
property Items: TStrings read GetItems write SetItems;
|
|
property Items: TStrings read GetItems write SetItems;
|
|
|
end;
|
|
end;
|
|
|
|
|
|
|
@@ -48,14 +47,27 @@ procedure TBCComboBox.ButtonClick(Sender: TObject);
|
|
|
var
|
|
var
|
|
|
p: TPoint;
|
|
p: TPoint;
|
|
|
begin
|
|
begin
|
|
|
|
|
+ if Assigned(FForm) then
|
|
|
|
|
+ begin
|
|
|
|
|
+ FreeAndNil(FForm);
|
|
|
|
|
+ Exit;
|
|
|
|
|
+ end;
|
|
|
|
|
+
|
|
|
p := ControlToScreen(Point(FButton.Left, FButton.Top + FButton.Height));
|
|
p := ControlToScreen(Point(FButton.Left, FButton.Top + FButton.Height));
|
|
|
|
|
+
|
|
|
|
|
+ FForm := TForm.Create(Self);
|
|
|
|
|
+ FForm.Visible := False;
|
|
|
|
|
+ FForm.FormStyle := fsStayOnTop;
|
|
|
|
|
+ FForm.BorderStyle := bsNone;
|
|
|
|
|
+ FForm.AutoSize := True;
|
|
|
FForm.Left := p.X;
|
|
FForm.Left := p.X;
|
|
|
FForm.Top := p.Y;
|
|
FForm.Top := p.Y;
|
|
|
- FForm.Visible := not FForm.Visible;
|
|
|
|
|
- if FForm.Visible and FListBox.CanSetFocus then
|
|
|
|
|
|
|
+ FListBox.Parent := FForm;
|
|
|
|
|
+
|
|
|
|
|
+ if FListBox.CanSetFocus then
|
|
|
FListBox.SetFocus;
|
|
FListBox.SetFocus;
|
|
|
- if FForm.Visible then
|
|
|
|
|
- FForm.Constraints.MinWidth := FButton.Width;
|
|
|
|
|
|
|
+ FForm.Constraints.MinWidth := FButton.Width;
|
|
|
|
|
+ FForm.Visible := True;
|
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
function TBCComboBox.GetItems: TStrings;
|
|
function TBCComboBox.GetItems: TStrings;
|
|
@@ -65,7 +77,7 @@ end;
|
|
|
|
|
|
|
|
procedure TBCComboBox.ListBoxClick(Sender: TObject);
|
|
procedure TBCComboBox.ListBoxClick(Sender: TObject);
|
|
|
begin
|
|
begin
|
|
|
- FForm.Visible := False;
|
|
|
|
|
|
|
+ FreeAndNil(FForm);
|
|
|
FButton.Caption := FListBox.Items[FListBox.ItemIndex];
|
|
FButton.Caption := FListBox.Items[FListBox.ItemIndex];
|
|
|
end;
|
|
end;
|
|
|
|
|
|
|
@@ -88,12 +100,6 @@ begin
|
|
|
FButton.OnClick := ButtonClick;
|
|
FButton.OnClick := ButtonClick;
|
|
|
FButton.DropDownArrow := True;
|
|
FButton.DropDownArrow := True;
|
|
|
|
|
|
|
|
- FForm := TForm.Create(Self);
|
|
|
|
|
- FForm.Visible := False;
|
|
|
|
|
- FForm.FormStyle := fsStayOnTop;
|
|
|
|
|
- FForm.BorderStyle := bsNone;
|
|
|
|
|
- FForm.AutoSize := True;
|
|
|
|
|
-
|
|
|
|
|
FListBox := TListBox.Create(FForm);
|
|
FListBox := TListBox.Create(FForm);
|
|
|
FListBox.Align := alClient;
|
|
FListBox.Align := alClient;
|
|
|
FListBox.Parent := FForm;
|
|
FListBox.Parent := FForm;
|