ExadoDlg.cpp
上传用户:weisheen
上传日期:2022-07-09
资源大小:19390k
文件大小:5k
源码类别:
ActiveX/DCOM/ATL
开发平台:
Visual C++
- // ExadoDlg.cpp : implementation file
- //
- #include "stdafx.h"
- #include "Exado.h"
- #include "ExadoDlg.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()
- /////////////////////////////////////////////////////////////////////////////
- // CExadoDlg dialog
- CExadoDlg::CExadoDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CExadoDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CExadoDlg)
- // NOTE: the ClassWizard will add member initialization here
- //}}AFX_DATA_INIT
- // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
- m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
- }
- void CExadoDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CExadoDlg)
- // NOTE: the ClassWizard will add DDX and DDV calls here
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CExadoDlg, CDialog)
- //{{AFX_MSG_MAP(CExadoDlg)
- ON_WM_SYSCOMMAND()
- ON_WM_PAINT()
- ON_WM_QUERYDRAGICON()
- ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CExadoDlg message handlers
- BOOL CExadoDlg::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 CExadoDlg::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 CExadoDlg::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 CExadoDlg::OnQueryDragIcon()
- {
- return (HCURSOR) m_hIcon;
- }
- void CExadoDlg::OnButton1()
- {
- // TODO: Add your control notification handler code here
- ::CoInitialize(NULL);
- _ConnectionPtr myconn;
- myconn.CreateInstance(__uuidof(Connection));
- _bstr_t sql("Provider=OraOLEDB.Oracle.1;User Id=scott;Data Source=tarena;");
- HRESULT hr=myconn->Open(sql,"scott","tiger",-1);
- _CommandPtr mysql1;
- mysql1.CreateInstance(__uuidof(Command));
- _bstr_t sql1("select * from ocyBooks");
- mysql1->CommandText=sql1;//指定命令文本
- mysql1->CommandType=adCmdText;//指定命令类型
- mysql1->ActiveConnection=myconn;
- _RecordsetPtr mydata=mysql1->Execute(NULL,NULL,adCmdText);//数据操作
- while(!mydata->adoEOF)//列表指针
- {
- _variant_t myid=mydata->GetCollect("BOOKISNB");//获取数据表对应属性名的数据
- _variant_t myname=mydata->GetCollect("BOOKNAME");//获取数据表对应属性名的数据
- _variant_t myauthor=mydata->GetCollect("BOOKAuthor");//获取数据表对应属性名的数据
- CString strName((LPCTSTR)(_bstr_t)myname);//(_bstr_t)为带空字节头的UNicode码
- CString strAuthor((LPCTSTR)(_bstr_t)myauthor);//(LPCTSTR)为不带空字节头的UNicode码
- CString str;
- str.Format("%d;%s;%s",(long)myid,strName,strAuthor);
- MessageBox(str);
- mydata->MoveNext();
- }
- mydata->Close();
- myconn->Close();
- }