C++ Programming
12-05-2009, 03:12 AM
I have to return the path of the selected file , EITHER in the Desktop or in the Windows Explorer.
I can get the path of the selected file both on the Windows Explorer and the desktop
My problem is that I am unable to find which window has the current focus
1) The user has selected a file on the desktop
2) The user has selected a file in the Windows explorer. ( So this has the focus now )
How do I programatically find that out
I am using the following code
HWND hWndDesktop = GetDesktopHandle(); // Gets the handle of the SyslistView32 window
DWORD dwThread = ::GetWindowThreadProcessId(hWndDesktop, NULL);
GUITHREADINFO gtf ;
gtf.cbSize = sizeof(GUITHREADINFO);
BOOL b = GetGUIThreadInfo(dwThread, >f);
if(hWndDesktop == gtf.hwndFocus)
{
// this window currently has the focus
}
But I am getting different handles for hWndDesktop and gtf.hwndFocus .
Please let me know if I am missing something
Thanks
Sujay
I can get the path of the selected file both on the Windows Explorer and the desktop
My problem is that I am unable to find which window has the current focus
1) The user has selected a file on the desktop
2) The user has selected a file in the Windows explorer. ( So this has the focus now )
How do I programatically find that out
I am using the following code
HWND hWndDesktop = GetDesktopHandle(); // Gets the handle of the SyslistView32 window
DWORD dwThread = ::GetWindowThreadProcessId(hWndDesktop, NULL);
GUITHREADINFO gtf ;
gtf.cbSize = sizeof(GUITHREADINFO);
BOOL b = GetGUIThreadInfo(dwThread, >f);
if(hWndDesktop == gtf.hwndFocus)
{
// this window currently has the focus
}
But I am getting different handles for hWndDesktop and gtf.hwndFocus .
Please let me know if I am missing something
Thanks
Sujay