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 613667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:01:40+00:00 2026-05-13T18:01:40+00:00

I was wondering if anybody could give insight on how to implement the window

  • 0

I was wondering if anybody could give insight on how to implement the window selector in Winspector Spy. Basically, I would want to provide a panel that I could mouse down on, drag over to another processes window (or sub window) and get something like the HWND out of it. Ideally, I would do this in C#, but if it’s only possible by wrapping the C APIs, then I can just do it in C++.

I messed around with the DragDrop event and calling DoDragDrop on mouse down in C#, but wasn’t really sure if that could give me what I want. Will it be easier to just get the global X/Y pos of the mouse and find the topmost window at that location? Is there an API which does that automagically for me given x, y parameters?

EDIT: Just discovered WindowFromPoint for the latter question

  • 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-13T18:01:40+00:00Added an answer on May 13, 2026 at 6:01 pm

    You don’t normally get mouse messages when the mouse isn’t over your window. But you need to in order to do drag and drop operations. So, Windows provides a mechanism called mouse capture. To prevent mouse capture from being abused, you can only capture the mouse on a button down message. Once you have capture, you get mouse move messages no matter where the mouse is on screen until you release capture or when Windows sees the corresponding button up message.

    The C++ code for this looks something like this

     case WM_LBUTTONDOWN:
         { 
         SetCapture(hwnd);
         }
         break;
    
     case WM_MOUSEMOVE:
         if (GetCapture() == hwnd)
            {
            POINT pt = {GET_MOUSE_X(lParam), GET_MOUSE_Y(lParam));
            ClientToScreen(hwnd, &pt);
            HWND hwndAtPoint = WindowFromPoint(pt);
            // Show info for hwndAtPoint....
            }
         break;
    
      case WM_LBUTTONUP:
         if (GetCapture() == hwnd)
            {
            ReleaseCapture();
            }
         break;
    
      case WM_CANCELMODE:
         // this is a request from Windows that leave my modal state
         if (GetCapture() == hwnd)
            ReleaseCapture(hwnd);
         break;
    
      case WM_CAPTURECHANGED:
         // notification that I lost capture (I released it or it was taken from me)
         break;      
    

    The GetAncestor function can be helpful to go from the window at the point, to the top level window that own it. GetWindow can be used to walk around the window tree.

    In .NET, the Control class has a Capture property that does the same thing see
    http://msdn.microsoft.com/en-us/library/system.windows.forms.control.capture.aspx

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

Sidebar

Related Questions

I am wondering if anybody out there could explain or provide online examples (yes,
I was wondering if anybody could help me with a method of creating a
I am new to php and was wondering if anybody could help me with
I was wondering if anybody here could help me out as I'm still very
Was wondering if anybody could help. Thanks so much! Problem : blog.example.com cool.example.com redirect
I was wondering if anybody could tell me why eclipse seems determined to not
Hi i was just wondering if anybody could help me i am reading characters
Wondering if anybody could point me in the direction of academic papers or related
I was wondering if anybody could tell me how to tell when IIS last
Just wondering if anybody could tell me why import subprocess, commands p=subprocess.Popen([ls, *00080], stdout=subprocess.PIPE,

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.