BorderRemove example for C++ 4.0 and later

   short nRet;
   //Border Remove
   //This example updates a region with the borders of a bitmap

   //For the example, windows regions are passed to the BorderRemove Event and combined.
   //In practice it would be easier and faster to just update a LEAD region representing the changes
   //The border is removed from the image
   
   //Create a NULL region
   hRgnAll = CreateRectRgn(0, 0, 0, 0);

   nRet = m_LEAD1.BorderRemove(BORDER_CALLBACK_REGION | BORDER_USE_VARIANCE,
                               BORDER_TOP | BORDER_BOTTOM | BORDER_LEFT | BORDER_RIGHT,
                               20, 2, 5);
                             
   if(nRet == 0)
   {
      m_LEAD1.FreeRgn();
      m_LEAD1.SetRgnHandle((OLE_HANDLE)hRgnAll, 0.0f, 0.0f, L_RGN_SET);
      m_LEAD1.SetRgnFrameType(RGNFRAME_ANIMATED);
   }
   //delete the Windows Rgn
   DeleteObject(hRgnAll);

void CDoccleanDlg::OnBorderRemoveLeadctrl1(long hRgn, long uBorderToRemove, float fBoundingRectLeft, float fBoundingRectTop, float fBoundingRectWidth, float fBoundingRectHeight) 
{
   CString szBorder;
   CString csOut;
   CombineRgn(hRgnAll, hRgnAll, (HRGN)hRgn, RGN_OR);
   switch(uBorderToRemove)
   {
   case BORDER_TOP:
      szBorder = "Top";
   case BORDER_LEFT:
      szBorder = "Left";
   case BORDER_RIGHT:
      szBorder = "Right";
   case BORDER_BOTTOM:
      szBorder = "Bottom";
   }
   csOut.Format("Border - %s Bounds:%d,%d,%d,%d",
                szBorder,
                (long)fBoundingRectLeft,
                (long)fBoundingRectTop,
                (long)fBoundingRectWidth,
                (long)fBoundingRectHeight);
   m_LEAD1.SetDocCleanSuccess(SUCCESS_REMOVE);
}