OkBottomDlg in custom component

i have created a component from class TPanel.  i'd like to add a TOkBottomDlg that lists entries from a ListBox.  I can create the OkBottomDlg, but how do i attach a listbox to reference?
thanks
bob k.
rkamarowskiAsked:
Who is Participating?
 
diniludConnect With a Mentor Commented:
i think this way we can Impliment your Form as a component.
Here the model results are importent.

i didn't check this. This is only One Outline. You have to modify this to achive your goal.



unit Mycomponent1;

interface

uses
  SysUtils, Classes;

type
  tMycomponent1 = class(TComponent)
  private
    { Private declarations }
    FMyList:TStringList;
    FSelectIndex:String;
    procedure SetMyList(Value:TStrings);
    Function GetMyList:TStrings;

  protected
    { Protected declarations }
    Function Execute:Boolean;
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
    { Public declarations }

  published
    { Published declarations }
  end;

procedure Register;

implementation

//uses kmpdRoutineDlg;

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

Function tMycomponent1.Execute:Boolean;
var Dlg:TdlgRoutines;
begin
   try
     Dlg:=TdlgRoutines.create(application);
     Dlg.ListBox1.assign(FMyList);
     result :=Dlg.Showmodel<>mrOK;    // Ok button have a model result
     FSelectIndex:=Dlg.ListBox1.selectedIndex;
   finally
     Dlg.free
   end;
end

constructor tMycomponent1.Create(AOwner: TComponent);
begin
   inherited Create(AOwner);
   FMyList :=TStringList.Create;
end;

destructor tMycomponent1.Destroy;
begin
   FMyList.free;
   inherited Destroy;
end;

procedure tMycomponent1.SetMyList(Value:TStrings);
begin
  FMyList.Assign(Value);
end;

Function tMycomponent1.GetMyList:TStrings;
begin
   Result :=FMyList;
end;

end.
0
 
MerijnBSr. Software EngineerCommented:
please collaborate, I'm not sure what you want to achieve.
What is a TOkBottomDlg? And what do you mean with "attach a listbox to reference"?
0
 
rkamarowskiAuthor Commented:
an OKBottomDlg is a type of dialog box.  here's code i have from another pas file that may give you and idea.

=============
unit kmpdRoutineDlg;

interface
uses Windows, SysUtils, Classes, Graphics, Forms, Controls, StdCtrls,
  Buttons, ExtCtrls, okcancl1, kmpdMain;

type
  TdlgRoutines = class(TOKBottomDlg)
    HelpBtn: TButton;
    ListBox1: TListBox;
    procedure HelpBtnClick(Sender: TObject);
    procedure OKBtnClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  dlgRoutines: TdlgRoutines;

implementation

{$R *.DFM}

procedure TdlgRoutines.HelpBtnClick(Sender: TObject);
begin
  Application.HelpContext(HelpContext);
end;

procedure TdlgRoutines.OKBtnClick(Sender: TObject);
var
  index:   integer;
begin
  inherited;
  index:=ListBox1.ItemIndex;
  if index<0 then exit;
  kmpdRtn.Name:=ListBox1.Items[index];
end;
end.
================

this would allow me to reference the dialog box by dlgRoutine.ListBox1.items...

i'm unable to add this code to a custom component i'm creating in delphi.
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
diniludCommented:
By viewing your code i assume that TOKBottomDlg not a component.
i think TOKBottomDlg is a Form.
0
 
rkamarowskiAuthor Commented:
so is it possible to include this in my component?
0
 
rkamarowskiAuthor Commented:
thanks dinilud.  i was looking at your code and it dawned on me i could just a use a combobox on the component.

thanks for your help.

bob k.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.