Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.



This topic is 6180 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok, in the first unit, I declared open as follows:
  TOpen = class
    procedure OpenIcon;
    procedure OpenPicture;
    procedure OpenSound;
    procedure OpenText;
    procedure OpenVideo;
    procedure SaveText;
    procedure SaveIcon;
now, in the 2nd unit, I put this in a procedure:
Case RadioGroup1.ItemIndex of
0: TForm1.TOpen.OpenIcon;
1: TForm1.TOpen.OpenPicture;
2: TForm1.TOpen.OpenSound;
3: TForm1.TOpen.OpenText;
4: TForm1.TOpen.OpenVideo;
I know this is totally wrong. What should TForm1.TOpen.OpenIcon; be changed to???

Share this post

Link to post
Share on other sites
You must create an object of your new class.
On the first unit, create a var of this object (under the Form1:TForm1)

NewOpen: TOpen;

On the OnCreate of the form:

NewOpen := TOpen.Create;

And on the second unit, you dont need use TForm1. because our object is not a property of the form. But you need put the unit1 on the uses, but the uses just after the implementation declaration, as follows:


uses Unit1; // (or the filename of your unit1)

Finally to use the new object:

Case RadioGroup1.ItemIndex of
0: NewOpen.OpenIcon;
1: NewOpen.OpenPicture;
2: NewOpen.OpenSound;
3: NewOpen.OpenText;
4: NewOpen.OpenVideo;

There are some remarks here. You can only use the NewOpen object on unit 2, if its declared on unit 1 before implementantion section (on interface), because just symbols on interface are exported to others units.

I think this solves your problem.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!