Results 1 to 5 of 5

Thread: How can I close an application and receive QueryUnload event

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2002
    Location
    The Netherlands
    Posts
    31

    How can I close an application and receive QueryUnload event

    I like to close application via an API call.

    I think it is possible using the PostMessage API, but all examples use WM_Close, for example:

    RetVal = PostMessage(winHwnd, WM_CLOSE, 0&, 0&)

    This always results in immediatly closing the application without the form_QueryUnload and form_unload events taking place.

    So unfinished business stays unfinished.

    The application I like to close needs to have the ability to reject my request to close it. Hence I need the Query_unload event.

    Thanks for answer.

  2. #2
    Software Eng. Megatron's Avatar
    Join Date
    Mar 1999
    Location
    Canada
    Posts
    11,286
    try:

    SendMessage hwnd, WM_SYSCOMMAND, SC_CLOSE, 0

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Sep 2002
    Location
    The Netherlands
    Posts
    31
    Correct my previous statement.

    Although I have tested this problem many times (I always had the same results), Microsoft does use WM_CLOSE in an (now) excellent example.

    For those who are interested, it has the code Q242308 and can be found on their site. (try this url: http://support.microsoft.com/default...;en-us;Q242308)

  4. #4
    Software Eng. Megatron's Avatar
    Join Date
    Mar 1999
    Location
    Canada
    Posts
    11,286
    So WM_CLOSE worked?

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Sep 2002
    Location
    The Netherlands
    Posts
    31
    Yep, but what I don't know, why it did not work previously.

    Ah well...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width