Delphi Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreDelphi Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 30th, 2003, 06:26 PM
lloydie-t lloydie-t is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: May 2002
Location: UK
Posts: 563 lloydie-t User rank is Private First Class (20 - 50 Reputation Level)lloydie-t User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Day 23 h 54 m 22 sec
Reputation Power: 12
Problems with components on different forms

I have just started writing my first application in delphi and I am now stuck communicating between forms. I am using a serial port component TnrComms which has a main serial port component and a Device dropdown box component. I wish to select the dropdown box on a different form in the same project, but I don't know how to reference the main serial port component so that I can select that component in the object inspector. Have a look and point me in the right direction.

form 1
Code:
 unit datacollex;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Menus, ExtCtrls, ToolWin, ActnMan, ActnCtrls, StdCtrls, ComCtrls,
  nrclasses, nrcomm, dataport;

type
  TMainForm = class(TForm)
    MainMenu1: TMainMenu;
    File1: TMenuItem;
    A1: TMenuItem;
    Options1: TMenuItem;
    Options2: TMenuItem;
    Disconnect1: TMenuItem;
    Help1: TMenuItem;
    SerialPortSettings1: TMenuItem;
    Quit1: TMenuItem;
    Panel2: TPanel;
    ActionToolBar1: TActionToolBar;
    IncomingDataEdit: TRichEdit;
    Panel1: TPanel;
    OutgoingSQLEdit: TRichEdit;
    Panel3: TPanel;
    Panel4: TPanel;
    Panel5: TPanel;
    nrComm1: TnrComm; // this is the component
    SelectPort1: TMenuItem;
    procedure SelectPort1Click(Sender: TObject);
    procedure SerialPortSettings1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  MainForm: TMainForm;

implementation

{$R *.dfm}

procedure TMainForm.SelectPort1Click(Sender: TObject);
var dlg: TPortForm;
begin
dlg := TPortForm.Create( Self);
    dlg.ShowModal;
end;

procedure TMainForm.SerialPortSettings1Click(Sender: TObject);
begin
nrComm1.ConfigDialog;
end;

end.


Form 2
Code:
unit dataport;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Menus, ComCtrls, nrcomm, nrcommbox;

type
  TPortForm = class(TForm)
    MainMenu1: TMainMenu;
    File1: TMenuItem;
    Quit1: TMenuItem;
    PortOk: TButton;
    PortCancel: TButton;
    nrDeviceBox1: TnrDeviceBox; //this is the dropdown box
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  PortForm: TPortForm;

implementation

{$R *.dfm}

end.

Thanx

Last edited by lloydie-t : November 30th, 2003 at 06:29 PM.

Reply With Quote
  #2  
Old December 1st, 2003, 03:33 AM
M.Hirsch M.Hirsch is offline
Contributing User
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: Oct 2000
Location: Back in the real world.
Posts: 5,966 M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Month 2 Days 52 m 24 sec
Reputation Power: 189
Code:
procedure TMainForm.OnCreate(Sender: TObject);
begin
  nrComms1.assocDropdown:=Form2.nrDeviceBox;
end;

"assocDropdown" is the property name, the same like in the object inspector.
This should do it although I can not test it and I don't know your Delphi version either.
You have to set the form create order so that form2 will be created before form1 and connect the procedure above to the OnCreate handler of Form1.

hth,
M.
__________________
--
Manuel Hirsch - Linux, FreeBSD, programming, administration articles, tutorials and more.

Reply With Quote
  #3  
Old December 1st, 2003, 05:03 PM
lloydie-t lloydie-t is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: May 2002
Location: UK
Posts: 563 lloydie-t User rank is Private First Class (20 - 50 Reputation Level)lloydie-t User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Day 23 h 54 m 22 sec
Reputation Power: 12
Hi M,
I managed to sort it out I added datacollex to the uses of dataform and added dataform was put in the implementation uses to stop circular references and that seem to this problem out. I do need some more advise, but will start a new post.

Thanx

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreDelphi Programming > Problems with components on different forms

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap