Link to home
Start Free TrialLog in
Avatar of soapsiam
soapsiam

asked on

Error: Cannot mak a visible winow modal (Delphi 6)

I have made automation server (DLL) and controller using delphi 6. But I have a runtime error showing "Cannot make a visible window modal" when I call function to launch a (Server) form. I know that to use showmodal, a form have to set it visible property to FALSE and formStyle = fsNormal. And I have set these properties and it is not work.

How can I fix this problem? I tried to set its properties during runtime, however it is not work. This is my code in Controller.

procedure TfrmMain.mnuMaintenanceClick(Sender: TObject);
var WorkOrderMgr : IMaintenanceWorkOrderSvr;
begin
    WorkOrderMgr := CoMaintenanceWorkOrderSvr.Create;
    try
        if WorkOrderMgr.Login(Users1.CurrentUser.UserName,
            Users1.CurrentUser.Password ,'Central',
            MaintenanceDM.ADOConn.ConnectionString) then

            WorkOrderMgr.LaunchUI
        else
            MessageDlg('Fail to login',mtError,[mbYes],0);
    finally
        WorkOrderMgr := nil;
    end;
end;  

and on Automation server.


procedure TMaintenanceWorkOrderSvr.LaunchUI;
var frmMaintenance : TfrmMaintenanceMgr;
begin
    if FLoginOk then
    begin
        frmMaintenance := TfrmMaintenanceMgr.Create(nil);
        try
            frmMaintenance.UserName     := FUserName;
            frmMaintenance.FormStyle    := fsNormal;
            frmMaintenance.Visible      := False;
            frmMaintenance.ShowModal;
        finally
            frmMaintenance.Free;
        end;
    end;
end;

Or you could you please suggest me how to do step debugging in automation server.

soapsiam.
ASKER CERTIFIED SOLUTION
Avatar of esoftbg
esoftbg
Flag of Bulgaria image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Pierre Cornelius
Pierre Cornelius
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of soapsiam
soapsiam

ASKER

My form is local variable, how can I make a second show modal form?
esoftbg
frmMaintenance can not be assigned in AutoCreate Forms as it is DLL.
I also remove "var frmMaintenance : TfrmMaintenanceMgr;" from my code.
Do you want to have more than one instance of TfrmMaintenanceMgr at the same time, or you need a new instance after closing the previous one ?
esoftbg

I want only one instance of TfrmMaintenanceMgr. If user close a form, it is freed. And recreate again if desire.
You need to implement into the .DLL a method for creating and showing the Form inside it ....

take a look at:

https://www.experts-exchange.com/questions/20923641/Forms-in-DLL.html
https://www.experts-exchange.com/questions/20665112/Forms-Inside-A-Dll.html
https://www.experts-exchange.com/questions/20923641/Forms-in-DLL.html
https://www.experts-exchange.com/questions/20665112/Forms-Inside-A-Dll.html


and into the .DLL it will be:

//....

uses
  SysUtils,
  Classes,
  Unit1 in 'Unit1.pas' {Form1};

{$R *.res}

procedure ShowDllForm; stdcall;
begin
  frmMaintenanceMgr :=TfrmMaintenanceMgr.Create(nil);
  try
    frmMaintenanceMgr.ShowModal;
  finally
    frmMaintenanceMgr.Release;
  end;
end;

Exports
    ShowDllForm;

begin
end.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I have create a new form in COM Client and it can show modally. I think it might be problem by one of component may be TUsers of ToolsandComps.
I don't know what causes the problem for this situation but when I open dfm file, no Visible property of form there. So, I add Visbile = True in dfm and it works. And before I add this, in object inspector its visible is false.


Thanks for all comments, so I will delete this question.
I have found what is a problem for this, it is FastReport. When I made error on fastreport (script) that is on my form and exception is shown. Then a showmodal is not working. I open the DFM file and insert Visible=False. Ok, it works fine.

Thanks