【VC开源代码栏目提醒】:网学会员在VC开源代码频道为大家收集整理了DlgXSDJ.cpp提供大家参考,希望对大家有所帮助!
// DlgXSDJ.cpp : implementation file
//
#include "stdafx.h"
#include "a1.h"
#include "DlgXSDJ.h"
#include "ScrollPrintView.h"
#include "mmsystem.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDlgXSDJ dialog
CDlgXSDJ::CDlgXSDJ(bool isxs,CWnd* pParent /*=NULL*/)
: CDialog(CDlgXSDJ::IDD, pParent)
{
//{{AFX_DATA_INIT(CDlgXSDJ)
m_strPh = _T("");
//}}AFX_DATA_INIT
this->m_plistXSDJ=NULL;
this->m_bXs=isxs;
wf=NULL;
m_draw=new CDrawXSDJ(this);
}
void CDlgXSDJ::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDlgXSDJ)
DDX_Control(pDX, IDC_BUTTON_OK, m_btnOk);
DDX_Control(pDX, IDC_EDIT_KHNAME, m_editKhName);
DDX_Control(pDX, IDC_EDIT1, m_editPh);
DDX_Control(pDX, IDC_COMBO1, m_comboJsfs);
DDX_Control(pDX, IDC_EDIT_KHID, m_editKhId);
DDX_Control(pDX, IDC_DATETIMEPICKER1, m_tcRq);
DDX_Control(pDX, IDC_COMBO2, m_comboJsr);
DDX_Text(pDX, IDC_EDIT1, m_strPh);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDlgXSDJ, CDialog)
//{{AFX_MSG_MAP(CDlgXSDJ)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_WM_MOVE()
ON_WM_CREATE()
ON_BN_CLICKED(IDC_BUTTON_OK, OnButtonOk)
ON_WM_DRAWITEM()
ON_BN_CLICKED(IDC_BUTTON_PRINT, OnButtonPrint)
//}}AFX_MSG_MAP
ON_MESSAGE(MYMESSAGE_XSDJ_SETTHEFOCUS,SetTheFocus)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDlgXSDJ message handlers
BOOL CDlgXSDJ::OnInitDialog()
{
CDialog::OnInitDialog();
CRect rect;
InitStringLists();
InitnListXSDJ();
if(!this->InitBaseInfo())
{
MessageBox("初始化基本数据失败");
return true;
}
m_editKhId.SetFocus();
return FALSE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDlgXSDJ::OnCancel()
{
if(MessageBox("确定退出登记模块?","注意",MB_YESNO)==IDYES)
{
if(MessageBox("是否保存?","注意",MB_YESNO)==IDNO)
{
CDialog::OnCancel();
}
else
this->OnButtonOk();
}
return;
}
void CDlgXSDJ::OnOK()
{
// CDialog::OnOK();
}
BOOL CDlgXSDJ::PreTranslateMessage(MSG* pMsg)
{
if(pMsg==NULL) return false;
const HWND hwnd=pMsg->hwnd;
if(pMsg->message==WM_SETFOCUS)
{
if(hwnd!=this->m_plistXSDJ->m_edit.GetSafeHwnd())
{
::SendMessage(m_plistXSDJ->m_edit.GetSafeHwnd(),WM_KEYDOWN,27,0);
}
}
if(pMsg->message==WM_KEYDOWN&&pMsg->wParam==13)
{
if(hwnd!=this->m_btnOk.GetSafeHwnd())
this->SetTheFocus();
}
if(pMsg->message==WM_KEYDOWN&&pMsg->wParam==VK_TAB)
{
if(this->FromHandle(hwnd)->GetDlgCtrlID()==IDCANCEL)
{
pMsg->wParam=VK_CONTROL;
this->SetTheFocus();
}
}
if(pMsg->message==WM_DESTROY)
TRACE("WM_DESTROY");
if(pMsg->message==WM_CLOSE)
TRACE("WM_CLOSE");
if(pMsg->message==WM_QUIT)
TRACE("WM_QUIT");
return CDialog::PreTranslateMessage(pMsg);
}
void CDlgXSDJ::OnButton1()
{
m_plistXSDJ->DeleteSelected();
}
bool CDlgXSDJ::InitStringLists()
{
CString sql;
_variant_t value;
m_strlistKh=new CStringList[2];
if(m_bXs)
{
m_strlistKh[0].AddTail("客户编号");
m_strlistKh[1].AddTail("客户全称");
sql.Format("select DISTINCT kh_id,kh_name from tabkh order by kh_id asc");
if(!this->m_runsql.CheckSQLResult(sql))return false;
while(!m_runsql.m_recordset->adoEOF)
{
value=m_runsql.m_recordset->GetCollect("kh_id");
if(value.vt!=VT_NULL)
{
this->m_strlistKh[0].AddTail((char*)(_bstr_t)value);
}