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.mnuMaintenanceCli ck(Sender: TObject);
var WorkOrderMgr : IMaintenanceWorkOrderSvr;
begin
WorkOrderMgr := CoMaintenanceWorkOrderSvr. Create;
try
if WorkOrderMgr.Login(Users1. CurrentUse r.UserName ,
Users1.CurrentUser.Passwor d ,'Central',
MaintenanceDM.ADOConn.Conn ectionStri ng) then
WorkOrderMgr.LaunchUI
else
MessageDlg('Fail to login',mtError,[mbYes],0);
finally
WorkOrderMgr := nil;
end;
end;
and on Automation server.
procedure TMaintenanceWorkOrderSvr.L aunchUI;
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.
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.mnuMaintenanceCli
var WorkOrderMgr : IMaintenanceWorkOrderSvr;
begin
WorkOrderMgr := CoMaintenanceWorkOrderSvr.
try
if WorkOrderMgr.Login(Users1.
Users1.CurrentUser.Passwor
MaintenanceDM.ADOConn.Conn
WorkOrderMgr.LaunchUI
else
MessageDlg('Fail to login',mtError,[mbYes],0);
finally
WorkOrderMgr := nil;
end;
end;
and on Automation server.
procedure TMaintenanceWorkOrderSvr.L
var frmMaintenance : TfrmMaintenanceMgr;
begin
if FLoginOk then
begin
frmMaintenance := TfrmMaintenanceMgr.Create(
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
esoftbg
frmMaintenance can not be assigned in AutoCreate Forms as it is DLL.
I also remove "var frmMaintenance : TfrmMaintenanceMgr;" from my code.
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 ?
ASKER
esoftbg
I want only one instance of TfrmMaintenanceMgr. If user close a form, it is freed. And recreate again if desire.
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
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.Creat e(nil);
try
frmMaintenanceMgr.ShowModa l;
finally
frmMaintenanceMgr.Release;
end;
end;
Exports
ShowDllForm;
begin
end.
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.Creat
try
frmMaintenanceMgr.ShowModa
finally
frmMaintenanceMgr.Release;
end;
end;
Exports
ShowDllForm;
begin
end.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.
ASKER
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.
Thanks for all comments, so I will delete this question.
ASKER
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
Thanks
ASKER