Board index » delphi » complete newbie needs help with menu's

complete newbie needs help with menu's

I have written in Pascal in the past but this is my first attempt in a
Visual environment.

Simple question, I want a button on form1 that when pressed displays form2,
which will have a number of options on it, one being exit, which will stop
form2 form being displayed and return the focus to form1.

Any help would be appreciated.

Thanks

 

Re:complete newbie needs help with menu's


Assign 'Form2.Show' to the button in Form1 and 'Close' on the close button
on form2.
This will do.

Re:complete newbie needs help with menu's


Quote
In article <OHRovYlG#GA.205@upnetnews05>, "BeeJ" <Bee...@msn.com> writes:
>Simple question, I want a button on form1 that when pressed displays form2,
>which will have a number of options on it, one being exit, which will stop
>form2 form being displayed and return the focus to form1.

Why not use a TMainMenu or a TPopUpMenu on your Form1 ?

Alan Lloyd
alangll...@aol.com

Re:complete newbie needs help with menu's


If the button to exit form2 is on form2 then form2 must be displayed before you
can use it?

Re:complete newbie needs help with menu's


Quote
PALFREYMAN wrote in message <19981211115615.29354.00004...@ng07.aol.com>...
>If the button to exit form2 is on form2 then form2 must be displayed before
you
>can use it?

What is your problem?
If form2 is not active, why should you want to close it?
On the other hand, if you want to perform some specific code in this method,
you might think about putting this code in a separate procedure or method
and call it, from any place you like!

for instance in form2 you have :

unit2

interface

type TForm2 = class(TForm)
// etc.
end;

procedure Perform_Special_Code;

var
  Form2 : TForm2;

implementation

procedure Perform_Special_Code;
begin
  // write your special code
end;

procedure Tform2.Button2click(sender: TObject);
begin
  Perform_Special_Code;
  Close;
end;

end.

and in form1 you have :

unit1

interface

type TForm1 = class(TForm)
// etc.
end;

var
  Form1 : TForm1;

implementation

uses
  unit2;

procedure Tform1.Button1click(sender: TObject);
begin
  Perform_Special_Code;
end;

end.

Matthijs
--
======
please check mail-adress if replying by mail. I try to avoid SPAM.

Other Threads