0
我創建一個CWnd類,顯示裏面的按鈕retangle,但不是由我自己畫一個按鈕,我想委託給按鈕組件。油漆MFC組件中擁塞窗口
正如....
class ExampleControl : public CWnd
{
void ExampleControl::OnPaint()
{
CPaintDC dc(this);
CRect rc(this);
CDC memDC;
memDC.CreateCompatibleDC(&dc);
m_bmpCache.DeleteObject();
m_bmpCache.CreateCompatibleBitmap(&dc, rc.Width(), rc.Height());
OnDraw(&memDC);
}
void ExampleControl::OnDraw(CDC* pDC)
{
CRect rcClient(this);
// draw background
pDC->FillSolidRect(rcClient, GetSysColor(COLOR_WINDOW));
// draw border
COLORREF borderColor = RGB(0,0,255);
pDC->Draw3dRect(0, 0, rcClient.Width(), rcClient.Height(), borderColor, borderColor);
**//draw button
//OK this draw a button ... but I would like to write
//CRect rect(10,10,25,15);
//pDC->DrawFrameControl(rect, DFC_BUTTON, DFCS_BUTTONPUSH);**
}
}
,因爲我想成爲....
class ExampleControl : public CWnd
{
//instantiate and call myButton.Create(...)
CButton myButton;
void ExampleControl::OnPaint()
{
CPaintDC dc(this);
CRect rc(this);
CDC memDC;
memDC.CreateCompatibleDC(&dc);
m_bmpCache.DeleteObject();
m_bmpCache.CreateCompatibleBitmap(&dc, rc.Width(), rc.Height());
OnDraw(&memDC);
}
void ExampleControl::OnDraw(CDC* pDC)
{
CRect rcClient(this);
// draw background
pDC->FillSolidRect(rcClient, GetSysColor(COLOR_WINDOW));
// draw border
COLORREF borderColor = RGB(0,0,255);
pDC->Draw3dRect(0, 0, rcClient.Width(), rcClient.Height(), borderColor, borderColor);
//draw button, using the mfc component
//!!!! myButton.OnPaint() !!!!!!!
}
}
請,我該怎麼辦呢?
詩:我不能使用Dialog類不幸