|
-
December 27th, 2009, 01:33 AM
#1
Finding the HWND which has the focus
When a user selects a file , I want to know which Window has the current focus .
Just to explain, I am providing a scnearios.
1) User selects abc.txt on the Desktop
2) User selects xyz.doc in the Explorer.
Though both files have the LVM_SELECTED flag set, I want to get the handle of the window in which the file has been selected.
I tried with GetForegroundWindow, and GetGUIThreadInfo , but its not working.
Any sort of help would be appreicated
Sujay
-
December 27th, 2009, 10:13 AM
#2
Re: Finding the HWND which has the focus
is this what you seek?:
Code:
HWND hFocusWnd = GetFocus();
GetFocus()
-
December 27th, 2009, 10:36 AM
#3
Re: Finding the HWND which has the focus
I dont think it shall do.
Intially I thought of this, but if you see selecting a file on the desktop , need the windows of the Listview of the destkop , not just the desktop.
After that I want to compare the two desktop handles and accordingly let the user know.
Last edited by sujayg; December 27th, 2009 at 10:44 AM.
Reason: Updated info
-
December 27th, 2009, 04:37 PM
#4
Re: Finding the HWND which has the focus
and GetGUIThreadInfo , but its not working
"It's not working" explains not much. A code would do a lot better.
Last edited by Igor Vartanov; December 27th, 2009 at 04:39 PM.
Best regards,
Igor
-
December 27th, 2009, 05:39 PM
#5
Re: Finding the HWND which has the focus
 Originally Posted by sujayg
After that I want to compare the two desktop handles and accordingly let the user know.
What are you hoping to let the user know?
-
December 27th, 2009, 11:16 PM
#6
Re: Finding the HWND which has the focus
 Originally Posted by Arjay
What are you hoping to let the user know?
Let me explain the situation . I think it would be better than the technical terms .
1) User selects abc.txt on the Desktop
2) User selects xyz.doc in the Explorer.
If the user presses Ctrl+C, the file xyz.doc gets copied ONLY . That is Windows copies only the file which has the current focus .
How does Windows knows which one has the current focus? I have do this programatically .
-
December 28th, 2009, 04:43 AM
#7
Re: Finding the HWND which has the focus
Windows knows it because only one window has the focus at a time, and the window in focus gets the copy command and it places it's contents inside the clipboard, and second app gets it by pasting operation from clipboard.
Regards,
Ramkrishna Pawar
-
December 28th, 2009, 05:33 AM
#8
Re: Finding the HWND which has the focus
You are right.
For example, if one has to get the desktop HWND, one has to find the handle of the Syslistview32 within the Program Manager .
In my case I want to compare the HWND's and see which HWND has the focus
-
December 28th, 2009, 02:08 PM
#9
Re: Finding the HWND which has the focus
 Originally Posted by sujayg
Let me explain the situation . I think it would be better than the technical terms .
1) User selects abc.txt on the Desktop
2) User selects xyz.doc in the Explorer.
If the user presses Ctrl+C, the file xyz.doc gets copied ONLY . That is Windows copies only the file which has the current focus .
How does Windows knows which one has the current focus? I have do this programatically .
Windows knows this because the listcontrol receives the CTRL+C message and the control itself knows which item(s) has been selected.
If you tell us what you are actually trying to accomplish we may be able to suggest a solution.
-
December 28th, 2009, 02:12 PM
#10
Re: Finding the HWND which has the focus
Hi Arjay,
I want to find the path of the selected file.
The user can select a file in the desktop and also on the explorer.
But I want to get the path of the file which has the focus.
Sujay
Last edited by sujayg; December 28th, 2009 at 02:13 PM.
Reason: Updated info
-
December 28th, 2009, 02:41 PM
#11
Re: Finding the HWND which has the focus
The hwnd to the window in focus isn't going to help because the best you can do is get the hwnd to the listcontrol containing the selected file, but not the selected file itself.
What you need to do is to register for a shell change event. This will tell you when items have been selected or deselected. See this link http://msdn.microsoft.com/en-us/libr...20(VS.85).aspx. At the bottom of the link there is another link to an sdk sample called "Change Notify Watcher Sample". Once you get the notification you should be able to retrieve the path of the selected item with IShellLink:GetPath.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|