📄 vdlg.cpp
字号:
// vDlg.cpp : implementation file
//
#include "stdafx.h"
#include "v.h"
#include "vDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#include "Pic_Name.h"
#include "Pic_Name1.h"
#include "Pic_Name2.h"
#include "iostream.h"
#include "fstream.h"
/////////////////////////////////////////////////////////////////////////////
// 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()
/////////////////////////////////////////////////////////////////////////////
// CVDlg dialog
CVDlg::CVDlg(CWnd* pParent /*=NULL*/)
: CDialog(CVDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CVDlg)
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CVDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CVDlg)
DDX_Control(pDX, IDC_EDIT1, m_edit);
DDX_Control(pDX, IDC_COMBO3, m_combo3);
DDX_Control(pDX, IDC_COMBO2, m_combo2);
DDX_Control(pDX, IDC_COMBO1, m_combo1);
DDX_Control(pDX, IDC_BUTTON1, m_button);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CVDlg, CDialog)
//{{AFX_MSG_MAP(CVDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_VIEW, OnView)
ON_BN_CLICKED(IDC_AITER, OnAiter)
ON_BN_CLICKED(IDC_ADD, OnAdd)
ON_BN_CLICKED(IDC_DELETE, OnDelete)
//}}AFX_MSG_MAP
ON_COMMAND_RANGE(IDC_RADIO1,IDC_RADIO3,OnChoice)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CVDlg message handlers
BOOL CVDlg::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
CDatabase m_database;
CString strSQL,str;
m_database.Open(_T("PIC_NAME"));
CPic_Name m_picname(&m_database);
strSQL.Format("select * from 165");
m_picname.Open(CRecordset::snapshot,strSQL);
CDBVariant varValue;
if(m_picname.GetRecordCount()!=0)
m_picname.MoveFirst();
while(!m_picname.IsEOF())
{
int temp=0;
m_picname.GetFieldValue(temp,varValue);
str=varValue.m_pstring->GetBuffer(1);
m_combo1.AddString(str);
m_picname.MoveNext();
}
m_picname.Close();
strSQL.Format("select * from 175");
m_picname.Open(CRecordset::snapshot,strSQL);
if(m_picname.GetRecordCount()!=0)
m_picname.MoveFirst();
while(!m_picname.IsEOF())
{
int temp=0;
m_picname.GetFieldValue(temp,varValue);
str=varValue.m_pstring->GetBuffer(1);
m_combo2.AddString(str);
m_picname.MoveNext();
}
m_picname.Close();
strSQL.Format("select * from 240");
m_picname.Open(CRecordset::snapshot,strSQL);
if(m_picname.GetRecordCount()!=0)
m_picname.MoveFirst();
while(!m_picname.IsEOF())
{
int temp=0;
m_picname.GetFieldValue(temp,varValue);
str=varValue.m_pstring->GetBuffer(1);
m_combo3.AddString(str);
m_picname.MoveNext();
}
m_picname.Close();
m_database.Close();
return TRUE; // return TRUE unless you set the focus to a control
}
void CVDlg::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 CVDlg::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 CVDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CVDlg::OnChoice(UINT nID)
{
switch(nID)
{
case IDC_RADIO1:num=165;break;
case IDC_RADIO2:num=175;break;
case IDC_RADIO3:num=240;break;
}
}
void CVDlg::OnView()
{
// TODO: Add your control notification handler code here
CString strs,strSQL,str;
CDatabase m_database;
m_database.Open(_T("PIC_NAME"));
CPic_Name m_picname(&m_database);
CDBVariant varValue;
if(num==165)
{
GetDlgItemText(IDC_COMBO1,str);
strSQL.Format("select PROPERTY from 165 where NAME='%s'",str);
m_picname.Open(CRecordset::forwardOnly,strSQL);
m_picname.GetFieldValue("PROPERTY",varValue);
m_edit.SetSel(0,-1);
m_edit.ReplaceSel(varValue.m_pstring->GetBuffer(1));
strs.Format("165\\%s.bmp",str);
m_picname.Close();
}
if(num==175)
{
GetDlgItemText(IDC_COMBO2,str);
strSQL.Format("select PROPERTY from 175 where NAME='%s'",str);
m_picname.Open(CRecordset::forwardOnly,strSQL);
m_picname.GetFieldValue("PROPERTY",varValue);
m_edit.SetSel(0,-1);
m_edit.ReplaceSel(varValue.m_pstring->GetBuffer(1));
strs.Format("175\\%s.bmp",str);
m_picname.Close();
}
if(num==240)
{
GetDlgItemText(IDC_COMBO3,str);
strSQL.Format("select PROPERTY from 240 where NAME='%s'",str);
m_picname.Open(CRecordset::forwardOnly,strSQL);
m_picname.GetFieldValue("PROPERTY",varValue);
m_edit.SetSel(0,-1);
m_edit.ReplaceSel(varValue.m_pstring->GetBuffer(1));
strs.Format("240\\%s.bmp",str);
m_picname.Close();
}
HBITMAP hBitmap=(HBITMAP)LoadImage(NULL,_T(strs),IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
m_button.SetBitmap(hBitmap);
}
void CVDlg::OnAiter()
{
// TODO: Add your control notification handler code here
CString str,strs,strSQL,cstr;
CDatabase m_database;
m_database.Open(_T("PIC_NAME"));
CPic_Name m_picname(&m_database);
CPic_Name1 m_picname1(&m_database);
CPic_Name2 m_picname2(&m_database);
m_edit.GetWindowText(cstr);
if(num==165)
{
GetDlgItemText(IDC_COMBO1,str);
strSQL.Format("NAME='%s'",str);
m_picname.m_strFilter=strSQL;
m_picname.Open();
m_picname.Edit();
m_picname.m_PROPERTY=cstr;
m_picname.Update();
m_picname.Close();
}
if(num==175)
{
GetDlgItemText(IDC_COMBO2,str);
strSQL.Format("NAME='%s'",str);
m_picname1.m_strFilter=strSQL;
m_picname1.Open();
m_picname1.Edit();
m_picname1.m_PROPERTY=cstr;
m_picname1.Update();
m_picname1.Close();
}
if(num==240)
{
GetDlgItemText(IDC_COMBO3,str);
strSQL.Format("NAME='%s'",str);
m_picname2.m_strFilter=strSQL;
m_picname2.Open();
m_picname2.Edit();
m_picname2.m_PROPERTY=cstr;
m_picname2.Update();
m_picname2.Close();
}
strs.Format("C:\\Program Files\\AutoCAD 2002\\acad.exe %d\\%s.dwg",num,str);
if(MessageBox("是否修改原图","修改提示",MB_ICONINFORMATION|MB_OKCANCEL)==IDOK)
WinExec(strs,SW_SHOW);
}
void CVDlg::OnAdd()
{
// TODO: Add your control notification handler code here
CString str,strSQL,cstr;
CDatabase m_database;
m_database.Open(_T("PIC_NAME"));
CPic_Name m_picname(&m_database);
CPic_Name1 m_picname1(&m_database);
CPic_Name2 m_picname2(&m_database);
m_edit.GetWindowText(cstr);
if(num==165)
{
GetDlgItemText(IDC_COMBO1,str);
m_combo1.AddString(str);
m_picname.Open();
m_picname.AddNew();
m_picname.m_NAME=str;
m_picname.m_PROPERTY=cstr;
m_picname.Update();
m_picname.Close();
}
if(num==175)
{
GetDlgItemText(IDC_COMBO2,str);
m_combo2.AddString(str);
m_picname1.Open();
m_picname1.AddNew();
m_picname1.m_NAME=str;
m_picname1.m_PROPERTY=cstr;
m_picname1.Update();
m_picname1.Close();
}
if(num==240)
{
GetDlgItemText(IDC_COMBO3,str);
m_combo3.AddString(str);
m_picname2.Open();
m_picname2.AddNew();
m_picname2.m_NAME=str;
m_picname2.m_PROPERTY=cstr;
m_picname2.Update();
m_picname2.Close();
}
m_database.Close();
WinExec("C:\\Program Files\\AutoCAD 2002\\acad.exe",SW_SHOW);
}
void CVDlg::OnDelete()
{
// TODO: Add your control notification handler code here
CString strs,strx,stre,str,strSQL;
CDatabase m_database;
int i;
m_database.Open(_T("PIC_NAME"));
if(num==165)
{
GetDlgItemText(IDC_COMBO1,str);
i=m_combo1.FindString(-1,str);
m_combo1.DeleteString(i);
m_combo1.Clear();
strSQL.Format("delete from 165 where NAME='%s'",str);
m_database.ExecuteSQL(strSQL);
strs.Format("165\\%s.bmp",str);
strx.Format("165\\%s.dwg",str);
}
if(num==175)
{
GetDlgItemText(IDC_COMBO2,str);
i=m_combo2.FindString(-1,str);
m_combo2.DeleteString(i);
strSQL.Format("delete from 175 where NAME='%s'",str);
m_database.ExecuteSQL(strSQL);
strs.Format("175\\%s.bmp",str);
strx.Format("175\\%s.dwg",str);
}
if(num==240)
{
GetDlgItemText(IDC_COMBO3,str);
i=m_combo3.FindString(-1,str);
m_combo3.DeleteString(i);
strSQL.Format("delete from 240 where NAME='%s'",str);
m_database.ExecuteSQL(strSQL);
strs.Format("240\\%s.bmp",str);
strx.Format("240\\%s.dwg",str);
}
DeleteFile(strs);
DeleteFile(strx);
m_database.Close();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -