Win32 api - how to check if a specified handle is a window? (and isn't a control inside a window)

StackOverflow https://stackoverflow.com/questions/22276691

Pregunta

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).

¿Fue útil?

Solución

if (GetWindowLong(hWnd, GWL_STYLE) & WS_CHILD) {
    // window is a child window
} else {
    // window is a top-level window
}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top