Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 201
  • Last Modified:

Unit 1 referencing Units2's component properties..


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
Madmarlin
Asked:
Madmarlin
  • 6
  • 4
1 Solution
 
EpsylonCommented:
Put 'uses Unit2' in the uses clause of Unit1.

Then in Unit1 you can do:

Form2.Visible := true;
0
 
EpsylonCommented:
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
 
MadmarlinAuthor Commented:

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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
EpsylonCommented:
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
 
MadmarlinAuthor Commented:

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
 
EpsylonCommented:
??????????????????????????????????????????

I am wasting my time!!!!!!!!
0
 
MadmarlinAuthor Commented:
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
 
EpsylonCommented:
Go away!
0
 
MadmarlinAuthor Commented:
Here have you points you miserable twat.

Thanks for the time..
0
 
EpsylonCommented:
(Edited by Computer101) off
0

Featured Post

Industry Leaders: 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!

  • 6
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now