Link to home
Start Free TrialLog in
Avatar of Delphi-Lover
Delphi-Lover

asked on

create and show Forms with NMStrmServ component

Hello,

Quite stuck with the following...

I try to create a form after a message is delivered by the NMStrmServ
component. like :

procedure TfrmServer.NMStrmServ1MSG(Sender: TComponent;
 const sFrom: String; strm: TStream);
begin
 If sFrom='Person' then  frmSelectForm.ShowForm;
end;

frmSelectForm is a form with a Tlist and every item in a list has an Object
with a Form.
(I don't put the code to select the proper Object from the list etc..)

procedure TfrmSelectForm.ShowForm;
Begin
 If MyForm=NIL Then
 Begin
   Application.CreateForm(TFormClass(TfrmCardImage), MyForm);
   MyForm.Show;

   //Also not work..
   //MyForm:=TfrmCardImage.Create(FOwner);
   //MyForm.Parent:=Application.MainForm;
  MyForm.Show;
End;

The form is not shown on the screen and when I leave the application it
gives me a win32 error.
It has something to do that the application is not creating the form in the
right way. Maybe the server component is in a Thread.
Don't bother with the list, object in the list, etc, because this works fine.

If a Visual component on the frmSelectForm, like a button, is doing the job,
the MyForm is OK and shown on screen when an user clicks on the button.

I can do this also with the NMStrmServ and calling a procedure that doing a
postmessage to the button like : PostMessage(btnPostButton.Handle,
cn_Command, bn_Clicked, 0);
In the buttonclick event of btnPostButton I create the form and everything
is OK again.

So, only when the event of the NMStrmServ is calling the create/show form
procedure the form will not show on screen. I'v tried to set the Parent,
Owner and things, but can not find the right way.

HELP!!!!!!!!

Greets,

Rob.
Avatar of esoftbg
esoftbg
Flag of Bulgaria image

MyForm.ShowModal;

emil
procedure TfrmSelectForm.FormShow(Sender: TObject);
begin
 if not Assigned(MyForm) then
   Application.CreateForm(TfrmCardImage, MyForm);
  MyForm.ShowModal;
end;
Avatar of Delphi-Lover
Delphi-Lover

ASKER

The problem is not in creating the form in an ordinary way, but the NMStrmServer component is doing something strange. I Can not do it in the Formshow of the SelectForm, because this is already open and visible. I don't want to do Showmodel, but show.

If a Visual component on the frmSelectForm, like a button, is doing the job, the MyForm is OK and shown on screen when an user clicks on the button.
It seems there must be a action from a user doing it in the frmSelectForm. It is very weird that in the event of the NMStrmServer component it goes wrong. I'm opening forms from other forms for years, but this time it doesn't work. (because of the NMStrmServer component!!) It must be some low level thing. like setting owner, parent , visible or something?

my try : Application.CreateForm(TFormClass(TfrmCardImage), MyForm);
your answer: Application.CreateForm(TfrmCardImage, MyForm);
must be the same...

Thanks.
here a post on a newsgroup with the same problem!
http://www.elists.org/pipermail/delphi/2000-June/009167.html

but no answer ;-(
ASKER CERTIFIED SOLUTION
Avatar of kretzschmar
kretzschmar
Flag of Germany 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
The ProcessMessages procedure doesn't work. The form is somehow destroyed by the server component. With the ProcessMessages you can now see a flash of the form on screen for 1 milisecond. The problem is in the way how the server component is doing his thread thing. It should work if the Indy component suite is used (There is a TCP component availble) but I like to see if the problem can be solved with the native FastNet components. (I've mailed the FastNet guys and waiting for an answer)

Can you be quicker with the solution?

Thanks,

Rob
Hi Delphi-Lover,

I have not solution for that bug. I am using Delphi Enterprise version 7.0 and there is not FastNet components. I can not taste it at all.

Sorry,
emil
thanks for accepting my comment as answer,
but could you explain the c-grade?

meikl ;-)
Hello,

I'm not aware of a C-Grade? I could not find a way to close this item that is open for so long time. There is no solution for this question. To close this item anyway, i decided to accept the answer of Master Kretschmar, not infecting the points thing because he has already over 1 million of them :-)))

Greets,

DL.
Kretzschmar,

There is no solution to this question, but there is an answer. There must be a flaw in this native component and there is not much we can do about it, only using an other (Indy) component. (Maybe this is the solution:-) Maybe it is wise to leave this question so that others who are getting the same problem can at least find something about it.

Greets,

DL.