Solved

Unit 1 referencing Units2's component properties..

Posted on 2001-06-15
10
195 Views
Last Modified: 2010-04-06

OK..

Example.
I have 2 units in a project. (Dll)

Unit 1 is my main form.
Unit 2 is a small popup window.

From the code in unit1 I wish to display the form from unit2 and have access and the ability to controll the components and there property's from the unit2 form..

(If that makes sense)


Points will be increased for examples..

Thanks Madmarlin..

0
Comment
Question by:Madmarlin
  • 6
  • 4
10 Comments
 
LVL 13

Expert Comment

by:Epsylon
ID: 6194410
Put 'uses Unit2' in the uses clause of Unit1.

Then in Unit1 you can do:

Form2.Visible := true;
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 6194417
I see it a Dll. In that case Unit1 will look something like this:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, Unit2;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
    Form2: TForm2;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin
  Form2 := TForm2.Create(Self);
  Form2.Visible := true;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  Form2.Release;
end;

end.
0
 
LVL 1

Author Comment

by:Madmarlin
ID: 6194433

The comments posted would work but I gain an access violation when I try to alter the position property of a progress bar that sat on the Form from Unit2 from within the code in Unit1.

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.

 
LVL 13

Expert Comment

by:Epsylon
ID: 6194451
Are you modifying the progress bar while Form2 is active? You can not modify anything on a form that has not been created first.

This should work after creating Form2:

  Form2.ProgressBar1.Position := 24;
0
 
LVL 1

Author Comment

by:Madmarlin
ID: 6194522

I have managed to fond away around this..
By passing my fucntion the correct sender I can create and controll the form and its components..
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 6194550
??????????????????????????????????????????

I am wasting my time!!!!!!!!
0
 
LVL 1

Author Comment

by:Madmarlin
ID: 6194597
your replys didn;t work for my scenario, probably due to a vaige description of the problem.

Sorry.
I appreciate your efforts but I a coleague came up with the answer and working example.
0
 
LVL 13

Accepted Solution

by:
Epsylon earned 50 total points
ID: 6194609
Go away!
0
 
LVL 1

Author Comment

by:Madmarlin
ID: 6194651
Here have you points you miserable twat.

Thanks for the time..
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 6194666
(Edited by Computer101) off
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need Help Delphi 2010 CheckBox1 Stored value in memo 13 70
Adoquery sql  left join does not work 25 98
scroll down TListBox component in Delphi 1 19
MS Access from Delphi 31 59
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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

790 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