?
Solved

OkBottomDlg in custom component

Posted on 2007-08-10
6
Medium Priority
?
650 Views
Last Modified: 2013-11-05
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.
0
Comment
Question by:rkamarowski
  • 3
  • 2
6 Comments
 
LVL 19

Expert Comment

by:MerijnB
ID: 19672333
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
 

Author Comment

by:rkamarowski
ID: 19672387
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
 
LVL 10

Expert Comment

by:dinilud
ID: 19675086
By viewing your code i assume that TOKBottomDlg not a component.
i think TOKBottomDlg is a Form.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:rkamarowski
ID: 19676042
so is it possible to include this in my component?
0
 
LVL 10

Accepted Solution

by:
dinilud earned 750 total points
ID: 19684833
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
 

Author Comment

by:rkamarowski
ID: 19685896
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

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question