preventing a premature exit...

This is a discussion on preventing a premature exit... within the Windows Programming forums, part of the Platform Specific Boards category; I have a window that I am using as a sort of dialog box (that is, it's not an actual ...

  1. #1
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708

    Question preventing a premature exit...

    I have a window that I am using as a sort of dialog box (that is, it's not an actual dialog). It does not have the WS_CHILD style and it was created with the parent HWND_DESKTOP. Still, when I close the window, the entire program exits. Not exactly what I wanted! I have searched the headers for possible CS_ and WS_ styles but find nothing that might disable this feature. Any clues?
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  2. #2
    Registered User
    Join Date
    Jan 2002
    Posts
    11
    Is the "dialog" window the only window for the program? If it is it's pretty obvious why the program shuts down when you close the window.

    It's really hard to offer advice without knowing all the specifics about the app, I'm pretty sure there isn't a special DWORD to prevent destroying a main window from halting the program.

    Going with what I have from your post I would suggest (if your "dialog" is indeed the main window) creating a main window (that becomes hidden when the dialog is created, and reshown when it is destroyed) and making the dialog a child with a parent of GetForegroundWindow() or changing your window procedure around so that closing the window doesn't process a PostQuitMessage().

    But to recap, no, I'm almost positive there's no special style to do what your asking.

  3. #3
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    It's not the main window, it's just a window that pops up during print jobs, thus I need it to be completely independant of the main window as far as destruction goes...
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  4. #4
    Registered User
    Join Date
    Jan 2002
    Posts
    11
    Sounds like you should subclass it, or at least make it a child window.

  5. #5
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    The WM_QUIT/WM_DESTROY message is posted to the thread, not the window.
    (I think )

    Put it in a different thread, or check the target window of the message in your message loop.
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  6. #6
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Thanks, man, I believe you're right - can't believe I was so short-sighted! I'll try it out...

    /*edit*/

    Ok, that was it. Thanks again, Drax.
    Last edited by Sebastiani; 11-12-2002 at 02:19 PM.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Chat Program Help?
    By Paul22000 in forum Networking/Device Communication
    Replies: 9
    Last Post: 02-10-2009, 12:35 AM
  2. Labels for premature function exit + cleanup
    By cboard_member in forum C++ Programming
    Replies: 6
    Last Post: 06-12-2006, 06:02 PM
  3. Odd memory leaks
    By VirtualAce in forum C++ Programming
    Replies: 11
    Last Post: 05-25-2006, 01:56 AM
  4. Dynamic array of pointers
    By csisz3r in forum C Programming
    Replies: 8
    Last Post: 09-25-2005, 03:06 PM
  5. exit() ?
    By smd in forum C++ Programming
    Replies: 4
    Last Post: 06-26-2002, 05:31 PM

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