Question

My aim is to get the handle of a window I click. I'm using a global mouse hook and then GetCursorPos and WindowFromPoint). When I click on a button (or other controls) I get the button's handle. Using GetParent I can find the parent window, so I need to check if the handle I have is a window or not.

I have tried GetClassName but it's not what I'm looking for.

Any ideas appreciated (also using other approaches).

Was it helpful?

Solution

if (GetWindowLong(hWnd, GWL_STYLE) & WS_CHILD) {
    // window is a child window
} else {
    // window is a top-level window
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top