1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

How to convert 'HRGN' to 'CRgn

Discussion in 'Win32' started by answerme, Jan 16, 2010.

  1. answerme

    answerme New Member

    Joined:
    Dec 17, 2007
    Messages:
    114
    Likes Received:
    0
    Trophy Points:
    0
    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);
     
  2. Gene Poole

    Gene Poole New Member

    Joined:
    Nov 10, 2009
    Messages:
    93
    Likes Received:
    5
    Trophy Points:
    0
    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);
    
     

Share This Page