Method cast for WTL classes

Introduction

There is often a need to obtain the base class function from a parameter of the type HWND. How can this be done, if it is not possible to use the static_cast method ?

This problem can be solved sufficiently simply for MFC. For example, for CScrollView, you should obtain the function method GetScrollPosition(). This is solved simply for MFC:

CMyClass::MyFunction(HWND hWnd)

{

CScrollView * p = (CScrollView *) CScrollView::FromHandle(hWnd);

CPointptScroll = pScroll->GetScrollPosition();

}

How can the analogous problem be solved in WTL?.

Let us assume we need to obtain the function

void GetScrollOffset( POINT& ptOffset)

public class CScrollWindowImpl from a parameter of the type hWnd. We create the prototype of the class of the parameter.

classCScrollView : public CScrollWindowImpl<CScrollView>

{

public:

CScrollView(HWND hWnd){ m_hWnd = hWnd; }

};

And then in MyFunction method we make

CMyClass::MyFunction(HWND hWnd)

{

……

CScrollViewtScroll(hWnd);

POINT pt;

tScroll.GetScrollOffset(pt);

WTL::CPointptScroll(pt);

}

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

I sent incomplete article, Sorry. You can see full version. I correct this problem on site.
Method cast for WTL classes.

There is often a need to obtain the base class function from a parameter of the type HWND. How can this be done, if it is not possible to use the static_cast method? This problem can be solved sufficiently simply for MFC. For example, for CScrollView, you should obtain the function GetScrollPosition() . This is solved simply for MFC:

How can the analogous problem be solved in WTL?. Let us assume we need to obtain the function void GetScrollOffset(.POINT& ptOffset) public class CScrollWindowImpl from a parameter of the type hWnd. We create the prototype of the class of the parameter.