Title: Drive DirList FileList Combo
Question: Save Coding / Configuration time with Drive combo, DirList, FileList and an EditContol to show the current file.
Answer:
I have placed the TDriveComboBox, TDirListBox and TFileListBox along with an TEdit contol on left and right TPanels and all these controls arranged in a userfreindly manner to save configuration time. The embeded controls are declared as public to enable accessiing individual controls as needed.
Click on the Edit control (at the bottom) to get focus to the control during design. Even to move around hold the mouse down on the Edit cotrol at the bottom.
Though a bit tricky to handle at design time easy to use. This installs in 'Sample' pallette.
Let me add splitters in next version.
Follow the usual procedure to install the component.
//============================================================================
unit Dir_FileList;
interface
uses
Windows, Messages, SysUtils, Classes, Controls, ExtCtrls, FileCtrl,stdCtrls;
type
TDir_FileList = class(TPanel)
private
{ Private declarations }
protected
{ Protected declarations }
procedure Dir_FileList1Resize(Sender: TObject);
procedure DC_FileListBox1Change(Sender: TObject);
public
{ Public declarations }
pnlLeft,pnlRight : TPanel ;
constructor Create(AOwner: TComponent); override;
published
{ Published declarations }
DC_DirCombo : TDriveComboBox ;
DC_DirList : TDirectoryListBox;
DC_FileListBox : TFileListBox;
DC_Edit : TEdit;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Samples', [TDir_FileList]);
end;
constructor TDir_FileList.Create(AOwner: TComponent);
begin
inherited;
width := 300 ;
Height := 300 ;
OnResize := Dir_FileList1Resize;
DC_DirCombo := TDriveComboBox.Create(pnlLeft) ;
DC_DirList := TDirectoryListBox.Create(pnlLeft);
DC_FileListBox := TFileListBox.Create(pnlRight);
DC_Edit := TEdit.create(self);
with DC_Edit do
begin
Parent := Self;
Align := alBottom;
end;
pnlLeft := TPanel.create(Self) ;
with pnlLeft do
begin
Parent := self;
Align := alLeft ;
width := Self.Width div 2 ;
end;
with DC_DirCombo do
begin
Parent := pnlLeft ;
Align := alTop;
DirList := DC_DirList ;
end;
with DC_DirList do
begin
Parent := pnlLeft ;
Align := alClient ;
FileList := DC_FileListBox ;
end;
pnlRight := TPanel.create(Self) ;
with pnlRight do
begin
Parent := self;
Align := alClient ;
end;
with DC_FileListBox do
begin
Parent := pnlRight ;
Align := alClient ;
OnChange := DC_FileListBox1Change ;
end;
end;
procedure TDir_FileList.DC_FileListBox1Change(Sender: TObject);
begin
DC_Edit.Text := DC_FileListBox.FileName ;
end;
procedure TDir_FileList.Dir_FileList1Resize(Sender: TObject);
begin
pnlLeft.width := Self.Width div 2 ;
end;
end.