dlg_loginfo.cpp
来自「对日本KSG震动探测仪器编写的伴侣服务代码」· C++ 代码 · 共 486 行
CPP
486 行
// (Version 1.00 :: 10-Mar-1999 :: Harutoshi Yoshida)
/*===================================================================
俲俽俧(恔搙忣曬僱僢僩儚乕僋)
-----------------------------------
捠怣儘僌偺昞帵丄嶍彍
-----------------------------------
Program Name : Dlg_LogInfo.cpp
Program Start : 26-Dec-1998
===================================================================*/
#include "stdafx.h"
#include "MSdefine.h"
#include "KSG.h"
#include "Dlg_LogInfo.h"
#include "Dlg_Print.h"
#include "msflexgrid.h"
#include "C_File.h"
#include "C_Proc.h"
#include "C_Work.h"
#include "KSG_Main.h"
#if !C_DEFINE_INC
#include "C_Define.h"
#endif
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define GMAX_COL 7
#define GMAX_ROW 40
char *LI_Grid_title[GMAX_COL] = { // 僌儕僢僪偺僞僀僩儖
// ver 1.30
//"敪拝怣擔晅", // 00
//"抂枛斣崋", // 01
//"娤應揰柤徧", // 02
//"庴敪怣", // 03
//"僐儅儞僪乛寢壥", // 04
//"儊僢僙乕僕", // 05
//"僄儔乕売強" // 06
"敪拝怣擔晅", // 00
"抂枛斣崋", // 01
"娤應揰柤徧", // 02
"庴敪怣", // 03
"Command乛寢壥", // 04
"Message", // 05
"Error強嵼" // 06
};
short LI_Grid_width[GMAX_COL] = { // 僌儕僢僪偺暆(暥帤悢仏俀亄俆侽)
(1700+ 500), // 00
( 850 ), // 01
(1050+ 200), // 02
( 650+ 350), // 03
(1450+ 800), // 04
(1050+ 500), // 05
(1050+ 200) // 06
};
/////////////////////////////////////////////////////////////////////////////
// CDlg_LogInfo 僟僀傾儘僌
CDlg_LogInfo::CDlg_LogInfo(CWnd* pParent /*=NULL*/)
: CDialog(CDlg_LogInfo::IDD, pParent)
{
//{{AFX_DATA_INIT(CDlg_LogInfo)
// 儊儌 - ClassWizard 偼偙偺埵抲偵儅僢僺儞僌梡偺儅僋儘傪捛壛傑偨偼嶍彍偟傑偡丅
//}}AFX_DATA_INIT
}
void CDlg_LogInfo::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDlg_LogInfo)
// 儊儌 - ClassWizard 偼偙偺埵抲偵儅僢僺儞僌梡偺儅僋儘傪捛壛傑偨偼嶍彍偟傑偡丅
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDlg_LogInfo, CDialog)
//{{AFX_MSG_MAP(CDlg_LogInfo)
ON_WM_CLOSE()
ON_BN_CLICKED(IDC_BTN_DEL, OnBtnDel)
ON_BN_CLICKED(IDC_BTN_PRINT, OnBtnPrint)
ON_BN_CLICKED(IDC_BTN_EXIT, OnBtnExit)
ON_BN_CLICKED(IDC_BTN_BACK, OnBtnBack)
ON_BN_CLICKED(IDC_BTN_NEXT, OnBtnNext)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDlg_LogInfo 儊僢僙乕僕 僴儞僪儔
/*=====================================
m:26-Dec-1998
@p << initialize >>
=====================================*/
BOOL CDlg_LogInfo::OnInitDialog()
{
CMSFlexGrid* pGrid;
int row, col;
CDialog::OnInitDialog();
pOpenDlg = this;
// 儊僯儏乕儃僞儞(倃)丗柍岠
GetSystemMenu(FALSE)->EnableMenuItem(SC_CLOSE, MF_DISABLED);
pGrid = (CMSFlexGrid*)GetDlgItem(IDC_MSFLEXGRID);
pGrid->SetCols(GMAX_COL);
pGrid->SetRows(GMAX_ROW+1);
pGrid->SetRow(0);
for (col=0;col<GMAX_COL;col++){
pGrid->SetCol(col);
pGrid->SetCellAlignment(flexAlignCenterCenter);
pGrid->SetText(LI_Grid_title[col]);
pGrid->SetColWidth(col, LI_Grid_width[col]);
}
for (row=1;row<=GMAX_ROW;row++){
pGrid->SetRow(row);
for (col=0;col<GMAX_COL;col++){
pGrid->SetCol(col);
pGrid->SetCellAlignment(flexAlignCenterCenter);
}
}
Dsp_Start = 0; // 昞帵奐巒俬値倓倕倶
PageSet();
return (TRUE);
}
/*=====================================
@p << Dialog Close >>
=====================================*/
void CDlg_LogInfo::OnClose()
{
dialog_close(DSP_LGI);
CDialog::OnOK();
}
/*=====================================
@p << 俷俲儃僞儞 >>
=====================================*/
void CDlg_LogInfo::OnOK()
{
return;
}
/*=====================================
@p << 僉儍儞僙儖儃僞儞 >>
=====================================*/
void CDlg_LogInfo::OnCancel()
{
return;
}
/*=====================================
m:26-Dec-1998
@p << 侾夋柺昞帵 >>
=====================================*/
void CDlg_LogInfo::PageSet()
{
int a, col, row, index, ap, dp;
int cnt, p, siz, enp, hdl;
char buf[64], bf2[64];
CMSFlexGrid* pGrid;
CC_File pFile;
ap = (LogMaxR-1) / GMAX_ROW;
if ((LogMaxR-1) % GMAX_ROW) {
ap ++;
}
dp = Dsp_Start / GMAX_ROW + 1;
sprintf(buf, "(%d/%d)", dp, ap);
SetDlgItemText(IDC_STC_PN, buf);
pGrid = (CMSFlexGrid*)GetDlgItem(IDC_MSFLEXGRID);
pGrid->ShowWindow(SW_HIDE); // 僌儕僢僪旕昞帵
index = LogMaxR - Dsp_Start; // 昞帵奐巒俬値倓倕倶
index -= GMAX_ROW;
if (index < 1){
index = 1;
}
cnt = LogMaxR - index;
if ((cnt%GMAX_ROW) == 0 && (cnt != 0)) {
cnt = GMAX_ROW;
}
else {
cnt = cnt % GMAX_ROW;
}
index *= sizeof(S_ComLog);
siz = cnt * sizeof(S_ComLog);
// 捠怣儘僌撉崬傒
hdl = pFile.Open(Data_dir[FLE_LOG], _O_BINARY | O_RDWR);
pFile.Seek(hdl, index, SEEK_SET);
pFile.Read(hdl, (char*) LogDspBuf, siz);
pFile.Close(hdl);
index /= sizeof(S_ComLog);
// 僨乕僞昞帵
for (row=1;row<=cnt;row++){
p = cnt - row;
pGrid->SetRow(row);
enp = LogDspBuf[p].Ch_Num;
// 00:敪拝怣擔晅
pGrid->SetCol(0);
sprintf(buf, "%04d/%02d/%02d %02d:%02d:%02d",
LogDspBuf[p].Dtm.yer, // 00:擭
//p+index, // for debug
LogDspBuf[p].Dtm.mon, // 01:寧
LogDspBuf[p].Dtm.day, // 02:擔
LogDspBuf[p].Dtm.hor, // 03:帪
LogDspBuf[p].Dtm.min, // 04:暘
LogDspBuf[p].Dtm.sec // 05:昩
);
pGrid->SetText(buf);
// 01:抂枛斣崋
pGrid->SetCol(1);
sprintf(buf, "%d", AdrEntDat[enp].TrmNo);
pGrid->SetText(buf);
// 02:娤應揰柤徧
pGrid->SetCol(2);
pGrid->SetText(AdrEntDat[enp].AdrName);
// 03:庴敪怣
pGrid->SetCol(3);
if (LogDspBuf[p].RcvSnd){ // 庴敪怣 (0:庴怣 / 1:憲怣)
pGrid->SetText("憲怣");
}
else{
pGrid->SetText("庴怣");
}
// 04:僐儅儞僪乛寢壥
pGrid->SetCol(4);
a = LogDspBuf[p].CmdNum; // 僐儅儞僪 (0~13)
if (a < 0 || a > 13){ // 僐儅儞僪柍偟
pGrid->SetText("");
}
else{
memmove(bf2, S_Cmd_Tbl[a], 8); bf2[8] = 0;
sprintf(buf, "%s(%d)", bf2, LogDspBuf[p].ResNum);
pGrid->SetText(buf);
}
// 05:儊僢僙乕僕
pGrid->SetCol(5);
a = LogDspBuf[p].MesNum; // 儊僢僙乕僕
if (a < 0 || a >= RCMD_MAX){
a = 0;
}
pGrid->SetText(R_Cmd_Tbl[a]);
// 06:僄儔乕売強
pGrid->SetCol(6);
sprintf(buf, "%d", LogDspBuf[p].ErrNum);
pGrid->SetText(buf);
}
// 僋儕傾
for (;row<=GMAX_ROW;row++){
pGrid->SetRow(row);
for (col=0;col<GMAX_COL;col++){
pGrid->SetCol(col);
pGrid->SetText("");
}
}
pGrid->ShowWindow(SW_SHOW); // 僌儕僢僪昞帵
pGrid->SetRow(1);
OnClickMsflexgrid();
}
/*=====================================
m:26-Dec-1998
@p << 慜儁乕僕 >>
=====================================*/
void CDlg_LogInfo::OnBtnBack()
{
PageChange(-1);
}
/*=====================================
m:26-Dec-1998
@p << 師儁乕僕 >>
=====================================*/
void CDlg_LogInfo::OnBtnNext()
{
PageChange(1);
}
/*=====================================
m:26-Dec-1998
@p << 嶍彍儃僞儞 >>
=====================================*/
void CDlg_LogInfo::OnBtnDel()
{
CMSFlexGrid* fxGrid;
CC_File pFile;
CString cbuf;
int s_row, e_row, dsp_srow, dsp_erow;
int cnt, hdl, lct;
int a, siz;
long s_index, d_index;
if (LogMaxR > 1) {
fxGrid = (CMSFlexGrid*)this->GetDlgItem(IDC_MSFLEXGRID);
dsp_srow = fxGrid->GetRow();
dsp_erow = fxGrid->GetRowSel();
fxGrid->SetCol(0);
fxGrid->SetRow(dsp_srow);
cbuf = fxGrid->GetText();
if (cbuf != "") {
fxGrid->ShowWindow(SW_HIDE);
for (a=dsp_srow+1; a<=dsp_erow; a++) {
fxGrid->SetRow(a);
cbuf = fxGrid->GetText();
if (cbuf == "") {
dsp_erow = a - 1;
break;
}
}
fxGrid->ShowWindow(SW_SHOW);
s_row = LogMaxR - Dsp_Start - dsp_erow;
e_row = LogMaxR - Dsp_Start - dsp_srow + 1;
// 嶍彍
d_index = s_row * sizeof(S_ComLog);
s_index = e_row * sizeof(S_ComLog);
cnt = LogMaxR - e_row;
lct = cnt / GMAX_ROW;
siz = GMAX_ROW * sizeof(S_ComLog);
hdl = pFile.Open(Data_dir[FLE_LOG], _O_BINARY | O_RDWR);
for (a=0;a<lct;a++) {
pFile.Seek(hdl, s_index, SEEK_SET);
s_index += siz;
pFile.Read(hdl, (char*)LogDspBuf, siz);
pFile.Seek(hdl, d_index, SEEK_SET);
d_index += siz;
pFile.Write(hdl, (char*)LogDspBuf, siz);
}
lct = cnt % GMAX_ROW;
if (lct) {
siz = lct * sizeof(S_ComLog);
pFile.Seek(hdl, s_index, SEEK_SET);
pFile.Read(hdl, (char*)LogDspBuf, siz);
pFile.Seek(hdl, d_index, SEEK_SET);
pFile.Write(hdl, (char*)LogDspBuf, siz);
}
// index couneter 彂偒崬傒
LogMaxR -= (e_row - s_row);
pFile.Seek(hdl, 0L, SEEK_SET);
pFile.Write(hdl, (char*) &LogMaxR, 4);
pFile.Close(hdl);
if (Dsp_Start >= (LogMaxR-1)) {
Dsp_Start -= GMAX_ROW;
if (Dsp_Start < 0) {
Dsp_Start = 0;
}
}
PageSet();
}
}
}
/*=====================================
m:26-Dec-1998
@p << 報嶞儃僞儞 >>
=====================================*/
void CDlg_LogInfo::OnBtnPrint()
{
CDlg_Print pDlg;
int ret;
ret = pDlg.DoModal();
if (ret == IDOK) {
Print_dat[0] = 0; // MAX/徻嵶
Print_dat[1] = 0; // 尰/慡儁乕僕
Print_dat[2] = 0; // 尰瓦凹轓o.
Print_dat[3] = 1; // 慡僨乕僞悢
Print_dat[4] = 1; // 報嶞枃悢
Print_dat[5] = Dsp_Start; // 僗僞乕僩No. 曐懚
if (Print_NowAll == 1) { // 慡儁乕僕報嶞?
Print_dat[1] = 1;
Print_dat[3] = LogMaxR;
Print_dat[4] = (LogMaxR-1) / LOG_PRT_MAX;
if (((LogMaxR-1) % LOG_PRT_MAX) != 0) {
Print_dat[4] ++;
}
Dsp_Start = 0;
PageSet();
}
Print_req = Disp.Num;
}
}
/*=====================================
m:26-Dec-1998
@p << 栠傞儃僞儞 >>
=====================================*/
void CDlg_LogInfo::OnBtnExit()
{
DspReqStack(DSP_LOG);
}
/*=====================================
m:16-Jan-1999
@p << 儁乕僕愗傝懼偊 >>
=====================================*/
void CDlg_LogInfo::PageChange(int dir)
{
int d;
d = Dsp_Start;
if (dir == -1) {
Dsp_Start -= GMAX_ROW;
if (Dsp_Start < 0){
Dsp_Start = 0;
}
if (d != Dsp_Start){
PageSet();
}
}
else {
Dsp_Start += GMAX_ROW;
if (Dsp_Start >= (LogMaxR-1)){
Dsp_Start -= GMAX_ROW;
}
if (d != Dsp_Start){
PageSet();
}
}
}
BEGIN_EVENTSINK_MAP(CDlg_LogInfo, CDialog)
//{{AFX_EVENTSINK_MAP(CDlg_LogInfo)
ON_EVENT(CDlg_LogInfo, IDC_MSFLEXGRID, -600 /* Click */, OnClickMsflexgrid, VTS_NONE)
//}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()
/*=====================================
m:26-Dec-1998
@p << 僌儕僢僪巜掕 >>
=====================================*/
void CDlg_LogInfo::OnClickMsflexgrid()
{
CMSFlexGrid* fxGrid;
CString buf;
long row;
fxGrid = (CMSFlexGrid*)this->GetDlgItem(IDC_MSFLEXGRID);
row = fxGrid->GetRow();
Sel_SRow = fxGrid->GetRow(); // 巜掕奐巒峴
Sel_ERow = fxGrid->GetRowSel(); // 巜掕廔椆峴
if (Sel_SRow > Sel_ERow){
row = Sel_SRow;
Sel_SRow = Sel_ERow;
Sel_ERow = row;
}
fxGrid->SetCol(0);
fxGrid->SetRow(Sel_SRow);
fxGrid->SetColSel(GMAX_COL-1);
fxGrid->SetRowSel(Sel_ERow);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?