Solved

Unit 1 referencing Units2's component properties..

Posted on 2001-06-15
10
198 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses
Course of the Month4 days, 18 hours left to enroll

636 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