msdn里在介绍Draw3dRect函数时附了一个例子如下:
void CMyView::OnDraw(CDC* pDC)
{
// Get the client area.
CRect rect;
GetClientRect(rect); // Shrink the rectangle 20 pixels on all sides.
rect.DeflateRect(20, 20); // Draw a rectangle with red top and left sides, and
// green right and bottom sides.
pDC->Draw3dRect(rect, RGB(255, 0, 0), RGB(0, 255, 0)); // This call to the four-integer override draws
// the same rectangle with a less convenience. // pDC->Draw3dRect(rect.left, rect.top, rect.Width(), rect.Height(),
// RGB(255, 0, 0), RGB(0, 255, 0));
}
但是如果我要在别的地方调用,在对话框上画出来这个立方体,这个pdc变量是个什么东西?小弟是个初学者,让大家见笑了。
void CMyView::OnDraw(CDC* pDC)
{
// Get the client area.
CRect rect;
GetClientRect(rect); // Shrink the rectangle 20 pixels on all sides.
rect.DeflateRect(20, 20); // Draw a rectangle with red top and left sides, and
// green right and bottom sides.
pDC->Draw3dRect(rect, RGB(255, 0, 0), RGB(0, 255, 0)); // This call to the four-integer override draws
// the same rectangle with a less convenience. // pDC->Draw3dRect(rect.left, rect.top, rect.Width(), rect.Height(),
// RGB(255, 0, 0), RGB(0, 255, 0));
}
但是如果我要在别的地方调用,在对话框上画出来这个立方体,这个pdc变量是个什么东西?小弟是个初学者,让大家见笑了。
CClientDC dc(this);
现在你就可以象用pDC一样用了,不过这个不是指针,你可以这样用。
dc.Draw3dRect(....);
GetClientRect(rect);
rect.DeflateRect(5, 5);
CClientDC dc(this);
dc.Draw3dRect(,RGB(255,0,0),RGB(0,255,0));
另外,我就是换成坐标,画出来的也不过是个矩形而已,怎么不是立方体啊?
如果只是画一个按钮的话可以用DrawFrameControl