Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combining multiple controls within one VCL....

Status
Not open for further replies.

rcloutie

Programmer
May 26, 2005
164
CA
Hi there,

I would like to (in my dreams) combining a ListBox and a BitBtn in one VCL. That is, I want to add a 'Caption' property to a ListBox which will looks like as a StringGrid's Column (FixedRow).

The main problem I see is to play with ListBox.Top to reserve the BitBtn.Height if Caption <> ''...

Anyone heard about similar thing? For myself, someone (from this forum) advices on a TLabelEdit VCL... But I couldn't find it...

Thank you all for reading my thoughts...

Have a nice day
 
TLabelEdit can be found in the last tabs in Delphi 7 version.It is a combination TLabel above TEdit in one component.
About you problem, try to be more specific. I can not understand the exact problem you have.
 
Which last tab?

Here's again what I want to build:

Combining a ListBox and a BitBtn in one VCL. That is, I want to add a 'Caption' property to a ListBox which will looks like as a StringGrid's Column (FixedRow).

So a BitBtn will be top aligned which is visible if Caption<>''; if Caption='' then it's the ListBox that will be top aligned and BitBtn invisible.

The main problem I see is to play with ListBox.Top to reserve the BitBtn.Height if Caption <> ''...
-------------------------------
if Caption<>'' then
begin
BitBtn.Visible := True;
BitBtn.Top:=0;
ListBox.Top:=BitBtn.Height;
ListBox.Height:=ListBox.Height-BitBtn.Height;
end

else if Caption='' then
begin
BitBtn.Visible := False;
ListBox.Top:=0;
ListBox.Height:=ListBox.Height+BitBtn.Height;
end;
-------------------------------

An option is to have a TPanel as a parent in which
BitBtn.Align:=alTop;
ListBox.Align:=alClient;

Any idea? or even better sample source code?
 
As you mentioned easiest way is probably to have a TPanel which contains both the bitbtn and the listbox aligned as you mentioned.


Code:
unit PanelList;

interface

uses
  Windows, Messages, SysUtils, Classes, Controls, ExtCtrls, StdCtrls,Buttons;

type
  TPanelList = class(TPanel)
  private
         fHead:TBitBtn;
         fList:TListBox;

         function GetShowCaption:Boolean;
         procedure SetShowCaption(bVal:Boolean);

  public
        constructor Create(aOwner:TComponent); override;

  published
        property Head:TBitBtn read fHead write fHead;
        property List:TListBox read fList write fList;
        property ShowCaption:Boolean read GetShowCaption write SetShowCaption;
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('Samples', [TPanelList]);
end;

constructor TPanelList.Create(aOwner:TComponent);
begin
    inherited;
    fHead:=TBitBtn.Create(self);
    fList:=TListBox.Create(self);

    fHead.Parent:=self;
    fList.Parent:=self;

    fHead.Align:=alTop;
    fList.Align:=alClient;

    fHead.Top:=0;
    fHead.Left:=0;
    fHead.Height:=24;
    fList.Top:=fHead.Height;
end;

procedure TPanelList.SetShowCaption(bVal:Boolean);
begin
    fHead.Visible:=bVal;
end;

function TPanelList.GetShowCaption:Boolean;
begin
     result:=fHead.Visible;
end;

end.

"It is in our collective behaviour that we are most mysterious" Lewis Thomas
 
If my VCL descends from TPanel, how can I access all members of TListBox directly (i.e. MyList.Items instead of MyList.List.Item)?

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top