Click here to Skip to main content
15,897,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Experts
My problem is that
I am not able to understand that how to access window property like its name, class and text contain inside it by using handle of that window.???
I am able to find its handle and its caption of that selected window
but am not able to display it inside dialog box control, it is displaying only on message box.
Plz help
Thanks in advanced...
Posted

1 solution

Here is the problem: how come you don't have a pointer to the instance of MFC CWnd (or whatever you use)?

Certainly, as CWnd installs it's Window procedure for handling raw Windows messages, it should keep "this" pointer in raw Windows API data, which is usually done by UI libraries build on Windows API. This is the way to keep mapping between the class instance with OOP-library and raw Window data. But — if this is your application, you already have this pointer; if not — getting this pointer is not helpful, because you cannot safely cast it to the MFC class you might assume, as nothing can guarantee that the window was build using MFC; and MFC of the same version as you use.

Also, do understand that Windows API registered Window class of the class derived from any MFC class are two absolutely different things.

Now, if you need just the window text, you can use GetWindowText, see http://msdn.microsoft.com/en-us/library/ms633520%28v=vs.85%29.aspx[^].

[EDIT]
To extract other information from the raw Window handle, use the function GetWindowLong, see http://msdn.microsoft.com/en-us/library/ms633584(v=vs.85).aspx[^]. Potentially the pointer to the instance of the UI library class can be stored at the index GWL_USERDATA, but nothing can guarantee you any certain interpretation of this pointer or valid type cast you can use if this is not your application.

—SA
 
Share this answer
 
v3
Comments
R. S. Verma 28-Jul-11 1:03am    
Hi Experts,
Thanks for replying ...
Actually I already used GetWindowText, and I mentioned above it in my question, now I need to extract other information and i need to display it on dialog's textboxes or on the labels....
I need Help Regarding this.
I have done Mouse hooking and keyboard hooking and by using MOUSEHOOKSTRUCT Structure I am able to access its current window handle. All thing are happening using MFC Code itself.
But Problem now is dat am not able to Go Ahead or beyond that.
Plz Help me to know more about it.
Thanks ...
Sergey Alexandrovich Kryukov 28-Jul-11 1:33am    
About other information: see my update above, after [EDIT]. This is all you can do. I suspect your problem is architectural. You could try to explain your ***ultimate*** goal to get more help. It looks like the way you're trying to go is not quite right from the very beginning.
Thanks for accepting this answer.
Good luck, call again.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900