[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 734
  • Last Modified:

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

0
Lucidity
Asked:
Lucidity
  • 2
1 Solution
 
NickRepinCommented:
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

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now