?? listwell.cpp
字號(hào):
// ListWell.cpp : implementation file
//
#include "stdafx.h"
#include "drawcli.h"
#include "ListWell.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CListWell dialog
IMPLEMENT_DYNCREATE(CListWell, CDialog)
CListWell::CListWell(CWnd* pParent /*=NULL*/)
: CDialog(CListWell::IDD, pParent)
{
//{{AFX_DATA_INIT(CListWell)
m_wellnum = _T("");
//}}AFX_DATA_INIT
m_pParent = pParent;
m_nID = CListWell::IDD;
}
void CListWell::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CListWell)
DDX_Control(pDX, IDC_LW_LISTWELLS, m_listwells);
DDX_Control(pDX, IDC_LW_LISTQKDY, m_listqkdy);
DDX_Text(pDX, IDC_LW_WELLNUM, m_wellnum);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CListWell, CDialog)
//{{AFX_MSG_MAP(CListWell)
ON_LBN_SELCHANGE(IDC_LW_LISTQKDY, OnSelchangeLwListqkdy)
ON_LBN_DBLCLK(IDC_LW_LISTWELLS, OnDblclkLwListwells)
ON_WM_SIZE()
//}}AFX_MSG_MAP
ON_COMMAND(IDCANCEL, OnCancel)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CListWell message handlers
BOOL CListWell::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
//連接數(shù)據(jù)庫(kù)
//UpdateData(TRUE);
m_AdoConn.OnInitADOConn();
//設(shè)置SELECT語(yǔ)句
_bstr_t vSQL;
vSQL = "select distinct qkdy from daa01";//查詢(xún)出所有區(qū)塊
//執(zhí)行SELETE語(yǔ)句
_RecordsetPtr m_pRecordset;
m_pRecordset = m_AdoConn.GetRecordSet(vSQL);
//返回各列的值
if (m_pRecordset->ADOEOF)
return FALSE;
//CWnd * m_LsCWnd;
//m_LsCWnd = GetDlgItem(IDC_LW_LISTQKDY);
//m_listqkdy.SetCurSel( 0 )
while (!m_pRecordset->ADOEOF)
{
m_listqkdy.AddString((char*)_bstr_t(m_pRecordset->GetCollect("qkdy")));
m_pRecordset->MoveNext() ;
}
//斷開(kāi)與數(shù)據(jù)庫(kù)的連接
m_AdoConn.ExitConnect();
m_listqkdy.SetCurSel(0);
UpdateData(FALSE);
GetListWell();
return FALSE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
//選擇了區(qū)塊,得到此區(qū)塊的井列表
void CListWell::OnSelchangeLwListqkdy()
{
// TODO: Add your control notification handler code here
GetListWell();
}
void CListWell::OnCancel()
{
DestroyWindow();
}
CListWell::~CListWell()
{
m_AdoConn.ExitConnect();
DestroyWindow();
}
//雙擊井的列表
void CListWell::OnDblclkLwListwells()
{
// TODO: Add your control notification handler code here
//GetWellLink();
}
//根據(jù)選擇了區(qū)塊,得到此區(qū)塊的井列表 CString pQkdy
void CListWell::GetListWell()
{
UpdateData(TRUE);
m_listwells.ResetContent();
int i = m_listqkdy.GetCurSel();
CString str = "";
m_listqkdy.GetText(i,str );
if (!str.IsEmpty() && "" != str)
{
_bstr_t vSQL;
vSQL = "select * from daa01 where qkdy='"+ str +"' order by jh";//查詢(xún)出區(qū)塊內(nèi)的所有井
_RecordsetPtr m_pRecordset;
m_AdoConn.OnInitADOConn();
m_pRecordset = m_AdoConn.GetRecordSet(vSQL);
//返回各列的值
if (m_pRecordset->ADOEOF)
{
m_AdoConn.ExitConnect();
return ;
}
int iCnt = 0;
while (!m_pRecordset->ADOEOF)
{
iCnt++;
m_listwells.AddString((char*)_bstr_t(m_pRecordset->GetCollect("JH")));
m_pRecordset->MoveNext() ;
}
//str.Format("%d",i)
m_wellnum.Format("[%d]口井",iCnt);
//斷開(kāi)與數(shù)據(jù)庫(kù)的連接
m_AdoConn.ExitConnect();
}
UpdateData(FALSE);
}
/*****************************************************************
//得到與列表指定井的相連通的井
//根據(jù)每一口井,得到其層數(shù)(及相關(guān)顯示參數(shù))將井的信息存放在數(shù)組中
******************************************************************/
void CListWell::GetWellLink()
{
//CString str = m_listwells.GetCurSel();
}
void CListWell::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);
// TODO: Add your message handler code here
//m_listwells.SetW
/*CWnd * pWnd = GetDlgItem(IDC_LW_LISTWELLS);
if(NULL != pWnd->GetSafeHwnd())
{
CRect r;
GetClientRect(&r);
//r.right /= 2;
//r.bottom /= 5 ;
r.top /= 5;
pWnd->MoveWindow(r);
}*/
if(NULL != m_listwells.GetSafeHwnd())
{
int bx,by;
int nWidht,nHeight;
CRect r;
//得到起點(diǎn)橫坐標(biāo)和寬度
GetWindowRect(&r);
bx = 0 ;
nWidht = r.Width() -10 ;///2 ;
CRect rect;
GetClientRect(&rect);
//得到取點(diǎn)縱坐標(biāo)和高度
m_listwells.GetWindowRect(&r);
ScreenToClient(&r);
by = r.top ;
nHeight = rect.bottom-r.top;//r.Height();
//CRect rList(bx,by,bx + nWidht,by + nHeight);
CRect rList(bx,by,bx + nWidht,by + nHeight);
m_listwells.MoveWindow(rList);
CRect rQkdy(0,0, bx + nWidht,161);
m_listqkdy.MoveWindow(rQkdy);
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -