2009-09-19 3 views
1

누구나 왜 이것이 작동하지 않는지 알 수 있습니까?FindWindow 대 GetActiveWindow - 왜 differnt 핸들을 반환합니까?

IntPtr hWnd = FindWindow(null, "Calculator"); 
IntPtr hWnd2 = GetActiveWindow(); 

if(hWnd == hWnd2) 
{ 
    MessageBox.Show("Same"); 
} 

를 불러옵니다은 다음과 같습니다

[DllImport("user32.dll")] 
static extern IntPtr GetActiveWindow(); 

[DllImport("user32.dll", SetLastError = true)] 
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName); 
+0

응용 프로그램을 실행할 때 활성 창을 계산기로 설정하는 방법은 무엇입니까? – scottm

+0

나는 그것을 마우스로 클릭 할 것인가? 나는 대답을 추가해 냈다. –

답변

1

그것은 GetActiveWindow()가 응용 프로그램/명령 창 핸들을 반환하는 것이 매우 가능하다.

+0

맞습니다. -'GetActiveWindow'는 호출 스레드의 활성 창에 대한 참조를 반환합니다. 여기에있는 문서 : http://msdn.microsoft.com/en-us/library/windows/desktop/ms646292.aspx – Blorgbeard

1

"GetActiveWindow"가 하위 영역을 반환하는 것으로 보입니다.

GetForegroundWindow()가 Windows 핸들을 반환합니다.

관련 문제