//
CProjectMFCReportView 메시지처리기
void
CProjectMFCReportView::OnDraw(CDC* pDC)
{
CProjectMFCReportDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if (!pDoc)
return;
int y_Position=0;
if(pDC->IsPrinting())
{
pDC->SetMapMode(MM_ISOTROPIC);
pDC->SetWindowExt(100, 100);
pDC->SetViewportExt(800, 800);
}
// Area
CRect reArea(0, 0, 594, 841);
SetBkMode(pDC->m_hDC, TRANSPARENT);
// Font List
CFont ftReport, ftMyNumber, tfTitle, tfInfo, *OldFont;
ftReport.CreateFont(60, 0, 0, 0,FW_HEAVY,FALSE, FALSE,
FALSE,
ANSI_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY,VARIABLE_PITCH | FF_SWISS, _T("Times New Roman"));
ftMyNumber.CreateFont(13, 0, 0, 0,FW_HEAVY,FALSE, FALSE,
FALSE,ANSI_CHARSET,OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,VARIABLE_PITCH | FF_SWISS, _T("Lucida Grande"));
tfTitle.CreateFont(15, 0, 0, 0,FW_HEAVY,FALSE, FALSE,
FALSE,ANSI_CHARSET,OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,VARIABLE_PITCH |
FF_SWISS,
_T("Lucida
Grande"));
tfInfo.CreateFont(13, 0, 0, 0,FW_NORMAL,FALSE, FALSE,
FALSE,ANSI_CHARSET,OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,VARIABLE_PITCH |
FF_SWISS,
_T("Lucida
Grande"));
// Rectangle
int off = 20;
// pDC->Rectangle(reArea.left, reArea.top,
reArea.right, reArea.bottom);
pDC->Rectangle(reArea.left+off, reArea.top+off, reArea.right-off,
reArea.bottom-off);
// REPORT
y_Position = 25;
TCHAR tcReport[10];
wsprintf(tcReport, _T("REPORT"));
OldFont = pDC->SelectObject(&ftReport);
SetTextAlign(pDC->m_hDC, TA_CENTER);
pDC->TextOutW(reArea.right/2, reArea.top+y_Position, tcReport,
lstrlen(tcReport));
pDC->SelectObject(OldFont);
SetTextAlign(pDC->m_hDC, TA_LEFT);
// Line 1 : y = 90
y_Position = 90;
pDC->MoveTo(reArea.left+55, reArea.top+y_Position
);
pDC->LineTo(reArea.right-55, reArea.top+y_Position);
// Div : y = 100 ~ 120
y_Position = 100;
TCHAR tcMyNumber[20], tcDate[20], tcMyText[60],
tcMyName[50];
CTime Today = CTime::GetCurrentTime();
OldFont = pDC->SelectObject(&ftMyNumber);
SetTextAlign(pDC->m_hDC, TA_CENTER);
SetTextColor(pDC->m_hDC, RGB(100, 100, 100));
wsprintf(tcMyNumber, _T("2005
02219"));
wsprintf(tcDate, _T("%d.%d.%d, %d:%d"),
Today.GetDay(), Today.GetMonth(), Today.GetYear(), Today.GetHour(),
Today.GetMinute());
wsprintf(tcMyText, _T("%s // %s"),
tcMyNumber, tcDate);
pDC->TextOutW(reArea.right/2, reArea.top+y_Position, tcMyText,
lstrlen(tcMyText));
y_Position+=20;
wsprintf(tcMyName, _T("D.S
Shin"));
pDC->TextOutW(reArea.right/2, reArea.top+y_Position, tcMyName,
lstrlen(tcMyName));
pDC->SelectObject(OldFont);
SetTextAlign(pDC->m_hDC, TA_LEFT);
// Line 2
y_Position+=20;
pDC->MoveTo(reArea.left+55,
reArea.top+y_Position);
pDC->LineTo(reArea.right-55,
reArea.top+y_Position);
// FILE title
y_Position+=20;
TCHAR tcFileTitle[20];
OldFont = pDC->SelectObject(&tfTitle);
SetTextColor(pDC->m_hDC, RGB(0, 0, 0));
wsprintf(tcFileTitle, _T("FILE")
);
pDC->TextOutW(reArea.left + 55, 160, tcFileTitle,
lstrlen(tcFileTitle));
pDC->SelectObject(OldFont);
// FILE info
y_Position+=25;
TCHAR tcPath[500], tcName[200], tcExtention[200];
OldFont = pDC->SelectObject(&tfInfo);
SetTextColor(pDC->m_hDC, RGB(0, 0, 0));
wsprintf(tcPath, _T("Path : ")
);
wsprintf(tcName, _T("Name :
"));
wsprintf(tcExtention, _T("Extention :
"));
pDC->TextOutW(reArea.left + 80, y_Position, tcPath,
lstrlen(tcPath));
y_Position+=25;
pDC->TextOutW(reArea.left + 80, y_Position, tcName,
lstrlen(tcName));
y_Position+=25;
pDC->TextOutW(reArea.left + 80, y_Position, tcExtention,
lstrlen(tcExtention));
pDC->SelectObject(OldFont);
// DATA title : y = 300
y_Position+=40;
TCHAR tcDataTitle[20];
OldFont = pDC->SelectObject(&tfTitle);
SetTextColor(pDC->m_hDC, RGB(0, 0, 0));
wsprintf(tcDataTitle, _T("DATA")
);
pDC->TextOutW(reArea.left + 55, y_Position, tcDataTitle,
lstrlen(tcDataTitle));
pDC->SelectObject(OldFont);
// DATA info : y = 330
y_Position+=25;
TCHAR tcPoint[50], tcUV[50],
tcMax[50], tcMin[50],
tcSize[50], tcMesh[50], tcFlag[50],
tcModified[100];
OldFont = pDC->SelectObject(&tfInfo);
SetTextColor(pDC->m_hDC, RGB(0, 0, 0));
wsprintf(tcPoint, _T("Point : ")
);
wsprintf(tcUV, _T("U, V :
"));
wsprintf(tcMax, _T("Max :
"));
wsprintf(tcMin, _T("Min :
"));
wsprintf(tcSize, _T("Size :
"));
wsprintf(tcMesh, _T("Mesh :
"));
wsprintf(tcFlag, _T("Flag :
"));
wsprintf(tcModified, _T("Modified Mesh :
"));
pDC->TextOutW(reArea.left + 80, y_Position, tcPoint,
lstrlen(tcPoint));
y_Position+=25;
pDC->TextOutW(reArea.left + 80, y_Position, tcUV,
lstrlen(tcUV));
y_Position+=25;
pDC->TextOutW(reArea.left + 80, y_Position, tcMax,
lstrlen(tcMax));
y_Position+=25;
pDC->TextOutW(reArea.left + 80, y_Position, tcMin,
lstrlen(tcMin));
y_Position+=25;
pDC->TextOutW(reArea.left + 80, y_Position, tcSize,
lstrlen(tcSize));
y_Position+=25;
pDC->TextOutW(reArea.left + 80, y_Position, tcMesh,
lstrlen(tcMesh));
y_Position+=25;
pDC->TextOutW(reArea.left + 80, y_Position, tcFlag,
lstrlen(tcFlag));
y_Position+=25;
pDC->TextOutW(reArea.left + 80, y_Position, tcModified,
lstrlen(tcModified));
pDC->SelectObject(OldFont);
// REVISION title : y =
560
y_Position+=40;
TCHAR tcRevisionTitle[20];
OldFont = pDC->SelectObject(&tfTitle);
SetTextColor(pDC->m_hDC, RGB(0, 0, 0));
wsprintf(tcRevisionTitle, _T("REVISION")
);
pDC->TextOutW(reArea.left + 55, y_Position, tcRevisionTitle,
lstrlen(tcRevisionTitle));
pDC->SelectObject(OldFont);
// REVISION info : y =
590
y_Position+=25;
TCHAR tcTranslate[200], tcRotate[200];
OldFont = pDC->SelectObject(&tfInfo);
SetTextColor(pDC->m_hDC, RGB(0, 0, 0));
wsprintf(tcTranslate, _T("Translate : ")
);
wsprintf(tcRotate, _T("Rotate :
"));
pDC->TextOutW(reArea.left + 80, y_Position, tcTranslate,
lstrlen(tcTranslate));
y_Position+=25;
pDC->TextOutW(reArea.left + 80, y_Position, tcRotate,
lstrlen(tcRotate));
pDC->SelectObject(OldFont);
// Set-Value title : y =
630
y_Position+=40;
TCHAR tcSetValue[20];
TCHAR tcColor[20];
OldFont = pDC->SelectObject(&tfTitle);
SetTextColor(pDC->m_hDC, RGB(0, 0, 0));
wsprintf(tcSetValue, _T("Set-Value")
);
wsprintf(tcColor, _T("Color"));
pDC->TextOutW(reArea.left + 55, y_Position, tcSetValue,
lstrlen(tcSetValue));
pDC->TextOutW(reArea.right/2 + 25, y_Position, tcColor,
lstrlen(tcColor));
pDC->SelectObject(OldFont);
// Set-Value info : y =
660
y_Position+=25;
TCHAR tcMeshType[50], tcMeshVector[50], tcClipping[50], tcPerspective[50],
tcLightPosition[50],
tcPointColor[50], tcMeshColor[50], tcFaceColor[50], tcLightColor[50],
tcBackgroundColor[50];
OldFont = pDC->SelectObject(&tfInfo);
SetTextColor(pDC->m_hDC, RGB(0, 0, 0));
wsprintf(tcMeshType, _T("Mesh type : ")
);
wsprintf(tcMeshVector, _T("Mesh vector :
"));
wsprintf(tcClipping, _T("Clipping :
"));
wsprintf(tcPerspective, _T("Perspective :
"));
wsprintf(tcLightPosition, _T("Light position :
"));
wsprintf(tcPointColor, _T("Point color :
"));
wsprintf(tcMeshColor, _T("Mesh color :
"));
wsprintf(tcFaceColor, _T("Face color :
"));
wsprintf(tcLightColor, _T("Light color :
"));
wsprintf(tcBackgroundColor, _T("Background color :
"));
pDC->TextOutW(reArea.left + 80, y_Position, tcMeshType,
lstrlen(tcMeshType));
pDC->TextOutW(reArea.right/2 + 50, y_Position, tcPointColor,
lstrlen(tcPointColor));
y_Position+=25;
pDC->TextOutW(reArea.left + 80, y_Position, tcMeshVector,
lstrlen(tcMeshVector));
pDC->TextOutW(reArea.right/2 + 50, y_Position, tcMeshColor,
lstrlen(tcMeshColor));
y_Position+=25;
pDC->TextOutW(reArea.left + 80, y_Position, tcClipping,
lstrlen(tcClipping));
pDC->TextOutW(reArea.right/2 + 50, y_Position, tcFaceColor,
lstrlen(tcFaceColor));
y_Position+=25;
pDC->TextOutW(reArea.left + 80, y_Position, tcPerspective,
lstrlen(tcPerspective));
pDC->TextOutW(reArea.right/2 + 50, y_Position, tcLightColor,
lstrlen(tcLightColor));
y_Position+=25;
pDC->TextOutW(reArea.left + 80, y_Position, tcLightPosition,
lstrlen(tcLightPosition));
pDC->TextOutW(reArea.right/2 + 50, y_Position, tcBackgroundColor,
lstrlen(tcBackgroundColor));
pDC->SelectObject(OldFont);
// Line 3
pDC->MoveTo(reArea.left+55,
reArea.bottom-80);
pDC->LineTo(reArea.right-55, reArea.bottom-80);
// Div...
OldFont = pDC->SelectObject(&ftMyNumber);
TCHAR tcMecha[128];
SetTextAlign(pDC->m_hDC, TA_CENTER);
SetTextColor(pDC->m_hDC, RGB(100, 100, 100));
wsprintf(tcMecha, _T("Div. Of Mechanical and auto
motive Engineering Kong-ju National University"));
pDC->TextOutW(reArea.right/2, reArea.bottom-70, tcMecha,
lstrlen(tcMecha));
SetTextAlign(pDC->m_hDC, TA_LEFT);
pDC->SelectObject(OldFont);
}
코드를 보면 알겠지만, y축 거리를 내려오면서 단계적으로 텍스트를 출력하고 있음을 알 수 있다.
이 중에서, 아래와 같은 코드가 가장 중요한 위치를 차지한다.
if(pDC->IsPrinting())
{
pDC->SetMapMode(MM_ISOTROPIC);
pDC->SetWindowExt(100,
100);
pDC->SetViewportExt(800,
800);
}
<그림 1 :: Report 양식>
<그림 1>은 필자가 초기에 구상했던 '출력용' 리포트 양식(hwp 작성)이다.
물론 구성 변수들이 지금과는 많이 다르지만, 아무튼 이런 양식을 따르기로 마음 먹은 것은 변하지 않았다.
그런데 만약 if(pDC->IsPrinting()) { (생략) } 의 코드를 넣지 않는다면, 인쇄 미리보기에서 <그림 2>와 같은 모습을 볼 수 있다.
<그림 2 :: 뭥미>
<그림 3 :: if문 적용한 인쇄 미리보기>
하지만 if문을 적용했다면 <그림 3>과 같이 바뀐 모습을 볼 수 있다.
매핑(mapping)기술이 들어간 것인데 자세한 것은 MFC 서적을 참고할 수 있기를 바란다.
개인적으로 필자는 Visual C++2008 MFC 윈도우 프로그래밍, 최호성, 프리렉 서적을 구입하여 참고했다.
(쿠폰 긁어놓고 동영상 강의를 제대로 보지 않아서 아깝다...)
이 정도 기초 틀을 다져놓았다면 아래와 같은 데이터 타입을 만들어주자.
<그림 4 :: 리포트 데이터>
ProjectOpenGL 에 포함했던 데이터 타입과 똑같아야 한다.
일단 이 프로젝트도 여기까지다.