Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Win32 (http://www.go4expert.com/forums/win32/)
-   -   How to convert 'HRGN' to 'CRgn (http://www.go4expert.com/forums/convert-hrgn-crgn-t20679/)

answerme 16Jan2010 14:30

How to convert 'HRGN' to 'CRgn
 
Hi All
I am trying to call GetUpdateRgn() function in Onpaint() but iam getting error
Code:

error C2664: 'CWnd::GetUpdateRgn' : cannot convert parameter 1 from 'HRGN' to 'CRgn
I tried to typecast HRGN to CRgn but it didnt work out ,below iam sending the code

Code:

HRGN m_hUpdateRgn;
GetUpdateRgn(m_hUpdateRgn,0);
CPaintDC dc(m_hWnd);
dc.FrameRgn(m_hUpdateRgn,NULL,4,4);


Gene Poole 16Jan2010 19:58

Re: How to convert 'HRGN' to 'CRgn
 
CRgn is an MFC class wrapper for the HRGN handle as used by the API. You have to declare a CRgn object, then attach it to the HRGN handle:

Code:

HRGN m_hUpdateRgn;
CRgn MyRgn;

GetUpdateRgn(m_hUpdateRgn,0);
MyRgn.FromHandle(m_hUpdateRgn);
CPaintDC dc(m_hWnd);
dc.FrameRgn(MyRgn,NULL,4,4);



All times are GMT +5.5. The time now is 10:23.