title: How to draw border in a non rectangular window in MFC
body: <p>I have a mode less dialog that I have changed the shape into a roundrect using SetWindowRgn(). I would like to draw a colored border around it using FrameRgn. Here is the code I am using</p>
  
  <pre><code>BOOL CMyDlg::OnInitDialog() 
   {
   CDialog::OnInitDialog(); m_Brush.CreateSolidBrush(RGB(255,255,255));
   CRect rcDialog;
   GetClientRect(rcDialog);
  
   // This Creates area assigned to Dialog: This goes directly below the above in OnInitDialog
   m_rgnShape.CreateRoundRectRgn(rcDialog.TopLeft().x, rcDialog.TopLeft().y,rcDialog.BottomRight().x,rcDialog.BottomRight().y, rcDialog.Width()/8, rcDialog.Height()/8);
  ::SetWindowRgn(GetSafeHwnd(), (HRGN)m_rgnShape, TRUE);
  
  return TRUE; // return TRUE unless you set the focus to a control
    // EXCEPTION: OCX Property Pages should return FALSE
  </code></pre>
  
  <p>}</p>
  
  <pre><code>void CMyDlg::OnPaint() 
  {
   CPaintDC dc(this); // device context for painting
  
   CBrush brush;
   brush.CreateSolidBrush(RGB(255,0,0));
  
    dc.FrameRgn(&amp;m_rgnShape, &amp;brush, 2, 2);
  }
  </code></pre>
  
  <p>Can anyone explain why the FrameRgn is not working, and maybe provide some sample code here 
  that will make it work.</p>