Solved

previous active window

Posted on 1997-05-07
3
287 Views
Last Modified: 2013-12-04
In Win95/NT, How do I get the previous active focused window handle of other applications when user clicks on my application?
0
Comment
Question by:jasonz050797
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 15

Accepted Solution

by:
NickRepin earned 50 total points
ID: 1397159
When user clicks on your window, it receives WM_SETFOCUS message. WPARAM of this message identifies the window that has lost the keyboard focus.
So you have to implement code for handling this message.
Also you can check WM_ACTIVATEAPP or WM_ACTIVATE messages.
0
 

Author Comment

by:jasonz050797
ID: 1397160
I used this messages before and they works fine. WPARAM=NULL if you activate app when destop is active.
In any other case WPARAM is handle of deactivated window.
If you have Winsight32 or Winspy you can check it.
By the way, WPARAM=hWnd for WM_SETFOCUS only.
0
 
LVL 15

Expert Comment

by:NickRepin
ID: 1397161
I am sorry.. You are right! It seems there is no way to obtain handle of deactivated window. Just reject my answer.

Here is MS knowledge base article:

WM_ACTIVATEAPP Has lParam of Zero (0)

Article ID: Q135785
Creation Date: 28-AUG-1995
Revision Date: 29-SEP-1995

The information in this article applies to:

•Microsoft Win32 Application Programming Interface (API) included with:



    - Microsoft Windows NT version 3.51
    - Microsoft Windows 95 version 4.0
    - Microsoft Win32s version 1.3










SUMMARY


Although the current Win32 documentation does not specifically indicate this, it is possible (and very likely) that the WM_ACTIVATEAPP message will be received by an application with the lParam equal to 0. You can in fact get 0 in lParam when activating and deactivating.



MORE INFORMATION


In previous versions of Windows, activation and deactivation used to be synchronous. This meant that you could never switch away from an application that was locked up because the application becoming active had to wait for a synchronous reply from the application being deactivated. The activating application would get stuck waiting for the deactivating application to process and return from the WM_ACTIVATEAPP, WM_ACTIVATE, and WM_NCACTIVATE messages.

In Windows 95 and Windows NT, Microsoft removed every place where these types of synchronous lockups can occur. When asynchronous activation occurs, the activating application becomes active immediately, and the messages to the deactivating application occur later. This means two things:

•An application can be terminated in the middle of this process. If this happens, the thread ID/task handle that is passed in the lParam is invalid. •When the deactivated application gets notified, it is possible that the activated application is no longer active. A third application might have been activated in the interim.






------------------------------------------------------------------------
Additional reference words: 4.00 1.30 Windows 95
KBCategory: kbui
KBSubcategory: UsrWndw


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

©1997 Microsoft Corporation. All rights reserved. Legal Notices.
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question