// BusDlg.cpp : implementation file
//
#include "stdafx.h"
#include "Bus.h"
#include "BusDlg.h"
#include "BusEditDlg.h"
#include "RegisterDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CBusDlg dialog
CBusDlg::CBusDlg(CWnd* pParent /*=NULL*/)
: CDialog(CBusDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CBusDlg)
m_end1 = _T("");
m_start1 = _T("");
m_detial1 = _T("");
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CBusDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CBusDlg)
DDX_Control(pDX, IDC_EDIT_DETIAL, m_detial);
DDX_Control(pDX, IDC_RADIO1, m_radio);
DDX_Control(pDX, IDC_LIST_RESULT, m_list_result);
DDX_Control(pDX, IDC_LIST_LIKE, m_list_like);
DDX_Control(pDX, IDC_EDIT_START, m_start);
DDX_Control(pDX, IDC_EDIT_END, m_end);
DDX_Text(pDX, IDC_EDIT_END, m_end1);
DDX_Text(pDX, IDC_EDIT_START, m_start1);
DDX_Text(pDX, IDC_EDIT_DETIAL, m_detial1);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CBusDlg, CDialog)
//{{AFX_MSG_MAP(CBusDlg)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_RADIO1, OnRadio1)
ON_BN_CLICKED(IDC_RADIO2, OnRadio2)
ON_BN_CLICKED(IDC_RADIO3, OnRadio3)
ON_BN_CLICKED(IDC_BUTTON_SEARCH, OnButtonSearch)
ON_EN_CHANGE(IDC_EDIT_START, OnChangeEditStart)
ON_LBN_SELCHANGE(IDC_LIST_LIKE, OnSelchangeListLike)
ON_EN_SETFOCUS(IDC_EDIT_START, OnSetfocusEditStart)
ON_EN_SETFOCUS(IDC_EDIT_END, OnSetfocusEditEnd)
ON_NOTIFY(NM_CLICK, IDC_LIST_RESULT, OnClickListResult)
ON_EN_CHANGE(IDC_EDIT_END, OnChangeEditEnd)
ON_NOTIFY(LVN_KEYDOWN, IDC_LIST_RESULT, OnKeydownListResult)
ON_BN_CLICKED(IDC_BUTTON_EDIT, OnButtonEdit)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CBusDlg message handlers
BOOL CBusDlg::OnInitDialog()
{
CDialog::OnInitDialog();
//打开数据库----------------------------------
if(!m_data.IsOpen())
{
m_data.Open(_T("bus;UID=admin;PWD=lyl"));
m_record.m_pDatabase=&m_data;
}
else
MessageBox("Can't open bus.bus database!");
// 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
font.CreateFont(14,0,0,0,0,FALSE,FALSE,0,ANSI_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,FF_SWISS,"宋体");
m_start.SetFont(&font,TRUE);
m_end.SetFont(&font,TRUE);
m_list_result.SetFont(&font,TRUE);
GetDlgItem(IDC_BUTTON_SEARCH)->SetFont(&font,TRUE);
focus=0;
//
m_radio.CheckRadioButton(IDC_RADIO1,IDC_RADIO3,IDC_RADIO1);
((CButton *)GetDlgItem(IDC_RADIO1))->SetCheck(TRUE);
m_styl=GetCheckedRadioButton(IDC_RADIO1,IDC_RADIO3);
wildcard = '%';
//初始化LISTCTRL
RECT rectList;
m_list_result.GetWindowRect(&rectList);
m_list_result.DeleteAllItems();
width=rectList.right-rectList.left-4;
Refresh();
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
// 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 CBusDlg::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 CBusDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CBusDlg::OnSetfocusEditStart()
{
focus=1;
}
void CBusDlg::OnSetfocusEditEnd()
{
focus=2;
}
void CBusDlg::Refresh()
{
UpdateData(TRUE);
m_list_result.DeleteAllItems();
int nColumnCount = m_list_result.GetHeaderCtrl()->GetItemCount();
for (int i=0;i < nColumnCount;i++)
m_list_result.DeleteColumn(0);
DWORD dwStyle=LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES|LVS_EX_HEADERDRAGDROP;//|LVN_ENDLABELEDIT;
m_list_result.SetExtendedStyle(dwStyle);
m_list_result.SetFont(&font,TRUE);
//设置LIST CONTRO控件的样式
if(m_styl==IDC_RADIO1)
{
((CButton *)GetDlgItem(IDC_STATIC1))->SetWindowText("起点");
((CButton *)GetDlgItem(IDC_STATIC2))->SetWindowText("终点");
((CButton *)GetDlgItem(IDC_STATIC3))->SetWindowText("换乘");
((CButton *)GetDlgItem(IDC_STATIC4))->SetWindowText("Interrelated");
((CButton *)GetDlgItem(IDC_BUTTON_SEARCH))->SetWindowText("换乘查询");
((CButton *)GetDlgItem(IDC_STATIC1))->EnableWindow(TRUE);
((CButton *)GetDlgItem(IDC_STATIC2))->EnableWindow(TRUE);
((CButton *)GetDlgItem(IDC_STATIC3))->EnableWindow(TRUE);
((CButton *)GetDlgItem(IDC_STATIC4))->EnableWindow(TRUE);
m_end.ShowWindow(TRUE);
((CButton *)GetDlgItem(IDC_STATIC2))->ShowWindow(TRUE);
m_start.SetFocus();
m_start.SetWindowText("");
m_end.SetWindowText("");
}
else if(m_styl==IDC_RADIO2)
{
((CButton *)GetDlgItem(IDC_STATIC1))->SetWindowText("输入公交路线");
((CButton *)GetDlgItem(IDC_STATIC2))->ShowWindow(FALSE);
((CButton *)GetDlgItem(IDC_STATIC3))->SetWindowText("All Station Of The Route");
((CButton *)GetDlgItem(IDC_STATIC4))->SetWindowText("Interrelated");
((CButton *)GetDlgItem(IDC_BUTTON_SEARCH))->SetWindowText("路线查询");
((CButton *)GetDlgItem(IDC_STATIC4))->EnableWindow(TRUE);
((CButton *)GetDlgItem(IDC_STATIC3))->EnableWindow(TRUE);
m_end.ShowWindow(FALSE);
m_start.SetWindowText("");
m_list_result.InsertColumn(0,"Line",LVCFMT_CENTER);//
m_list_result.InsertColumn(1,"Station",LVCFMT_LEFT);
m_list_result.SetColumnWidth(0,100);
m_list_result.SetColumnWidth(1,width-103);
}
else if(m_styl==IDC_RADIO3)
{
m_list_result.InsertColumn(0,"Line",LVCFMT_CENTER);
m_list_result.InsertColumn(1,"Station",LVCFMT_LEFT);
m_list_result.SetColumnWidth(0,100);
m_list_result.SetColumnWidth(1,width-103);
((CButton *)GetDlgItem(IDC_STATIC1))->SetWindowText("输入公交站点");
((CButton *)GetDlgItem(IDC_STATIC2))->SetWindowText("");
((CButton *)GetDlgItem(IDC_STATIC3))->SetWindowText("Station Information");
((CButton *)GetDlgItem(IDC_STATIC4))->SetWindowText("Interrelated");
((CButton *)GetDlgItem(IDC_BUTTON_SEARCH))->SetWindowText("站点查询");
((CButton *)GetDlgItem(IDC_STATIC1))->EnableWindow(TRUE);
((CButton *)GetDlgItem(IDC_STATIC3))->EnableWindow(TRUE);
((CButton *)GetDlgItem(IDC_STATIC4))->EnableWindow(TRUE);
m_end.ShowWindow(FALSE);
((CButton *)GetDlgItem(IDC_STATIC2))->ShowWindow(FALSE);
m_start.SetFocus();
m_start.SetWindowText("");
}
m_detial.SetWindowText("");//清空
}
void CBusDlg::OnRadio1()
{
((CButton *)GetDlgItem(IDC_RADIO1))->SetCheck(TRUE);
m_styl=GetCheckedRadioButton(IDC_RADIO1,IDC_RADIO3);
Refresh();
}
void CBusDlg::OnRadio2()
{
// TODO: Add your control notification handler code here
((CButton *)GetDlgItem(IDC_RADIO2))->SetCheck(TRUE);
m_styl=GetCheckedRadioButton(IDC_RADIO1,IDC_RADIO3);
Refresh();
m_start.SetFocus();
}
void CBusDlg::OnRadio3()
{
// TODO: Add your control notification handler code here
((CButton *)GetDlgItem(IDC_RADIO3))->SetCheck(TRUE);
m_styl=GetCheckedRadioButton(IDC_RADIO1,IDC_RADIO3);
Refresh();
}
void CBusDlg::OnButtonSearch()
{
// TODO: Add your control not
深圳市公交查询系统 VC++ACCESS
3星 · 超过75%的资源 需积分: 9 92 浏览量
2010-10-29
10:12:48
上传
评论 3
收藏 6.24MB RAR 举报
macolin
- 粉丝: 1
- 资源: 11
- 1
- 2
前往页