• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 381
  • Last Modified:

MDI Question: how i create a LOGIN form in a MDI application?

Hi folks,

I am trying to put a LOGIN form in my application, but i got a error message saying that the MDI is not active ("No MDI forms are currently active").

Do you know how can i implement that?

Best regards.
0
joelsilva
Asked:
joelsilva
1 Solution
 
DelphianCommented:
The simple solution is to made the form an SDI form.
So, change the form Style to fsNormal and show it
before load the main form of the application (need a
little change on the DPR of the project).
0
 
DelphianCommented:
Ops, a typo!
Where you read "change on the DPR"
read "change on the DPR file".

[]s
0
 
joelsilvaAuthor Commented:
Hello,
 
Thx. for reply... I will check your suggestion.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Ivanov_GCommented:
Here is my suggestion:

LOGIN FORM:
------------------------------------------------------------
  TfrmLogin = class(TForm)
  private
  public
    class function CheckLogin : Boolean;
  end;

  class function TfrmLogin : Boolean;
  begin
    // Check your login here
   
  end;
-----------------------------------------------------------

modify your DPR file like this:

begin
  Application.Initialize;
  if TfrmLogin.CheckLogin then
    begin
      // create your forms
      Application.CreateForm(TForm1, Form1);
    end;
  Application.Run;
end.
0
 
BlackTigerXCommented:
if you wanted to use MDI forms and have the login window, the way to do it would be to create that MDI Child window dinamically with the login stuff at the OnShow event of the MainForm, from there you can "enable" all the other stuff if the login was successful, here's an example, supposing the Form1 is the Main Form and Form3 is the login Form

procedure TForm1.FormShow(Sender: TObject);
begin
  with TForm3.Create(nil) do
  try
    Show
  finally
    Free
  end
end;

you would have to disable all functions in your main window (buttons, menus, etc) until they login, from the login Form you would have to change a global variable that would inform the main form that is logged in so you can enable everything that needs to be enabled, you can even have a call to the main form from the MDI Child to do all these
0
 
BlackTigerXCommented:
sorry... this is MDI Forms... all you need to do is this:

procedure TForm1.FormShow(Sender: TObject);
begin
  with TForm3.Create(nil) do //set any properties of the child window here... captions, edit boxes, buttons, etc
end;

the Show gets called automatically for MDI Child forms, and you don't need to free it, you can free it in the OnClose event of the Child form:

procedure TForm3.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  Action:=caFree
end;
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now