Cleanup Sequence

This is a discussion on Cleanup Sequence within the Windows Programming forums, part of the Platform Specific Boards category; I've always been a bit puzzled on the subject of exactly how a Windows application should 'correctly' be shut down. ...

  1. #1
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879

    Cleanup Sequence

    I've always been a bit puzzled on the subject of exactly how a Windows application should 'correctly' be shut down.

    Specifically, I'm confused about DestroyWindow(). On MSDN, regarding the notification WM_DESTROY, it says:
    The WM_DESTROY message is sent when a window is being destroyed. It is sent to the window procedure of the window being destroyed after the window is removed from the screen.

    This message is sent first to the window being destroyed and then to the child windows (if any) as they are destroyed. During the processing of the message, it can be assumed that all child windows still exist.
    If WM_DESTROY is guaranteed to be processed *before* child windows are completely deallocated, then does this imply that killing the message loop before destroying windows will prevent the child windows from being completely deallocated, i.e. resource leak?
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  2. #2
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,457
    I'm not an expert, but I would say yes.
    However, you can use GetMessage until it returns FALSE, which would mean there are not messages to fetch for the current process. GetMessage blocks until there's a message to fetch, and when it find one, it returns TRUE.
    So if you use a loop like that, it should guarantee all messages are sent and processed before quitting the loop.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Ah, that's unfortunate; since window creation is part of a general initialization function in my code, I originally had DestroyWindow() as part of a general cleanup function being executed after the message loop quits. I suppose I'll have to find some unified way of calling DestroyWindow from any point where I want to kill the message loop.
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Immediate programming help! Please!
    By xMEGANx in forum C++ Programming
    Replies: 6
    Last Post: 02-20-2008, 11:52 AM
  2. while statement
    By wonderpoop in forum C Programming
    Replies: 13
    Last Post: 10-23-2006, 09:14 PM
  3. sequence
    By braddy in forum C Programming
    Replies: 2
    Last Post: 03-30-2006, 01:15 PM
  4. wsprintf and format specifiers
    By incognito in forum Windows Programming
    Replies: 2
    Last Post: 01-03-2004, 09:00 PM
  5. How do I restart a random number sequence.
    By jeffski in forum C Programming
    Replies: 6
    Last Post: 05-29-2003, 02:40 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21