Alex
Alex

Reputation: 177

Couldn't find child window using FindWindowExA()

Trying to get button's handle on window calculator's form. Spy++ shows the following tree:

("Calculator"; CalcFrame) ->

(""; CalcFrame) ->

(""; #32770 Dialog), ...anather child windows ->

(""; Button) ,... another child windows

// ("window caption"; window class) // -> next child level

I catch main window and go deeper using FindWindowExA();

#define wndName "Calculator"
...
    HWND calcHwnd = ::FindWindowA(0, wndName);
    HWND frameHwnd = ::FindWindowExA(calcHwnd, 0, 0, 0);
    HWND contentHwnd = ::FindWindowExA(calcHwnd, 0, "#32770 (Dialog)", 0);
    DWORD er = GetLastError();

I could use ::FindWindowExA(calcHwnd, 0, 0, 0) several times to get the HWND I need(at that level there are several child windows). but i want to get HWND using condition that the window i need has class "#32770 (Dialog)". But ::FindWindowExA(calcHwnd, 0, "#32770 (Dialog)", 0) - returns NULL. GetLastError returns 0. What is wrong?

Upvotes: 1

Views: 2440

Answers (1)

Frédéric Hamidi
Frédéric Hamidi

Reputation: 262939

#32770 is actually a class atom. Try:

HWND contentHwnd = ::FindWindowExA(calcHwnd, NULL, MAKEINTRESOURCE(32770), NULL);

Upvotes: 2

Related Questions