Newsgroups : Borland : borland.public.delphi.internet.winsock : 2007 Dec : Re: closing an application over the network

www.cryer.info
Managed Newsgroup Archive

Re: closing an application over the network

Subject:Re: closing an application over the network
Posted by:"soonic" (xxsoon..@op.pl)
Date:Fri, 21 Dec 2007 00:37:55

> Then you need to change how you are calling Application.Terminate().  The
> easiest way is to simply pass Application.Terminate() to
> TThread.Synchronize(), ie:
>
>    Synchronize(Application.Terminate);
>

It works now!


>
> You can use the same custom message approach for that.  Have CTIStartup()
> post a custom message to TMainForm, and then have the message handler
> execute what you need.  You can also have the OnShow event post the same
> message as well.

It's working, but not quite correctly, I got:

const
      WM_MYMSG = WM_USER + 1000;    //I don't know what is WM_USER, just
wrote that ;)


procedure TMainForm.FormCreate(Sender: TObject);
begin
  Application.OnMessage := MyMsg;
end;


procedure TMainForm.MyMsg(var Msg: TMsg; var Handled: Boolean);
begin
  if Msg.message = WM_MYMSG then
  begin
    Handled := True;
    FormShow(nil);
  end;
end;

procedure TMainForm.CTIStartup(Sender: TObject; var ShowMainForm: Boolean);
begin
  PostMessage(CTI.Handle, WM_MYMSG, 0, 0);
  ShowMainForm := False;
end;

The main problem I noticed is that I get this procedure below called (which
I had mentioned before regarding the already solved problem with app
terminate)

procedure TMainForm.Terminate;
begin
  //Application.Terminate;
end;

In my FormShow I do:
- setting TButton properties
- reading from file
- connecting to server
- sending information

As I said that FromShow works perfect when my application starts normally
(not to tray ).
Probably I'm setting wrong this message handler. I don't know if this
information is enough but maybe you can help me.

Replies:

In response to:

www.cryer.info
Managed Newsgroup Archive