🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #8290

Re: PostMessage() does not close the Form

#8290
From: Umut Ozden
Date: Wed, 10 Nov 2004 11:14
41 lines
2605 bytes
> It is good use to give the reason(s) then why it is unsufficient.
>
> Please explain in the students newsgroup first why that answer
> is unsufficient. The solution with a TTimer does work.
>
> HAns.

I was told that Close() command cannot be used in a FormActivate event.
The lines below were Remy Lebeau's reply (16th June 2003)

"
You can't close a form from those events, modal or otherwise.  If you need
to close a form when it appears, then you need to either:

1) use a TTimer instead, and call Close() in its OnTimer event

2) call Close() in the OnPaint event, protected by a boolean variable so it
only gets called once (since OnPaint is triggered repeatedly)

3) in the OnShow/OnActivate event, call PostMessage() to post a WM_CLOSE
message to the message queue and the form will process it later on.
"

I chose PostMessage() to close the form because it is the simplest. As I
mentioned before, calling PostMessage()
used to close the form always in another program of mine, but not always
now.
I expected an answer explaining why PostMessage() doesn't work know. Since
you didn't explain
this, I regard the answer to be insufficient.

I also noted that changing mouse coordinates manually or programatically
closes the Form.
I expect an suggestion like adding some kind of message to Windows message
queue before or after
PostMessage((HWND)Handle,WM_CLOSE,0,0); (maybe it is a message related with
the mouse or the keyboard).

 I 'm not going to post the mail to the students newsgroups since it would
be duplicate.
Thanks.
Technical Details
Message-ID: <4191f7e8@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!news2.euro.net!216.196.110.149.MISMATCH!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!news-hub.cableinet.net!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <4191b34d@newsgroups.borland.com> <4191d74d$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,eddba34e31a6f877
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Umut Ozden" <umut_ozden@yahoo.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <4191b34d@newsgroups.borland.com> <4191d74d$1@newsgroups.borland.com>
Subject: Re: PostMessage() does not close the Form
Date: Wed, 10 Nov 2004 13:14:48 +0200
Lines: 44
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.50.4807.1700
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
NNTP-Posting-Host: 212.174.88.7
Message-ID: <4191f7e8@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1100085224 212.174.88.7 (10 Nov 2004 03:13:44 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!news2.euro.net!216.196.110.149.MISMATCH!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!news-hub.cableinet.net!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail