Creating Shaped UI Objects by Steve Sipe Example 1: (a) // (NOTE: m_rgnWnd must be a data member, not on the stack because Windows // continues to use the region handle as long as the window object // associated with it exists) CRgn m_rgnWnd; (b) BOOL CMyDialog::OnInitDialog() { // Call the base class CDialog::OnInitDialog(); // Create a rectangular region (100x100) with rounded (30x30) corners m_rgnWnd.CreateRoundRectRgn(0,0,100,100,30,30); // Set the window's visible region to the specified shape SetWindowRgn(m_hWnd,m_rgnWnd); return TRUE; } Example 2: class CCalculator : public CDialog, public CShape { private: // Any class derived from CShape must implement this method HWND GetHWND() { return m_hWnd; } ... }; Example 3: (a) class CCalcKey : public CWnd, public CShape { // Declare the custom control class // NOTE: argument MUST match class name DECLARE_SHAPECLASS(CCalcKey); ... }; (b) (various include files) ... // Implement the custom control class // NOTE: argument MUST match class name IMPLEMENT_SHAPECLASS(CCalcKey); (Rest of CCalcKey methods below) ... Example 4: int CMyCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct) { // Create the OLE control (and CWnd object) if (COleControl::OnCreate(lpCreateStruct) == -1) return -1; // Use a CShape method to make it look like a star SetStarShape(); return 0; } ??