Quote:whosrdaddy (Vendor)
clearer now?
Yes, I think so. Thank you. This is the code on my main form. Quote:type TForm1 = class(TForm) MainMenu1: TMainMenu; Menu1: TMenuItem; Menu2: TMenuItem; Menu3: TMenuItem; Menu4: TMenuItem; Panel1: TPanel; procedure Menu1Click(Sender: TObject); procedure Menu2Click(Sender: TObject); procedure Menu3Click(Sender: TObject); procedure Menu4Click(Sender: TObject); private { Private declarations } public { Public declarations } end;
var Form1: TForm1; CurrentForm : TForm;
implementation
uses Unit2, Unit3, Unit4;
{$R *.dfm}
procedure TForm1.Menu1Click(Sender: TObject); var Form : TForm1; begin if Assigned(CurrentForm) then CurrentForm.Close; Form1 := TForm1.Create(nil); CurrentForm := Form1; end;
procedure TForm1.Menu2Click(Sender: TObject); var Form : TForm1; begin if Assigned(CurrentForm) then CurrentForm.Close; Form2 := TForm2.Create(nil); CurrentForm := Form2; Form2.Show; end;
procedure TForm1.Menu3Click(Sender: TObject); var Form : TForm1; begin if Assigned(CurrentForm) then CurrentForm.Close; Form3 := TForm3.Create(nil); CurrentForm := Form3; Form3.Show; end;
procedure TForm1.Menu4Click(Sender: TObject); var Form : TForm1; begin if Assigned(CurrentForm) then CurrentForm.Close; Form4 := TForm4.Create(nil); CurrentForm := Form4; Form4.Show; end;
I'm sure I'm doing something wrong, as it gives me a message when compiling: Quote:[DCC Warning] Unit1.pas(38): H2164 Variable 'Form' is declared but never used in 'TForm1.Menu1Click' [DCC Warning] Unit1.pas(47): H2164 Variable 'Form' is declared but never used in 'TForm1.Menu2Click' [DCC Warning] Unit1.pas(57): H2164 Variable 'Form' is declared but never used in 'TForm1.Menu3Click' [DCC Warning] Unit1.pas(67): H2164 Variable 'Form' is declared but never used in 'TForm1.Menu4Click'
However, it does appear to work. I think. I assume I don't need the create routine in the menu1 click procedure, as menu1 is the main form? |
|