我有一个模式较少的对话框,我已经使用SetWindowRgn()将形状更改为一个圆角。我想用FrameRgn在它周围画一个彩色边框。下面是我使用如何在MFC的非矩形窗口中绘制边框
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
}
void CMyDlg::OnPaint()
{
CPaintDC dc(this); // device context for painting
CBrush brush;
brush.CreateSolidBrush(RGB(255,0,0));
dc.FrameRgn(&m_rgnShape, &brush, 2, 2);
}
任何人都可以解释为什么FrameRgn不工作,也许在这里提供一些示例代码 ,这将使它的工作代码。
嗨,我改变了代码,当我绘制一个多边形shaped.Now边界显示,但只为多边形的两侧。你可以告诉我如何控制它。现在,边界不是来多边形的所有边。 – user2336139 2013-05-01 06:21:08
这可能是由于你在对话框上有一个边框 - 我会在我的答案中添加一些内容来解释。 – icabod 2013-05-01 15:58:24