Click here to Skip to main content
15,888,176 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
in the name of allah

have a good time

i work with visual c++ 2012.

how can i get the "CWnd" from a "CDC" in an ActiveX project?

thanks

What I have tried:

i've tried bellow code but doesn't work.

void CLanxXCtrl::OnDraw(
CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid)
{

HWND h=WindowFromDC(pdc->m_hDC);
CWnd *w=CWnd::FromHandle(h);


...
}

this CWnd will work but cause of the ActiveX in Project is not visible, the OnDraw function doesn't work in run time.

how can i do that?
Posted
Updated 24-Feb-16 20:23pm

1 solution

You've already got a pointer to the MFC window object associated with the CDC - it's the this pointer for the function you're calling.
 
Share this answer
 
Comments
Mahdi Nejadsahebi 25-Feb-16 7:53am    
dear friend
i also use the "this" but when the application(VB.net) will be opened, error will happen.
Aescleal 25-Feb-16 13:38pm    
It sounds like you've got a more severe error. OnDraw will only be called if a WM_PAINT is received by the window. Check that your code is not doing something brain damaged like calling OnDraw manually anywhere as that'll just end in tears.

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