Solved

Unit 1 referencing Units2's component properties..

Posted on 2001-06-15
10
192 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
 
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Delphi XE7 Rest Client 2 177
code issue 8 85
how to center only a line in richedit? 4 45
control image tags in a string ? 12 68
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now