📄 logtodlg.cpp
字号:
// logtoDlg.cpp : implementation file
//
#include "stdafx.h"
#include "logto.h"
#include "logtoDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CLogtoDlg dialog
CLogtoDlg::CLogtoDlg(CWnd* pParent /*=NULL*/)
: CDialog(CLogtoDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CLogtoDlg)
NAMEY = _T("");
NAMEM = _T("");
filename = _T("");
wellname = _T("");
diqu = _T("");
namekind = _T("");
datakind = _T("");
picname = _T("");
nlog = 0;
depthstart = 0.0;
depthend = 0.0;
jiange = 0.0;
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CLogtoDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CLogtoDlg)
DDX_Control(pDX, IDOK, m_Button);
DDX_Control(pDX, IDC_PROGRESS1, m_progress);
DDX_Control(pDX, IDC_LIST2, m_List1);
DDX_Control(pDX, IDC_LIST1, m_List2);
DDX_Text(pDX, IDC_EDIT1, NAMEY);
DDX_Text(pDX, IDC_EDIT12, NAMEM);
DDX_Text(pDX, IDC_EDIT2, filename);
DDX_Text(pDX, IDC_EDIT3, wellname);
DDX_Text(pDX, IDC_EDIT4, diqu);
DDX_Text(pDX, IDC_EDIT5, namekind);
DDX_Text(pDX, IDC_EDIT6, datakind);
DDX_Text(pDX, IDC_EDIT7, picname);
DDX_Text(pDX, IDC_EDIT11, nlog);
DDX_Text(pDX, IDC_EDIT8, depthstart);
DDX_Text(pDX, IDC_EDIT9, depthend);
DDX_Text(pDX, IDC_EDIT10, jiange);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CLogtoDlg, CDialog)
//{{AFX_MSG_MAP(CLogtoDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
ON_WM_TIMER()
ON_BN_CLICKED(IDCANCEL2, OnCancel2)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CLogtoDlg message handlers
BOOL CLogtoDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
void CLogtoDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CLogtoDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CLogtoDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CLogtoDlg::OnButton1()
{
CFileDialog dlg(TRUE,NULL,"*.*",OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,"All Files(*.*)|*.*|Wellog文件 (*.dat)|*.dat||",this);
if(dlg.DoModal()==IDOK){
m_List1.ResetContent();
CFile file1(dlg.GetPathName() ,CFile::modeRead);
NAMEY=dlg.GetPathName();
NAMEM=dlg.GetPathName()+".txt";
char filemsg[120];
file1.Seek(0,CFile::begin);
file1.Read(&filemsg,sizeof filemsg);
CString str=filemsg;
filename=str.Mid(0,20);
wellname=str.Mid(20,20);
diqu=str.Mid(40,10);
namekind=str.Mid(50,3);
datakind=str.Mid(53,7);
picname=str.Mid(60,20);
depthstart=atof(str.Mid(80,10));
depthend=atof(str.Mid(90,10));
jiange=atof(str.Mid(100,10));
nlog=(int)(atof(str.Mid(110,10)));
char logname[4];
for(int i=0;i<nlog;i++){
file1.Seek(120+i*4,CFile::begin);
file1.Read(&logname,sizeof 4);
str=logname;
m_List1.AddString(str.Mid(0,4));
}
file1.Close();
UpdateData(FALSE);
// InvalidateRect(NULL,TRUE);
// UpdateWindow();
}
}
void CLogtoDlg::OnButton2()
{
CFileDialog dlg(FALSE,NULL,"*.txt",OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,"All Files(*.*)|*.*|Text文件 (*.txt)|*.txt||",this);
if(dlg.DoModal()==IDOK){
NAMEM=dlg.GetPathName();
UpdateData(FALSE);
}
}
void CLogtoDlg::OnOK()
{
m_Button.EnableWindow(FALSE);
SetTimer(1,10,NULL);
UpdateData(TRUE);
FILE * fp;
m_List2.ResetContent();
bb=(depthend-depthstart)/jiange+1;
float s[30];
CString str,str1;
fp=fopen(NAMEM, "a+");
fprintf(fp,"\n Depth ");
for(long ii=0;ii<nlog;ii++){
m_List1.SetTopIndex(ii);
m_List1.GetText(ii,str);
fprintf(fp,str);
fprintf(fp," ");
}
fprintf(fp,"\n");
fclose(fp);
for(i=0;i<bb;i++){
CFile file(NAMEY,CFile::modeRead);
for(int ii=0;ii<nlog;ii++){
file.Seek(1200+ii*4+4*30*i,CFile::begin);
file.Read(&s[ii],4);
}
file.Close();
fp=fopen(NAMEM, "a+");
fprintf(fp,"\n%8.3f",depthstart+i*jiange);
str1.Format("%8.3f",depthstart+i*jiange);
for(ii=0;ii<nlog;ii++){
fprintf(fp," %7.2f",s[ii]);
str1.Format(str1+" %7.2f",s[ii]);
}
m_List2.AddString(str1);
fclose(fp);
str1="";
if(::PeekMessage(&Message,NULL,0,0,PM_REMOVE)){
::TranslateMessage(&Message);
::DispatchMessage(&Message);
}
}
::TranslateMessage(&Message);
::DispatchMessage(&Message);
KillTimer(1);
MessageBox("数据转换完毕!",NULL,MB_OK|MB_ICONASTERISK);
m_Button.EnableWindow(TRUE);
}
void CLogtoDlg::OnTimer(UINT nIDEvent)
{
m_progress.SetRange(0,bb);
m_progress.SetPos(i+1);
CDialog::OnTimer(nIDEvent);
}
void CLogtoDlg::OnCancel2()
{
CAboutDlg dlg;
dlg.DoModal();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -