mfc_pattern_brush - 8BitsCoding/RobotMentor GitHub Wiki
// Dlg.h
CBrush m_my_brush;
CBrush m_num_brush;
void CMFCApplication1Dlg::OnLButtonDown(UINT nFlags, CPoint point)
{
CClientDC dc(this);
CBrush * p_old_brush = dc.SelectObject(&m_my_brush);
dc.SetBrushOrg(point.x - 24, point.y - 24);
// dc.Rectangle(point.x-24, point.y-24, point.x+24, point.y+24);
dc.Ellipse(point.x - 24, point.y - 24, point.x + 24, point.y + 24);
dc.SelectObject(p_old_brush);
CDialogEx::OnLButtonDown(nFlags, point);
}
void CMFCApplication1Dlg::OnMouseMove(UINT nFlags, CPoint point)
{
/*
if (nFlags & MK_LBUTTON) {
if (point.x < 160 && point.y < 48) {
CClientDC dc(this);
CBrush * p_old_brush = dc.SelectObject(&m_num_brush);
CGdiObject * p_old_pen = dc.SelectStockObject(NULL_PEN);
dc.Rectangle(point.x - 5, point.y - 5, point.x + 5, point.y + 5);
dc.SelectObject(p_old_brush);
dc.SelectObject(p_old_pen);
}
}
*/
CDialogEx::OnMouseMove(nFlags, point);
}
void CMFCApplication1Dlg::OnPaint()
{
CPaintDC dc(this); // 그리기λ₯Ό μν λλ°μ΄μ€ 컨ν
μ€νΈμ
λλ€.
if (IsIconic())
{
// ...
}
else
{
// CBrush * p_old_brush = dc.SelectObject(&m_my_brush);
// dc.Rectangle(0, 0, 200, 200);
dc.FillSolidRect(0, 0, 160, 48, RGB(218, 218, 218));
// dc.SelectObject(p_old_brush);
// CDialogEx::OnPaint();
}
}
BOOL CMFCApplication1Dlg::OnInitDialog()
{
CDialogEx::OnInitDialog();
// μ΄ λν μμμ μμ΄μ½μ μ€μ ν©λλ€. μμ© νλ‘κ·Έλ¨μ μ£Ό μ°½μ΄ λν μμκ° μλ κ²½μ°μλ
// νλ μμν¬κ° μ΄ μμ
μ μλμΌλ‘ μνν©λλ€.
SetIcon(m_hIcon, TRUE); // ν° μμ΄μ½μ μ€μ ν©λλ€.
SetIcon(m_hIcon, FALSE); // μμ μμ΄μ½μ μ€μ ν©λλ€.
// TODO: μ¬κΈ°μ μΆκ° μ΄κΈ°ν μμ
μ μΆκ°ν©λλ€.
CBitmap my_bmp, num_bmp;
my_bmp.LoadBitmapW(IDB_TH_IMAGE);
num_bmp.LoadBitmapW(IDB_NUM_IMAGE);
m_my_brush.CreatePatternBrush(&my_bmp);
m_num_brush.CreatePatternBrush(&num_bmp);
return TRUE; // ν¬μ»€μ€λ₯Ό 컨νΈλ‘€μ μ€μ νμ§ μμΌλ©΄ TRUEλ₯Ό λ°νν©λλ€.
}