🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: WM_CLOSE, WM_DESTROY problem

#7804
From: Bob Gonder
Date: Mon, 20 Dec 2004 17:41
34 lines
2083 bytes
PaoloItaly wrote:

>if i close all the window of my application "at hand", by clicking the X
>button, my child wndProc receive the wm_close, wm_destroy event.

That button sends 
 SC_CLOSE	Closes the window. This command sends a WM_CLOSE
message to the window. The window carries out any steps needed to
clean up and destroy itself.

That suggests that if you send yourself a WM_CLOSE, that it will have
the same effect as the X.
	case WM_COMMAND:	// message: command application menu
		switch(wParam)
		{
		case CM_EXIT:
			PostMessage(hWnd,WM_CLOSE, NULL,0);
			return 0;

>Closing my application from the main window (PostQuitMessage(0)) no event
>are sended at child windows.

PostQuitMessage is the _last_ thing you do.
It stops the message pump and exits.
Clean up everything _before_ posting that message.

>I've to take trace of opened windows myself and then call DestroyWindow, or
>there is a built-in Windows method to do this job ?

If sending yourself a WM_CLOSE doesn't do it, then you could try
sending an SC_CLOSE (See WM_SYSCOMMAND)

Something like
	DefWindowProc(hWnd,WM_SYSCOMMAND,SC_CLOSE, 0);
Technical Details
Message-ID: <6m2es0pnlpb0ggvc63debugnst53fa59bn@4ax.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.media.kyoto-u.ac.jp!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <41c6e166@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,7d205b36418f01bf
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: Bob Gonder <notbg@notmindspring.invalid>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: WM_CLOSE, WM_DESTROY problem
Date: Mon, 20 Dec 2004 09:41:24 -0800
Organization: MindSpring Enterprises, Inc.
Reply-To: notbg@notmindspring.invalid
Message-ID: <6m2es0pnlpb0ggvc63debugnst53fa59bn@4ax.com>
References: <41c6e166@newsgroups.borland.com>
X-Newsreader: Forte Agent 1.93/32.576 English (American)
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 67.77.147.28
X-Trace: newsgroups.borland.com 1103564481 67.77.147.28 (20 Dec 2004 09:41:21 -0800)
Lines: 37
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.media.kyoto-u.ac.jp!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail