BAI THUC HANH SO 2 WINDOW
2 posters
Trang 1 trong tổng số 1 trang
BAI THUC HANH SO 2 WINDOW
//Em không biết kèm theo file, mong các anh chị thông cảm
void CChildView::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
// Do not call CWnd::OnPaint() for painting messages
CPoint points[10];
int npts = 0;
CRect rect;
GetClientRect (&rect);
rect.SetRect(0,0,rect.Width()/3, rect.Height()/2);
for (int i=0; i<2; i++)
{
for (int j=0; j<3; j++)
{
http://dc.Rectangle(&rect);
switch (i*3+j) /// thu tu cua cac hcn i*3+j
{
case 0:
dc.MoveTo(rect.TopLeft());
dc.LineTo(rect.BottomRight());
break;
case 1:
points[npts++] = rect.TopLeft();
points[npts++] = CPoint(rect.left + rect.Width()/4, rect.bottom);
points[npts++] = rect.CenterPoint();
points[npts++] = CPoint(rect.left + 3*rect.Width()/4, rect.bottom);
points[npts++] = CPoint(rect.right, rect.top);
dc.Polyline(points, npts);
break;
case 2:
{
npts=0;
points[npts++] = rect.TopLeft();
points[npts++] = CPoint(rect.left + rect.Width()/4, rect.bottom);
points[npts++] = CPoint(rect.left + rect.Width()/2, rect.top);
points[npts++] = CPoint(rect.left + rect.Width()/2, rect.bottom);
points[npts++] = CPoint(rect.left + 3*rect.Width()/4, rect.top);
points[npts++] = rect.BottomRight();
const DWORD a[2]={3,3};
dc.PolyPolyline(points,a,2);
dc.DrawText(_T("Line"), &rect, DT_CENTER|DT_VCENTER|DT_SINGLELINE);
}
break;
case 3:
npts = 0;
points[npts++] = rect.TopLeft();
points[npts++] = CPoint(rect.right, rect.top);
points[npts++] = CPoint(rect.left, rect.bottom);
points[npts++] = rect.BottomRight();
dc.PolyBezier(points, npts);
break;
case 4:
npts = 0;
points[npts++] = CPoint(rect.CenterPoint().x, rect.bottom);
points[npts++] = CPoint(rect.right, rect.top + rect.Height()/3);
points[npts++] = CPoint(rect.right - rect.Width()/4, rect.top);
points[npts++] = CPoint(rect.CenterPoint().x, rect.top + rect.Height()/3);
points[npts++] = CPoint(rect.left + rect.Width()/4, rect.top);
points[npts++] = CPoint(rect.left, rect.top + rect.Height()/3);
points[npts++] = points[0];
dc.PolyBezier(points, npts);
// line, polyline, bezier, polybezier
// ve text drawtext
}
rect.OffsetRect(rect.Width(),0);
}
rect.OffsetRect(-3*rect.Width(), rect.Height());
}
}
void CChildView::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
// Do not call CWnd::OnPaint() for painting messages
CPoint points[10];
int npts = 0;
CRect rect;
GetClientRect (&rect);
rect.SetRect(0,0,rect.Width()/3, rect.Height()/2);
for (int i=0; i<2; i++)
{
for (int j=0; j<3; j++)
{
http://dc.Rectangle(&rect);
switch (i*3+j) /// thu tu cua cac hcn i*3+j
{
case 0:
dc.MoveTo(rect.TopLeft());
dc.LineTo(rect.BottomRight());
break;
case 1:
points[npts++] = rect.TopLeft();
points[npts++] = CPoint(rect.left + rect.Width()/4, rect.bottom);
points[npts++] = rect.CenterPoint();
points[npts++] = CPoint(rect.left + 3*rect.Width()/4, rect.bottom);
points[npts++] = CPoint(rect.right, rect.top);
dc.Polyline(points, npts);
break;
case 2:
{
npts=0;
points[npts++] = rect.TopLeft();
points[npts++] = CPoint(rect.left + rect.Width()/4, rect.bottom);
points[npts++] = CPoint(rect.left + rect.Width()/2, rect.top);
points[npts++] = CPoint(rect.left + rect.Width()/2, rect.bottom);
points[npts++] = CPoint(rect.left + 3*rect.Width()/4, rect.top);
points[npts++] = rect.BottomRight();
const DWORD a[2]={3,3};
dc.PolyPolyline(points,a,2);
dc.DrawText(_T("Line"), &rect, DT_CENTER|DT_VCENTER|DT_SINGLELINE);
}
break;
case 3:
npts = 0;
points[npts++] = rect.TopLeft();
points[npts++] = CPoint(rect.right, rect.top);
points[npts++] = CPoint(rect.left, rect.bottom);
points[npts++] = rect.BottomRight();
dc.PolyBezier(points, npts);
break;
case 4:
npts = 0;
points[npts++] = CPoint(rect.CenterPoint().x, rect.bottom);
points[npts++] = CPoint(rect.right, rect.top + rect.Height()/3);
points[npts++] = CPoint(rect.right - rect.Width()/4, rect.top);
points[npts++] = CPoint(rect.CenterPoint().x, rect.top + rect.Height()/3);
points[npts++] = CPoint(rect.left + rect.Width()/4, rect.top);
points[npts++] = CPoint(rect.left, rect.top + rect.Height()/3);
points[npts++] = points[0];
dc.PolyBezier(points, npts);
// line, polyline, bezier, polybezier
// ve text drawtext
}
rect.OffsetRect(rect.Width(),0);
}
rect.OffsetRect(-3*rect.Width(), rect.Height());
}
}
Được sửa bởi nguyenducvong_i83c ngày 28/10/2009, 15:26; sửa lần 1.
nguyenducvong_i83c- Tổng số bài gửi : 23
Join date : 30/09/2009
Age : 38
Đến từ : Kom Tum
Re: BAI THUC HANH SO 2 WINDOW
Lập trình Windows chứ hỏng phải là java.
NguyenTanToan_I83C- Tổng số bài gửi : 43
Join date : 18/09/2009
Similar topics
» Thông báo dời lịch thi thực hành môn LT Window
» Giúp mình về bài thực hành LT Window
» Những Bài Tập Thực Hành Môn Hệ Điều Hành -Thầy Vũ Lê Hùng - Chủ đề 1: Mô phỏng
» Thi thuc hanh mon thuat giai: Khi nao lop mình thi thực hành vay các ban?
» Thảo luận Bài 7
» Giúp mình về bài thực hành LT Window
» Những Bài Tập Thực Hành Môn Hệ Điều Hành -Thầy Vũ Lê Hùng - Chủ đề 1: Mô phỏng
» Thi thuc hanh mon thuat giai: Khi nao lop mình thi thực hành vay các ban?
» Thảo luận Bài 7
Trang 1 trong tổng số 1 trang
Permissions in this forum:
Bạn không có quyền trả lời bài viết