Pb with a new form and a menu

Help
2007-12-06
2013-04-23
  • Bidibulle69
    Bidibulle69
    2007-12-06

    Hi,

    I have two problems when I added a new form:

    1/ In my project I already have a main form. Following the instructions founded in the thread "How to: Multiple forms" and in the lazarus wiki page, I added a new form.
    The problem is that the new form is displayed when I run the application and not the main form.

    2/ The main form have menu that allow to show the second form. The second form have a menu that allow to go back to the main form. The text in menus the are different, so I know which menu is displayed.
    When I launch the application the second is displayed (see the first problem). If with the menu I ask to go to the main form, the main form is displayed but the menu don't change :-). I have to "tap" on the screen in order to have the display of main menu. If I switch form more than I time I need to "tap" on the "ok" button in order to have the display of the main menu.

    Any solutions to this problem?

    Thanks in advance

    Pierre

     
    • jura
      jura
      2007-12-12

      You need to leave only main form in auto-create forms list in project options.
      To show the second form (with Form2 name) use the following code:

      procedure ShowForm2;
      var
        frm: PForm2;
      begin
        NewForm2(frm, Applet);
        frm.Form.ShowModal;
        frm.Form.Free;
      end;

      To close Form2 do the following in button or menu OnClick event:

      Form.ModalResult:=IDOK;

      or

      Form.ModalResult:=IDCANCEL;