mfc_custom_window - 8BitsCoding/RobotMentor GitHub Wiki

ํด๋ž˜์Šค ๋งˆ๋ฒ•์‚ฌ -> ํด๋ž˜์Šค ์ถ”๊ฐ€ -> MFC ํด๋ž˜์Šค

์ด๋ฏธ์ง€

// Dlg.h
#include "UserWnd.h"

private:
    UserWnd m_user_w;
// Dlg.cpp
// OnInitDialog()
CRect r;
r.SetRest(50, 50, 200, 200);

m_user_w.Create(NULL, NULL, WS_VISIBLE | WS_CHILD | WS_VORDER, r, this, 25000);

์ด๋ฏธ์ง€


์œˆ๋„์šฐ์— ์ƒˆ๋กœ ๊ทธ๋ ค๋ณด์ž

ํด๋ž˜์Šค ๋งˆ๋ฒ•์‚ฌ -> WM_PAINT ์ƒ์„ฑ

์ด๋ฏธ์ง€

// OnPaint()
CPaintDC dc(this);

CRect r;
GetClientRect(r);

dc.FillSolidRect(r, RGB(0, 0, 255));

์ด๋ฏธ์ง€

ํด๋ฆญ์ด ๋˜๋ฉด ๋นจ๊ฐ„์ƒ‰์œผ๋กœ ๋ณ€๊ฒฝ

ํด๋ž˜์Šค ๋งˆ๋ฒ•์‚ฌ -> WM_LBUTTON_DOWN

// OnLButtonDownn
{
    CRect r;
    r.SetRect(point.x - 10, point.y - 10, point + 10, point.y + 10);

    CClientDC dc(this);
    dc.FillSolidRect(r, RGB(255, 0, 0,));
}