📄 useredit.cpp
字号:
// UserEdit.cpp : implementation file
//
#include "stdafx.h"
#include "Monitor.h"
#include "UserEdit.h"
#include "InfoEdit.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CUserEdit dialog
CUserEdit::CUserEdit(CWnd* pParent /*=NULL*/)
: CDialog(CUserEdit::IDD, pParent)
{
//{{AFX_DATA_INIT(CUserEdit)
m_strAddress = _T("");
m_strCompany = _T("");
m_strMail = _T("");
m_strName = _T("");
m_strPassword = _T("");
m_strPerson = _T("");
m_strPhone = _T("");
//}}AFX_DATA_INIT
bTypeChanged=FALSE;
}
void CUserEdit::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CUserEdit)
DDX_Text(pDX, IDC_ADDRESS, m_strAddress);
DDX_Text(pDX, IDC_COMPANY, m_strCompany);
DDX_Text(pDX, IDC_MAIL, m_strMail);
DDX_Text(pDX, IDC_NAME, m_strName);
DDX_Text(pDX, IDC_PASSWORD, m_strPassword);
DDX_Text(pDX, IDC_PERSON, m_strPerson);
DDX_Text(pDX, IDC_PHONE, m_strPhone);
DDX_Control(pDX, IDC_BIG_BEGIN, m_BigBegin);
DDX_Control(pDX, IDC_BIG_END, m_BigEnd);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CUserEdit, CDialog)
//{{AFX_MSG_MAP(CUserEdit)
ON_BN_CLICKED(IDC_BEGIN_BUTTON, OnBeginButton)
ON_BN_CLICKED(IDC_END_BUTTON, OnEndButton)
ON_BN_CLICKED(IDC_INVERT, OnInvert)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CUserEdit message handlers
void CUserEdit::OnOK()
{
// TODO: Add extra validation here
UpdateData();
m_pInfoEdit->SaveData();
delete m_pInfoEdit;
if(m_strName!=ThisUser->Name)
{
ThisUser->NewName=m_strName;
ThisUser->bNameChanged=TRUE;
}
if(m_strPassword=ThisUser->Pass)
{
ThisUser->Pass=m_strPassword;
ThisUser->bPassChanged=TRUE;
}
ThisUser->bTypeChanged=ThisUser->bTypeChanged||bTypeChanged;
CDialog::OnOK();
}
BOOL CUserEdit::SetData(CXhinfo *User, CObArray *Types)
{
ThisUser=User;
TypeList=Types;
iTypeNumber=Types->GetSize();
CTypeValue *pOneValue;
int i;
for(i=0;i<iTypeNumber;i++)
{
pOneValue=new CTypeValue;
UserValueList.Add(pOneValue);
}
int iSelected=ThisUser->InfoArray.GetSize();
for(i=0;i<iSelected;i++)
{
CTypeValue *p=(CTypeValue*)ThisUser->InfoArray.GetAt(i);
pOneValue=(CTypeValue*)UserValueList.GetAt(p->iKey);
*pOneValue=*p;
}
m_strName=ThisUser->Name;
m_strPassword=ThisUser->Pass;
return TRUE;
}
BOOL CUserEdit::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
VARIANT myDate;
myDate.vt=VT_DATE;
COleDateTime d=COleDateTime::GetCurrentTime();
d.SetDateTime(d.GetYear(),d.GetMonth(),d.GetDay(),0,0,0);
myDate.date=d.m_dt;
m_BigBegin.SetValue(myDate);
d.SetDateTime(d.GetYear()+1,d.GetMonth(),d.GetDay(),23,59,59);
d.m_dt--;
myDate.date=d.m_dt;
m_BigEnd.SetValue(myDate);
m_pInfoEdit=new CInfoEdit;
m_pInfoEdit->SetData(&UserValueList,TypeList);
m_pInfoEdit->Create(NULL,NULL,WS_CHILD|WS_VISIBLE|WS_BORDER,CRect(13,100,752,405)
,this,IDD_INFOEDIT,NULL);
m_pInfoEdit->OnInitialUpdate();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
BEGIN_EVENTSINK_MAP(CUserEdit, CDialog)
//{{AFX_EVENTSINK_MAP(CUserEdit)
//}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()
void CUserEdit::OnBeginButton()
{
// TODO: Add your control notification handler code here
VARIANT *result=new VARIANT;
*result=m_BigBegin.GetValue();
::SendNotifyMessage(m_pInfoEdit->m_hWnd,SET_VALUE,1,(long)result);
delete result;
}
void CUserEdit::OnEndButton()
{
// TODO: Add your control notification handler code here
VARIANT *result=new VARIANT;
*result=m_BigEnd.GetValue();
::SendNotifyMessage(m_pInfoEdit->m_hWnd,SET_VALUE,2,(long)result);
delete result;
}
void CUserEdit::OnInvert()
{
// TODO: Add your control notification handler code here
::SendNotifyMessage(m_pInfoEdit->m_hWnd,INVERT_CONTROL,0,0);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -