CWnd * from HWND

Given that I have a HWND is there a way to get a CWnd pointer for the window? I want to call CWnd functions for the window. I am intercepting WM_ message and I would like to call class functions to return approprite values.

Jason

LucidityAsked:
Who is Participating?
 
NickRepinConnect With a Mentor Commented:
CWnd::Attach  
BOOL Attach( HWND hWndNew );

Return Value

Nonzero if successful; otherwise 0.

Parameters

hWndNew

Specifies a handle to a Windows window.

Remarks

Attaches a Windows window to a CWnd object.

0
 
NickRepinCommented:
CWnd w;
w.Attach(hWnd);
0
 
jkrCommented:
Alternatively,

CWnd* CWnd::FromHandle();

or

CWnd* CWnd::FromHandlePermanent();

could do it also...
0
 
LucidityAuthor Commented:
Arg, I guess I missed that in MSDN.... But thanks for the regurgetation. I will try it our and get back to you.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.