By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,567 Members | 1,056 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,567 IT Pros & Developers. It's quick & easy.

Quitting a window, using GetActiveWindow() API, returns 0???

P: n/a
I am using the GetActiveWindow() API but it returns 0

I have a remote that I activate this code with:

Code:
WinAmpHandler = GetActiveWindow
WinAMPhWnd = FindWindow("Winamp v1.x", vbNullString)

I have the WinAmp window active but the GetActiveWindow returns a 0 instead
of the window handler, way?
I am using this WinAMPhWnd = FindWindow("Winamp v1.x", vbNullString) to se
the correct WinAmp hWnd, it works fine.

I want to get the handler for the active window and use it to quit the
active program:

Code:
Public Const WM_QUIT = &H12

PostMessage(hWndHandler, WM_QUIT, 0&, 0&)

It work if i use WinAMPhWnd to quite WinAmp, but I want it to work on all
active programs...

If there is another bather way of quitting a active program than please tell
me :-)

Yours, Jonas

Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
I have started to use GetForegroundWindow instead now.

But I don't know when I should use WM_CLOSE and WM_QUIT I can quit IE with
WM_CLOSE but not with WM_QUIT and I can quit WinAmp with WM_QUIT but not
with WM_CLOSE...

How do I know where to use QUIT and CLOSE?
How can I make my program to decide when to use CLOSE an QUIT?

PostMessage(hWndHandler, WM_CLOSE, 0&, 0&)
"BadOmen" <ba*******@hotmail.com> skrev i meddelandet
news:S%********************@newsc.telia.net...
I am using the GetActiveWindow() API but it returns 0

I have a remote that I activate this code with:

Code:
WinAmpHandler = GetActiveWindow
WinAMPhWnd = FindWindow("Winamp v1.x", vbNullString)

I have the WinAmp window active but the GetActiveWindow returns a 0 instead of the window handler, way?
I am using this WinAMPhWnd = FindWindow("Winamp v1.x", vbNullString) to se
the correct WinAmp hWnd, it works fine.

I want to get the handler for the active window and use it to quit the
active program:

Code:
Public Const WM_QUIT = &H12

PostMessage(hWndHandler, WM_QUIT, 0&, 0&)

It work if i use WinAMPhWnd to quite WinAmp, but I want it to work on all
active programs...

If there is another bather way of quitting a active program than please tell me :-)

Yours, Jonas

Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.