📄 reportwzdfield.cpp
字号:
}
m_saFieldTitle.RemoveAll();
m_strFieldTitle.Empty();
UpdateData(FALSE);
}
void CReportWzdField::OnSelchangeListsel()
{
// TODO: Add your control notification handler code here
UpdateData();
UINT nSel = m_LBSelected.GetCurSel();
if(nSel == LB_ERR) return;
UINT nArrayCount = m_saFieldTitle.GetSize();
if(nSel >= nArrayCount) return;
CString strFieldTitle;
strFieldTitle = m_saFieldTitle.GetAt(nSel);
m_strFieldTitle = strFieldTitle;
m_uSelIndex = nSel;
UpdateData(FALSE);
}
void CReportWzdField::OnKillfocusFieldtitle()
{
// TODO: Add your control notification handler code here
UpdateData();
UINT nArrayCount = m_saFieldTitle.GetSize();
if(m_uSelIndex < nArrayCount)
m_saFieldTitle.SetAt(m_uSelIndex, m_strFieldTitle);
}
LRESULT CReportWzdField::OnWizardNext()
{
// TODO: Add your specialized code here and/or call the base class
UpdateData();
CReportWizard *psheet = (CReportWizard *) GetParent();
psheet->m_strReportTitle = m_strReportTitle;
psheet->m_strReportFooter = m_strReportFooter;
psheet->m_fHavePage = m_fUsePageNum;
psheet->m_uPageType = m_CBPageType.GetCurSel();
// fields information
CString strFieldName;
for(int i=0;i<m_LBSelected.GetCount();i++){
m_LBSelected.GetText(i, strFieldName);
psheet->m_saSelectedFields.Add(strFieldName);
}
for(i=0;i<m_saFieldTitle.GetSize();i++)
psheet->m_saSelectedFieldsTitle.Add(m_saFieldTitle.GetAt(i));
///
return CPropertyPage::OnWizardNext();
}
LRESULT CReportWzdFormat::OnWizardNext()
{
// TODO: Add your specialized code here and/or call the base class
UpdateData();
CReportWizard *psheet = (CReportWizard *) GetParent();
CString strFontName;
// font name
m_CBFontTitle.GetLBText(m_CBFontTitle.GetCurSel(), strFontName) ;
psheet->m_strFontTitle = strFontName;
m_CBFontContentHead.GetLBText(m_CBFontContentHead.GetCurSel(), strFontName) ;
psheet->m_strFontContentHead = strFontName;
m_CBFontContent.GetLBText(m_CBFontContent.GetCurSel(), strFontName) ;
psheet->m_strFontContent = strFontName;
m_CBFontFooter.GetLBText(m_CBFontFooter.GetCurSel(), strFontName) ;
psheet->m_strFontFooter = strFontName;
// font size
UINT uFontSize;
CString strSize;
CComboBox *pCombo;
pCombo = (CComboBox *)GetDlgItem(IDC_CBTITLESIZE);
pCombo->GetLBText(pCombo->GetCurSel(), strSize);
uFontSize = atoi(strSize);
psheet->m_uSizeTitle = uFontSize;
pCombo = (CComboBox *)GetDlgItem(IDC_CBHEADSIZE);
pCombo->GetLBText(pCombo->GetCurSel(), strSize);
uFontSize = atoi(strSize);
psheet->m_uSizeContentHead = uFontSize;
pCombo = (CComboBox *)GetDlgItem(IDC_CBNORMALSIZE);
pCombo->GetLBText(pCombo->GetCurSel(), strSize);
uFontSize = atoi(strSize);
psheet->m_uSizeContent = uFontSize;
pCombo = (CComboBox *)GetDlgItem(IDC_CBFOOTERSIZE);
pCombo->GetLBText(pCombo->GetCurSel(), strSize);
uFontSize = atoi(strSize);
psheet->m_uSizeFooter = uFontSize;
//
return CPropertyPage::OnWizardNext();
}
void CReportWzdFormat::OnSelchangeCbTitlefont()
{
// TODO: Add your control notification handler code here
UpdateData();
RefreshDisplay();
}
void CReportWzdFormat::OnSelchangeCbNormalfont()
{
// TODO: Add your control notification handler code here
UpdateData();
RefreshDisplay();
}
void CReportWzdFormat::OnSelchangeCbFooterfont()
{
// TODO: Add your control notification handler code here
UpdateData();
RefreshDisplay();
}
void CReportWzdFormat::OnSelchangeCbTitlesize()
{
// TODO: Add your control notification handler code here
UpdateData();
RefreshDisplay();
}
void CReportWzdFormat::OnSelchangeCbNormalsize()
{
// TODO: Add your control notification handler code here
UpdateData();
RefreshDisplay();
}
void CReportWzdFormat::OnSelchangeCbFootersize()
{
// TODO: Add your control notification handler code here
UpdateData();
RefreshDisplay();
}
void CReportWzdFormat::RefreshDisplay()
{
CDC *pDC = GetDlgItem(IDC_PREVIEWAREA)->GetDC();
if(!pDC) return;
CRect rect;
GetDlgItem(IDC_PREVIEWAREA)->GetClientRect(rect);
CBrush brush;
brush.CreateSolidBrush(RGB(255,255,255));
pDC->FillRect(rect, &brush);
//
CString line; //This is the print line
TEXTMETRIC metrics; //Font measurements
int y = 0; //Current y position on report
CFont TitleFont; //Font for Title
CFont HeadingFont; //Font for headings
CFont DetailFont; //Font for detail lines
CFont FooterFont; //Font for footer lines
//Tab stops at 1 inch, 2.5 inches, and 6.5 inches
int TabStops[] = {100, 275, 650};
CString strFontName;
CString strSize;
UINT uFontSize;
CComboBox *pSizeCB;
//Bold font for Title
m_CBFontTitle.GetLBText(m_CBFontTitle.GetCurSel(), strFontName);
pSizeCB = (CComboBox *)GetDlgItem(IDC_CBTITLESIZE);
pSizeCB->GetLBText(pSizeCB->GetCurSel(), strSize);
uFontSize = atoi(strSize);
TitleFont.CreateFont(uFontSize, 0, 0, 0, FW_BOLD, FALSE, TRUE, 0,
ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY, DEFAULT_PITCH | FF_ROMAN,
strFontName);
//Bold and underlined font for headings
m_CBFontContentHead.GetLBText(m_CBFontContentHead.GetCurSel(), strFontName);
pSizeCB = (CComboBox *)GetDlgItem(IDC_CBHEADSIZE);
pSizeCB->GetLBText(pSizeCB->GetCurSel(), strSize);
uFontSize = atoi(strSize);
HeadingFont.CreateFont(uFontSize, 0, 0, 0, FW_BOLD, FALSE, TRUE, 0,
ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY, DEFAULT_PITCH | FF_ROMAN,
strFontName);
//Normal font for detail
m_CBFontContent.GetLBText(m_CBFontContent.GetCurSel(), strFontName);
pSizeCB = (CComboBox *)GetDlgItem(IDC_CBNORMALSIZE);
pSizeCB->GetLBText(pSizeCB->GetCurSel(), strSize);
uFontSize = atoi(strSize);
DetailFont.CreateFont(uFontSize, 0, 0, 0, FW_NORMAL, FALSE, FALSE, 0,
ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY, DEFAULT_PITCH | FF_ROMAN,
strFontName);
//Footer font for detail
m_CBFontFooter.GetLBText(m_CBFontFooter.GetCurSel(), strFontName);
pSizeCB = (CComboBox *)GetDlgItem(IDC_CBFOOTERSIZE);
pSizeCB->GetLBText(pSizeCB->GetCurSel(), strSize);
uFontSize = atoi(strSize);
FooterFont.CreateFont(uFontSize, 0, 0, 0, FW_NORMAL, FALSE, FALSE, 0,
ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY, DEFAULT_PITCH | FF_ROMAN,
strFontName);
//Capture default settings when setting the title font
CFont* OldFont = pDC->SelectObject(&TitleFont);
//Retrieve the heading font measurements
pDC->GetTextMetrics(&metrics);
//Compute the heading line height
int LineHeight = metrics.tmHeight + metrics.tmExternalLeading;
// 标题
y = 2;
pDC->TextOut(rect.Width()/2 - 70, y, "标 题");
// 列标题
pDC->GetTextMetrics(&metrics);
LineHeight = metrics.tmHeight + metrics.tmExternalLeading;
y += LineHeight + 1; //Adjust y position
pDC->SelectObject(&HeadingFont);
line.Format("%s\t%s\t%s","列1","列2","列3");
pDC->TabbedTextOut(10, y, line, 2, TabStops, 0);
// 正文
pDC->GetTextMetrics(&metrics);
LineHeight = metrics.tmHeight + metrics.tmExternalLeading;
y += LineHeight + 1; //Adjust y position
pDC->SelectObject(&DetailFont);
line.Format("%s\t%s\t%s", "值1","值2","值3");
pDC->TabbedTextOut(10, y, line, 2, TabStops, 0);
// 注脚
pDC->GetTextMetrics(&metrics);
LineHeight = metrics.tmHeight + metrics.tmExternalLeading;
y += LineHeight + 1; //Adjust y position
pDC->SelectObject(&FooterFont);
line = _T("注脚");
pDC->TextOut(rect.Width() - 40, y, line);
//Restore default settings
pDC->SelectObject(OldFont);
}
void CReportWzdFormat::OnSelchangeCbheadfont()
{
// TODO: Add your control notification handler code here
UpdateData();
RefreshDisplay();
}
void CReportWzdFormat::OnSelchangeCbheadsize()
{
// TODO: Add your control notification handler code here
UpdateData();
RefreshDisplay();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -