Thread: Order of cleanup

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

    Order of cleanup

    Ok, as far as I know, cleanup is mostly done in this order:
    1) WM_CLOSE calls DestroyWindow()
    2) WM_DESTROY calls PostQuitMessage()
    3) Loop ends on WM_QUIT, and application returns

    But is there any problem if it's done in this order:
    1) WM_CLOSE calls PostQuitMessage()
    2) Loop ends on WM_QUIT
    3) DestroyWindow() is called after the loop
    4) application returns

    Will there be any problems with leftover messages or anything of the sort? And would there be problems with other arrangements similar to this?
    Just Google It. √

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

  2. #2
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    >>2) Loop ends on WM_QUIT
    3) DestroyWindow() is called after the loop<<

    If the msg loop is stopped how will you get the DestroyWindow msg?
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  3. #3
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Hmm, ok. Because in one of my previous programs I needed to call the cleanup function of my graphics wrapper before calling DestroyWindow(), otherwise it would crash. Does this mean that I'll have to put all of my cleanup before the message loop ends (i.e. call a cleanup function which does de-initializing and stuff and then calls DestroyWindow())? And also, how would I signal my program to quit? Currently I just use PostQuitMessage() when I want to quit. Should I be calling a cleanup function>DestroyWindow>WM_DESTROY>PostQuitMessage( ) instead?
    Just Google It. √

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

  4. #4
    Registered User Dante Shamest's Avatar
    Join Date
    Apr 2003
    Posts
    970
    Should I be calling a cleanup function>DestroyWindow>WM_DESTROY>PostQuitMessage( ) instead?
    Yes, that should work.

    How about running your debugger to see?

  5. #5
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Ok, thanks. But how would running a debugger help?
    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. Laplace Expansion
    By Leojeen in forum C Programming
    Replies: 7
    Last Post: 10-28-2008, 11:26 PM
  2. Embedded SQL Order By
    By cjohnman in forum C Programming
    Replies: 12
    Last Post: 04-15-2008, 03:45 PM
  3. while statement
    By wonderpoop in forum C Programming
    Replies: 13
    Last Post: 10-23-2006, 09:14 PM
  4. How do you order your game code?
    By Queatrix in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 02-05-2006, 06:26 PM
  5. what is the significance of low order and high order bits
    By Shadow12345 in forum Windows Programming
    Replies: 1
    Last Post: 11-16-2002, 11:46 AM