📄 unit7.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "stdio.h"
#include "clipbrd.hpp"
#include "Unit7.h"
#include "Unit11.h"
#include "Unit1.h"//主窗口
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TXiShouFeng *XiShouFeng;
//---------------------------------------------------------------------------
__fastcall TXiShouFeng::TXiShouFeng(TComponent* Owner)
: TForm(Owner)
{
m_bShowed = false;
}
//---------------------------------------------------------------------------
void __fastcall TXiShouFeng::FormCreate(TObject *Sender)
{
int i,j;
//StringGrid1->RowCount=5000;
StringGrid1->ColWidths[0]=25;
StringGrid1->Cells[0][0]="序号";
StringGrid1->Cells[1][0]="波长";
StringGrid1->Cells[2][0]="峰尖数值";
StringGrid2->ColWidths[0]=25;
StringGrid2->Cells[0][0]="序号";
StringGrid2->Cells[1][0]="波长";
StringGrid2->Cells[2][0]="峰谷数值";
//for(i=0;i<StringGrid1->ColCount;i++)
}
//---------------------------------------------------------------------------
void __fastcall TXiShouFeng::Button1Click(TObject *Sender)
{
if(CheckBox2->Checked)
Form1->bWLonImage=true;
else
Form1->bWLonImage=false;
if(CheckBox1->Checked)
Form1->bPVonImage=true;
else
Form1->bPVonImage=false;
Close();
}
//---------------------------------------------------------------------------
void __fastcall TXiShouFeng::FormShow(TObject *Sender)
{
int i;
float t;
char s[20];
iNum1=Form1->pkn1; iNum2=Form1->pkn2;
lpiData1=Form1->pkw1; lpiData2=Form1->pkw2;
if(iNum1!=0) StringGrid1->RowCount=iNum1+1;
else StringGrid1->RowCount=1;
if(iNum2!=0) StringGrid2->RowCount=iNum2+1;
else StringGrid2->RowCount=1;
//StringGrid1->FixedCols=1; StringGrid1->FixedRows=1;
//StringGrid2->FixedCols=1; StringGrid2->FixedRows=1;
for(i=1;i<=iNum1;i++)
{
StringGrid1->Cells[0][i]=IntToStr(i);
t=Form1->ptc.wns+(float)Form1->pkw1[i]
*(float)Form1->itl[Form1->ptc.interval]/(float)Form1->wnd0;
sprintf(s,"%3.3f",t);
StringGrid1->Cells[1][i]=s;//FloatToStr(t);//显示波长
t=Form1->tc[Form1->pkw1[i]];
switch(Form1->csd[1])
{
case 1:
break;
case 2:t=Form1->toa(t);
break;
case 3:;
}
sprintf(s,"%3.3f",t);
StringGrid1->Cells[2][i]=s;//FloatToStr(t); //显示峰值
}
for(i=1;i<=iNum2;i++)
{
StringGrid2->Cells[0][i]=IntToStr(i);
t=Form1->ptc.wns+(float)Form1->pkw2[i]
*(float)Form1->itl[Form1->ptc.interval]/(float)Form1->wnd0;
sprintf(s,"%3.3f",t);
StringGrid2->Cells[1][i]=s;//FloatToStr(t);//显示波长
t=Form1->tc[Form1->pkw2[i]];
switch(Form1->csd[1])
{
case 1:
break;
case 2:t=Form1->toa(t);
break;
case 3:;
}
sprintf(s,"%3.3f",t);
StringGrid2->Cells[2][i]=s;//FloatToStr(t); //显示峰值
}
//if(iNum1!=0||iNum2!=0)
//Form1->N9->Enabled=true;
m_bShowed = true;
cbPrintFJClick(NULL);
cbPrintFGClick(NULL);
}
//---------------------------------------------------------------------------
void __fastcall TXiShouFeng::Copy1Click(TObject *Sender)
{//点击了PMCopy1->Copy1
CopyToTClipboard(StringGrid1);
}
//---------------------------------------------------------------------------
void __fastcall TXiShouFeng::Copy2Click(TObject *Sender)
{//点击了PMCopy2->Copy2
CopyToTClipboard(StringGrid2);
}
//---------------------------------------------------------------------------
void TXiShouFeng::CopyToTClipboard(TStringGrid *sgTemp)
{//把sgTemp中被选中的部分复制到剪贴板中
int StartRow,EndRow,StartCol,EndCol;
String sTemp;
StartRow=sgTemp->Selection.Top;
EndRow=sgTemp->Selection.Bottom;
StartCol=sgTemp->Selection.Left;
EndCol=sgTemp->Selection.Right;
TClipboard *cbText=Clipboard();
cbText->AsText="";
for(int i=StartRow;i<=EndRow;i++)
{
for(int j=StartCol;j<=EndCol;j++)
{
sTemp+=sgTemp->Cells[j][i];
if(j!=EndCol) sTemp+="\t";
}
if(i!=EndRow) sTemp+="\r\n";
}
cbText->AsText=sTemp;
}
//---------------------------------------------------------------------------
void __fastcall TXiShouFeng::CopyAll1Click(TObject *Sender)
{//点击了PMCopy1->CopyAll1
TGridRect grTemp;
grTemp.Top=0;
grTemp.Left=0;
grTemp.Right=StringGrid1->ColCount-1;
grTemp.Bottom=StringGrid1->RowCount-1;
StringGrid1->Selection=grTemp;
CopyToTClipboard(StringGrid1);
}
//---------------------------------------------------------------------------
void __fastcall TXiShouFeng::CopyAll2Click(TObject *Sender)
{//点击了PMCopy2->CopyAll2
TGridRect grTemp;
grTemp.Top=0;
grTemp.Left=0;
grTemp.Right=StringGrid2->ColCount-1;
grTemp.Bottom=StringGrid2->RowCount-1;
StringGrid2->Selection=grTemp;
CopyToTClipboard(StringGrid2);
}
//---------------------------------------------------------------------------
void __fastcall TXiShouFeng::FormClose(TObject *Sender,
TCloseAction &Action)
{
Form1->DrawBK ();
Form1->DrawQX ();
if(Form1->pkw1[1]!=0||Form1->pkw2[1]!=0)
Form1->DispFengZhi();
FormPrntSetting->PrintFJ(false);
FormPrntSetting->PrintFG(false);
m_bShowed = false;
//ShowMessage("dd");
}
//---------------------------------------------------------------------------
void __fastcall TXiShouFeng::cbPrintFJClick(TObject *Sender)
{
if((cbPrintFJ->Enabled) && (m_bShowed) )
{
FormPrntSetting->PrintFJ(cbPrintFJ->Checked);
}
else
{
FormPrntSetting->PrintFJ(false);
}
}
//---------------------------------------------------------------------------
void __fastcall TXiShouFeng::cbPrintFGClick(TObject *Sender)
{
if((cbPrintFG->Enabled) && (m_bShowed))
{
FormPrntSetting->PrintFG(cbPrintFG->Checked);
}
else
{
FormPrntSetting->PrintFG(false);
}
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -