when use GetFocus() get Different Hwnd

i use this function ..
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
HWND GetFocusGlobal()
{
    HWND Wnd;
    HWND Result = NULL;
    DWORD TId, PId;

    Result = GetFocus();
    if (!Result)
    {
        Wnd = GetForegroundWindow();
        if(Wnd)
        {
            TId = GetWindowThreadProcessId(Wnd, &PId);
            if (AttachThreadInput(GetCurrentThreadId(), TId, TRUE))
            {
                Result = GetFocus();
                AttachThreadInput(GetCurrentThreadId(), TId, FALSE);
            }            
        }
    }
    return Result;
}

My problem return a different hwnd !
but when passing return value from GetFocusGlobal() to this function GetClassName() return true classname ..
True Hwnd is : 0x30450 and GetFocusGlobal() return this Hwnd: 0x3044e
Last edited on
Topic archived. No new replies allowed.