Jump to content

Recommended Posts

I have two units  (1 & 6) with associated Forms

1 is the stratup form.  I want a button on that form

to close form 1 and open form 6 for further input.

I need to call a procedure in from 6 

after the button is triggered to use a file write routine in form 6

before (or as) closing form 1 and opening form 6.

How do I do this?    Sounds simple but I haven't found a tutorial or book that shows the code yet.

I know the code goes into the buttonclick procedure and I have found the USES clause for Form 6

but making the transfer from 1 to 6??? not yet.

 

 

Share this post


Link to post
7 minutes ago, Freeeee said:

1 is the stratup form. I want a button on that form

to close form 1 and open form 6 for further input.

Is Form 1 the Main form? Closing the Main form will terminate the app.  You could just hide it instead, buy why do you want to close Form 1 at all?

7 minutes ago, Freeeee said:

How do I do this?    Sounds simple but I haven't found a tutorial or book that shows the code yet.

I know the code goes into the buttonclick procedure and I have found the USES clause for Form 6

but making the transfer from 1 to 6??? not yet.

What exactly is stopping you from accomplishing what you want?  What exactly have you attempted so far that is not working for you?  Do you know how to create and open forms?  Do you know how to add procedures to classes, and how to call them?  Sounds like you are missing some fundamentals.

 

Try something like this

unit Unit1;

interface

...

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
    ...
  end;

implementation

uses
  Unit6;

...

procedure TForm1.Button1Click(Sender: TObject);
begin
  Form6 := TForm6.Create(Application);
  Form6.Show;
  Hide;
  Form6.DoSomething;
end;

end.
unit Unit6;

interface

...

type
  TForm6 = class(TForm)
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    ...
  public
    procedure DoSomething;
  end;

var
  Form6: TForm6;

implementation

...

procedure TForm6.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  Action := caFree;
  Form6 := nil;
end;

procedure TForm6.DoSomething;
begin
  ...
end;

end.

 

Edited by Remy Lebeau

Share this post


Link to post

thanks... very much.  It worked just fine with a few minor adjustments.

I used Hide on form1 because it was/is the main form

and didn't need the Action on form6.  

 

It would seem like a simple thing to do but I couldn't find that bit of info any where.

Do you know Cathy Henley?

 

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×