國立暨南國際大學 99 學年度第二學期小考試卷

科目名稱:程式設計 開課系所:資訊工程 學系 任課教師
吳坤熹
系所別:
年級:
學號:
姓名:
考試日期
2011.6.15

(考試時間: 16:30-16:45)

  1. (10%) Please down load the project QUIZ 12 at http://ipv6.ncnu.org/Course/C_Programming.992/quiz-12.zip.  Uncompress and build it. Try to change the pen width.  What problem do you observe, and how should you correct it?
    CRect CElement::GetBoundRect(void)
    {
    CRect boundingRect(m_EnclosingRect); // Object to store bounding rectangle

    // Increase the rectangle by the pen width and return it
    int Offset = (m_PenWidth == 0) ? 1 : m_PenWidth;
    // Width must be at least 1
    boundingRect.InflateRect(Offset, Offset);
    return boundingRect;
    }

    CLine::CLine(const CPoint& start, const CPoint& end, COLORREF aColor, int penWidth)
    {
    m_StartPoint = start;
    m_EndPoint = end;
    m_Color = aColor;
    m_PenWidth = penWidth; // Set pen width

    // Define the enclosing rectangle
    m_EnclosingRect = CRect(start, end);
    m_EnclosingRect.NormalizeRect();
    }

    void CSketcherDoc::OnPenWidth()
    {
    // Create a local dialog object
    CPenDialog aDlg;

    // Set the pen width in the dialog to that stored in the document
    aDlg.m_PenWidth = m_PenWidth;

    // Display the dialog as modal
    if (aDlg.DoModal() == IDOK)
    aDlg.DoModal();
    }