?? query.cpp
字號(hào):
// Query.cpp : implementation file
//
#include "stdafx.h"
#include "Query.h"
#include "fun.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CQuery dialog
CQuery::CQuery(CWnd* pParent /*=NULL*/)
: CDialog(CQuery::IDD, pParent)
{
//{{AFX_DATA_INIT(CQuery)
m_str1 = _T("");
m_str2 = _T("");
//}}AFX_DATA_INIT
m_record1 = NULL;
m_record2 = NULL;
button = -1;
m_pParent = pParent;
}
void CQuery::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CQuery)
DDX_Control(pDX, IDC_COMBO2, m_combo2);
DDX_Control(pDX, IDC_COMBO1, m_combo1);
DDX_Text(pDX, IDC_STATIC1, m_str1);
DDX_Text(pDX, IDC_STATIC2, m_str2);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CQuery, CDialog)
//{{AFX_MSG_MAP(CQuery)
ON_WM_CLOSE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CQuery message handlers
BOOL CQuery::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
Init();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
BOOL CQuery::Init()
{
int i;
for(i=m_combo1.GetCount(); i>=0; i--)
m_combo1.DeleteString(i);
for(i=m_combo2.GetCount(); i>=0; i--)
m_combo2.DeleteString(i);
switch(button)
{
case 1:
case 2:
{
if(m_record1)
{
m_record1->MoveFirst();
int index = -1;
while(!m_record1->IsEOF())
{
index += 1;
CString strVar = strVARIANT(m_record1->GetFieldValue(0));
int Flag = -1;
int countComboBox = m_combo1.GetCount();
CString str2;
for(int x=0; x<countComboBox; x++)
{
m_combo1.GetLBText(x, str2);
if(strVar == str2)
Flag ++;
}
if(Flag == -1)
m_combo1.AddString(strVar);
m_record1->MoveNext();
}
m_combo1.SetCurSel(0);
}
GetDlgItem(IDC_STATIC2)->ShowWindow(SW_HIDE);
m_combo2.ShowWindow(SW_HIDE);
}
break;
case 3:
{
if(m_record1)
{
m_record1->MoveFirst();
int index = -1;
while(!m_record1->IsEOF())
{
index += 1;
CString strVar = strVARIANT(m_record1->GetFieldValue(0));
CString strVar1 = strVARIANT(m_record1->GetFieldValue(1));
strVar = strVar+ " " +strVar1;
m_combo1.AddString(strVar);
m_record1->MoveNext();
}
m_combo1.SetCurSel(0);
}
GetDlgItem(IDC_STATIC2)->ShowWindow(SW_HIDE);
m_combo2.ShowWindow(SW_HIDE);
}
break;
case 4:
{
if(m_record1)
{
m_record1->MoveFirst();
int index = -1;
while(!m_record1->IsEOF())
{
index += 1;
CString strVar = strVARIANT(m_record1->GetFieldValue(0));
CString strVar1 = strVARIANT(m_record1->GetFieldValue(1));
strVar = strVar+ " " +strVar1;
m_combo1.AddString(strVar);
m_record1->MoveNext();
}
m_combo1.SetCurSel(0);
}
if(m_record2)
{
GetDlgItem(IDC_STATIC2)->ShowWindow(SW_SHOW);
m_combo2.ShowWindow(SW_SHOW);
m_record2->MoveFirst();
int index = -1;
while(!m_record2->IsEOF())
{
index += 1;
CString strVar = strVARIANT(m_record2->GetFieldValue(0));
CString strVar1 = strVARIANT(m_record2->GetFieldValue(1));
strVar = strVar+ " " +strVar1;
m_combo2.AddString(strVar);
m_record2->MoveNext();
}
m_combo2.SetCurSel(0);
}
else
{
GetDlgItem(IDC_STATIC2)->ShowWindow(SW_HIDE);
m_combo2.ShowWindow(SW_HIDE);
}
}
break;
default:
AfxMessageBox("這是怎么回事?應(yīng)該是出錯(cuò)了?");
break;
}
UpdateData(FALSE);
return TRUE;
}
void CQuery::OnOK()
{
// TODO: Add extra validation here
m_pParent->SendMessage(WM_QUERY_OK);
}
void CQuery::OnCancel()
{
// TODO: Add extra cleanup here
DestroyWindow();
}
void CQuery::PostNcDestroy()
{
// TODO: Add your specialized code here and/or call the base class
m_pParent->SendMessage(WM_QUERY_CLOSE);
delete this;
CDialog::PostNcDestroy();
}
void CQuery::OnClose()
{
// TODO: Add your message handler code here and/or call default
m_pParent->SendMessage(WM_QUERY_CLOSE);
DestroyWindow();
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -