📄 main.cpp
字号:
if( celldisp == NULL)
{
ShowMessage("请选择单元格!");
return;
}
frmBorder->LeftLine->Checked =cellline_d->LeftLine;
frmBorder->TopLine->Checked =cellline_d->TopLine ;
frmBorder->RightLine->Checked =cellline_d->RightLine ;
frmBorder->BottomLine->Checked =cellline_d->BottomLine ;
frmBorder->Edit_LeftWidth->Value =cellline_d->LeftLineWidth;
frmBorder->Edit_TopWidth->Value =cellline_d->TopLineWidth ;
frmBorder->Edit_RightWidth->Value =cellline_d->RightLineWidth ;
frmBorder->Edit_BottomWidth->Value =cellline_d->BottomLineWidth ;
if( frmBorder->ShowModal()==IDOK)
{
CNReportControl1->SetCellLines(
frmBorder->LeftLine->Checked,
frmBorder->TopLine->Checked,
frmBorder->RightLine->Checked,
frmBorder->BottomLine->Checked,
frmBorder->Edit_LeftWidth->Value,
frmBorder->Edit_TopWidth->Value,
frmBorder->Edit_RightWidth->Value,
frmBorder->Edit_BottomWidth->Value
);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmMain::cbFontChange(TObject *Sender)
{
TLogFont CellFont;
TFont *cf;
if( celldisp != NULL)
{
cf = new TFont;
cf->Name = cbFont->Items->Strings[cbFont->ItemIndex];
cf->Size = cbFontSize->Text.ToInt();
if( btBold->Down) cf->Style = cf->Style << fsBold;
if( btItalic->Down) cf->Style = cf->Style << fsItalic;
if( btUnderline->Down) cf->Style = cf->Style << fsUnderline;
GetObject(cf->Handle,sizeof(CellFont),&CellFont);
delete cf;
CNReportControl1->SetCellFont(CellFont);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmMain::btFontClick(TObject *Sender)
{
TLogFont CellFont;
HDC hTempDC;
TPoint pt, ptOrg;
if( cellline_d != NULL)
{
hTempDC = GetDC(0);
pt.y = abs(CNReportControl1->CellFont_d.lfHeight) * 720 / GetDeviceCaps(hTempDC, LOGPIXELSY);
DPtoLP(hTempDC, &pt, 1);
ptOrg.x = 0;
ptOrg.y = 0;
DPtoLP(hTempDC, &ptOrg, 1);
FontDialog1->Font->Name = CNReportControl1->CellFont_d.lfFaceName;
FontDialog1->Font->Size = ((pt.y - ptOrg.y)/10);
if( FontDialog1->Execute())
{
GetObject(FontDialog1->Font->Handle,sizeof(CellFont),&CellFont);
CNReportControl1->SetCellFont(CellFont);
}
}
else
{
Application->MessageBox("请选择单元格!!!", "警告", MB_OK | MB_ICONWARNING);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmMain::btColorClick(TObject *Sender)
{
if( celldisp == NULL)
{
Application->MessageBox("请选择单元格!!!", "警告", MB_OK | MB_ICONWARNING);
return;
}
frmColor->TextColor = (TColor)celldisp->TextColor;
frmColor->BkColor = (TColor)celldisp->BkColor;
if(frmColor->ShowModal() == IDOK)
{
CNReportControl1->SetCellColor(frmColor->TextColor,frmColor->BkColor);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmMain::btNewClick(TObject *Sender)
{
ReportFile = "";
Caption = ReportFile;
CNReportControl1->ResetContent();
}
//---------------------------------------------------------------------------
void __fastcall TfrmMain::btDiagonalClick(TObject *Sender)
{
int nDiagonal = 0;
if( celldisp == NULL)
{
Application->MessageBox("请选择单元格!!!", "警告", MB_OK | MB_ICONWARNING);
return;
}
frmDiagonal->LeftDiagonal1->Checked = (celldisp->Diagonal & LINE_LEFT1);
frmDiagonal->LeftDiagonal2->Checked = (celldisp->Diagonal & LINE_LEFT2);
frmDiagonal->LeftDiagonal3->Checked = (celldisp->Diagonal & LINE_LEFT3);
frmDiagonal->RightDiagonal1->Checked = (celldisp->Diagonal & LINE_RIGHT1);
frmDiagonal->RightDiagonal2->Checked = (celldisp->Diagonal & LINE_RIGHT2);
frmDiagonal->RightDiagonal3->Checked = (celldisp->Diagonal & LINE_RIGHT3);
if( frmDiagonal->ShowModal() == IDOK)
{
if (frmDiagonal->LeftDiagonal1->Checked)
nDiagonal = nDiagonal | LINE_LEFT1;
if (frmDiagonal->LeftDiagonal2->Checked)
nDiagonal = nDiagonal | LINE_LEFT2;
if (frmDiagonal->LeftDiagonal3->Checked)
nDiagonal = nDiagonal | LINE_LEFT3;
if (frmDiagonal->RightDiagonal1->Checked)
nDiagonal = nDiagonal | LINE_RIGHT1;
if (frmDiagonal->RightDiagonal2->Checked)
nDiagonal = nDiagonal | LINE_RIGHT2;
if (frmDiagonal->RightDiagonal3->Checked)
nDiagonal = nDiagonal | LINE_RIGHT3;
CNReportControl1->SetCellDiagonal(nDiagonal);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmMain::btPrinterSetupClick(TObject *Sender)
{
if(PrinterSetupDialog1->Execute())
{
pgw = 0;
CNReportControl1->CalcWndSize();
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmMain::btTableSetupClick(TObject *Sender)
{
TRect MarginRect;
MarginRect = CNReportControl1->GetMargin();
frmPageSetup->Edit_LeftMargin->Value = MarginRect.Left;
frmPageSetup->Edit_TopMargin->Value = MarginRect.Top;
frmPageSetup->Edit_RightMargin->Value = MarginRect.Right;
frmPageSetup->Edit_BottomMargin->Value = MarginRect.Bottom;
frmPageSetup->Edit_MaxLine->Value = CNReportControl1->DataLine;
frmPageSetup->Edit_LinePerPage->Value = CNReportControl1->TablePerPage;
if( frmPageSetup->ShowModal()== IDOK)
{
CNReportControl1->SetMargin(frmPageSetup->Edit_LeftMargin->Value,
frmPageSetup->Edit_TopMargin->Value,
frmPageSetup->Edit_RightMargin->Value,
frmPageSetup->Edit_BottomMargin->Value);
CNReportControl1->DataLine = frmPageSetup->Edit_MaxLine->Value;
CNReportControl1->TablePerPage = frmPageSetup->Edit_LinePerPage->Value ;
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmMain::N6Click(TObject *Sender)
{
if(SaveDialog1->Execute())
{
ReportFile = SaveDialog1->FileName;
}
CNReportControl1->SaveToFile(ReportFile);
}
//---------------------------------------------------------------------------
void __fastcall TfrmMain::FormShow(TObject *Sender)
{
TempFile = "";
char WinDir[256];
GetWindowsDirectory(WinDir,256);
TempFile = WinDir;
TempFile = TempFile + "\\temp\\" + TEMP_EPT;
ReportFile = "";
pgw = 0;
CNReportControl1->CalcWndSize();
}
//---------------------------------------------------------------------------
void __fastcall TfrmMain::ScrollBox1Resize(TObject *Sender)
{
if (ClientRect.Right > (CNReportControl1->Width + 20) )
CNReportControl1->Left = (ClientRect.Right - CNReportControl1->Width)/2 - 12;
else
CNReportControl1->Left = 10;
}
//---------------------------------------------------------------------------
void __fastcall TfrmMain::FormCanResize(TObject *Sender, int &NewWidth,
int &NewHeight, bool &Resize)
{
btEditToolBar->Width = NewWidth;
tbNormalBar->Width = NewWidth;
tbMenuBar->Width = NewWidth;
}
//---------------------------------------------------------------------------
void __fastcall TfrmMain::FormCloseQuery(TObject *Sender, bool &CanClose)
{
if( ReportFile == "")
{
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmMain::pmNormarlClick(TObject *Sender)
{
((TMenuItem *)Sender)->Checked = !((TMenuItem *)Sender)->Checked;
btEditToolBar->Visible = pmEdit->Checked;
tbNormalBar->Visible = pmNormarl->Checked;
SB->Visible = pmStatus->Checked;
}
//---------------------------------------------------------------------------
void __fastcall TfrmMain::N48Click(TObject *Sender)
{
cbZoom->Text = "100";
CNReportControl1->SetScale(100);
if(CNReportControl1->Width > ScrollBox1->Width)
{
CNReportControl1->Left = 0;
}
else
{
CNReportControl1->Left = (ScrollBox1->Width - CNReportControl1->Width) /2;
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmMain::N28Click(TObject *Sender)
{
TfrmAbout *About = new TfrmAbout(this);
About->ShowModal();
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -