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 conditio开发者_Python百科n that the window i need has class "#32770 (Dialog)". But ::FindWindowExA(calcHwnd, 0, "#32770 (Dialog)", 0) - returns NULL. GetLastError returns 0. What is wrong?
#32770
is actually a class atom. Try:
HWND contentHwnd = ::FindWindowExA(calcHwnd, NULL, MAKEINTRESOURCE(32770), NULL);
精彩评论