⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 userdialog.cpp

📁 无线图象监控系统(用VC++编程)用数据库ACCESS存储图象
💻 CPP
字号:
// UserDialog.cpp : implementation file
//

#include "stdafx.h"
#include "MoinorCentre.h"
#include "UserDialog.h"
#include "Newuser.h"
#include "KeyModify.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CUserDialog dialog


CUserDialog::CUserDialog(CWnd* pParent /*=NULL*/)
	: CDialog(CUserDialog::IDD, pParent)
{usernum=0;
	//{{AFX_DATA_INIT(CUserDialog)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void CUserDialog::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CUserDialog)
	DDX_Control(pDX, IDC_LIST1, m_userlist);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CUserDialog, CDialog)
	//{{AFX_MSG_MAP(CUserDialog)
	ON_BN_CLICKED(IDC_DEL, OnDel)
	ON_BN_CLICKED(IDC_NEW, OnNew)
	ON_BN_CLICKED(IDC_CHAGE, OnChage)
	ON_WM_CTLCOLOR()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CUserDialog message handlers

BOOL CUserDialog::OnInitDialog() 
{  
	CDialog::OnInitDialog();
	if(!m_user.IsOpen())
		m_user.Open();
	m_user.MoveFirst();
while(!m_user.IsEOF())
	 {
		 
	   m_userlist.AddString(m_user.m_username);
	   m_user.MoveNext();
	   usernum++;
	 }
//AfxMessageBox("请选择要删除的管理员");
//usernum=m_user.GetIndexCount();
m_user.MoveFirst();
	// TODO: Add extra initialization here
CDib beijing;
	 beijing.Load(".//res//dd.bmp");
	 CRect ff;
GetWindowRect(ff);
beijing.ChangeImageSize(ff.Width(),ff.Height());
  m_brush.CreateDIBPatternBrush(beijing.m_hDib,DIB_PAL_COLORS);	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CUserDialog::OnDel() 
{
if(m_userlist.GetCurSel()==CB_ERR)
     AfxMessageBox("请选择要删除的管理员");
	 else
{int index=m_userlist.GetCurSel();
CString name;
m_userlist.GetText(index,name);
CString look;
   look.Format("username='%s'",name);

  if(m_user.FindFirst(look))
  {CString xunwen;
     xunwen.Format("确定要删除管理员帐号%s吗?",name);

	  if(AfxMessageBox(xunwen,MB_YESNO)== IDYES) 
	  {  if(usernum==1)
	      AfxMessageBox("必须要有一个管理员不能删除该管理员");
	      else
		  {
	     m_user.Delete();
		 m_userlist.DeleteString(index);
			 usernum--;
		  }
	  }
	}
}
}

//DEL int CUserDialog::usernum()
//DEL {
//DEL 
//DEL }

void CUserDialog::OnNew() 
{ShowWindow(SW_HIDE);
CNewuser newuser;
newuser.DoModal();
	
}

void CUserDialog::OnChage() 
{
	if(m_userlist.GetCurSel()==CB_ERR)
     AfxMessageBox("请选择要修改的管理员");
	 else
{int index=m_userlist.GetCurSel();
CString name;
m_userlist.GetText(index,name);
CString look;
   look.Format("username='%s'",name);

  if(m_user.FindFirst(look))
  {CKeyModify key;
   key.DoModal();
	}
}
}

HBRUSH CUserDialog::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
{
	HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
	
if(nCtlColor==CTLCOLOR_DLG)
           {
              return m_brush;
           }
	if(nCtlColor == CTLCOLOR_STATIC)
	{	pDC->SetBkMode(0);
		pDC->SetTextColor(RGB(255,100,70));
hbr = (HBRUSH)::GetStockObject(NULL_BRUSH);
	return hbr;
	}	
	// TODO: Return a different brush if the default is not desired
	return hbr;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -