这里有个例子,MFC在OnPaint中,调用C的绘图函数:
void C_Draw(HDC dc, HBRUSH br, RECT rc)
{
::FillRect(dc, &rc, br);
::SetTextColor(dc, RGB(255, 255, 255));
::SetBkMode(dc, TRANSPARENT);
::DrawText(dc, _T("这是C画的文字"), -1, &rc, DT_CENTER);
}
MFC的调用是:
void CMFC_CDlg::OnPaint()
{
CPaintDC dcPaint(this);
CRect rcClient;
GetClientRect(rcClient);
CBrush br;
br.CreateSolidBrush(RGB(79, 201, 100));
C_Draw(dcPaint.m_hDC, (HBRUSH)br.m_hObject, rcClient);
}