Problem with DestroyWindow API Call 
Author Message
 Problem with DestroyWindow API Call

Hi,

I have a VB 5 program and one of the things it needs to do is to close
another running application.  That other application that it needs to close
has a main window.  That other application also may have an additional
window started by that main window.

I use FindWindow and GetWindow to get the handles of the main and child
windows.  This works fine.

If there is no child window, I issue a PostMessage using WM_CLOSE and the
main window/app closes fine.

If there is a child window, the PostMessage using WM_CLOSE does not close
the windows (main and child).

I've tried using DestroyWindow to close first the child and then the main
windows.  The calls to both return 0 which according to the doc indicates
the DestroyWindow failed ( and indeed it did because the app is still
running ).  The doc says that  GetLastError will give me an error code.  So
I put in a GetLastError which is returning zero which according to the
documentation indicates success.

*It can't be both ways!!!*  The DestroyWindow can't fail and be successful.
This looks like a bug with the GetLastError function because the
DestroyWindow does indeed fail (because the app is still running).

Here's a code snippet.  Does anyone have a clue as to either why
DestroyWindow would fail or the GetLastError would fail?

' yhwnd is a valid window handle for the child window
' after executing DestroyWindow, X is 0.
' after executing GetLastErr, lerr is 0.
' *what gives???*

        X& = DestroyWindow(yhwnd)
        lerr = GetLastError()

Any help is ***greatly*** appreciated.

Thanks,

Doug



Sun, 21 Jul 2002 03:00:00 GMT  
 Problem with DestroyWindow API Call

Quote:
>The doc says that  GetLastError will give me an error code.  So
>I put in a GetLastError which is returning zero which according to the
>documentation indicates success.

Doug,

You can't trust the eturn value of GetLastError in VB. To get the real
error code, check Err.LastDllError.

Mattias

__________________________________________________

     VB+ http://hem.spray.se/mattias.sjogren/
 Please send questions/replies to the newsgroups



Sun, 21 Jul 2002 03:00:00 GMT  
 Problem with DestroyWindow API Call
Well, unfortunately Err.LastDllError also gives me a zero.  So . . . I'm
still pulling my hair out.
Quote:
> >The doc says that  GetLastError will give me an error code.  So
> >I put in a GetLastError which is returning zero which according to the
> >documentation indicates success.

> Doug,

> You can't trust the eturn value of GetLastError in VB. To get the real
> error code, check Err.LastDllError.

> Mattias



Sun, 21 Jul 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. DestroyWindow API call not working?

2. Newbie to VB4 needs help w/ API call to DestroyWindow

3. Looking for help on DestroyWindow API call

4. DestroyWindow API call not working?

5. VB3 Api Call DestroyWindow

6. Win API DestroyWindow Usage

7. hep with API--->DestroyWindow()

8. Win API DestroyWindow usage

9. DestroyWindow problem

10. API Call from Access under NT$ problem.

11. Problems with Marshal.PtrToStructure in wrapper for API call returning byte array enumeration

12. Problem in converting this api call from c# to vb.net

 

 
Powered by phpBB® Forum Software