Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4576810
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T20:15:29+00:00 2026-05-21T20:15:29+00:00

I know which using the GetForegroundWindow function i can get the current active window

  • 0

I know which using the GetForegroundWindow function i can get the current active window handle, but now i want to detect when the active window (of any application) changes (become active). the first solution which come to my mind is

  1. store the current value (handle) returned by the GetForegroundWindow function.
  2. using a timer component check again the value returned by GetForegroundWindow and compare with the old value.

I’m wondering if exist a better way to do this maybe using a windows message or something else.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T20:15:30+00:00Added an answer on May 21, 2026 at 8:15 pm

    Use SetWindowsHookEx to install a CBT hook. MSDN describes the callback function you’ll provide:

    The system calls this function before activating, creating, destroying, minimizing, maximizing, moving, or sizing a window; before completing a system command; before removing a mouse or keyboard event from the system message queue; before setting the keyboard focus; or before synchronizing with the system message queue. A computer-based training (CBT) application uses this hook procedure to receive useful notifications from the system.

    The calls you’ll be interested in are the ones where the first parameter is HCBT_Activate. The wParam parameter will tell you the window handle.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know which function to use but I can't get it to work right.
I want to know which *.config file the ConfigurationManager is using. How can I
I know they're using a jQuery plugin, but I can't seem to find which
I want to know which tool can be used to measure the cyclomatic complexity
How to know which application is using an Assembly in GAC ? I want
I am using buy it now PayPal buttons but I DO NOT want to
The fuser command lets me know which processes are using a file or directory.
I'd like to know which method is recommended on Windows C programming: using malloc
I'd like to know situations in which I should consider using a framework other
I know this is supposed to output what kind of shell I'm using, which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.