PassWordDlg.cpp
上传用户:yffx2008
上传日期:2014-10-12
资源大小:12414k
文件大小:3k
- // PassWordDlg.cpp : implementation file
- //
- #include "stdafx.h"
- #include "GpsSC.h"
- #include "PassWordDlg.h"
- #include "UserSet.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CPassWordDlg dialog
- extern CGpsSCApp theApp;
- CPassWordDlg::CPassWordDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CPassWordDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CPassWordDlg)
- m_strPassWord = _T("");
- m_strUsers = _T("");
- //}}AFX_DATA_INIT
- }
- void CPassWordDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CPassWordDlg)
- DDX_Control(pDX, IDC_USERCOMBO, m_ctrlUserCombo);
- DDX_Text(pDX, IDC_PASSWORD, m_strPassWord);
- DDV_MaxChars(pDX, m_strPassWord, 10);
- DDX_CBString(pDX, IDC_USERCOMBO, m_strUsers);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CPassWordDlg, CDialog)
- //{{AFX_MSG_MAP(CPassWordDlg)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CPassWordDlg message handlers
- BOOL CPassWordDlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
-
- // TODO: Add extra initialization here
- //InitDialog();
- m_strUsers = theApp.m_strLoginUser;
- UpdateData(FALSE);
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- //Get project dir
- CString CPassWordDlg::GetProjectInDir()
- {
- CString Path;
- char Name[MAX_PATH+1];
- int Len,i;
- TCHAR chr = 0;
- GetModuleFileName(NULL,Name,MAX_PATH);
- Path = Name;
- Len = Path.GetLength();
- for(i = Len - 1; i >= 0; i--) {
- chr = Path.GetAt(i);
- if(chr == '\') break;
- }
- i++;
- Path = Path.Left(i);
- return Path;
- }
- //Get the conttent
- char * CPassWordDlg::GetConttent(const CString strpassderectory)
- {
- CFile f;
- int m_lFileBufLength;
- char * m_pFileBuf = NULL;
-
- if(!f.Open(strpassderectory,CFile::modeRead,NULL))
- {
- AfxMessageBox("open files error!");
- return "nihao";
- }
- f.SeekToBegin();
- m_lFileBufLength = f.GetLength();
-
- m_pFileBuf = new char[m_lFileBufLength];
- f.SeekToBegin();
- f.Read(m_pFileBuf,m_lFileBufLength);
- f.Close();
- m_pFileBuf[m_lFileBufLength] = ' ';
- int a = strlen(m_pFileBuf);
- return m_pFileBuf;
- }
- //Inite the dilalog
- void CPassWordDlg::InitDialog()
- {
- return;
- CString strDir = GetProjectInDir();
- strDir += "sysinit.ini";
- CString strTmpUser(""),strTmpPass("");
- //get conttent
- BYTE useNo = 0;
- char * m_pConttent = GetConttent(strDir);
- CString strConttent(m_pConttent);
- //get hte Number of the users
- for(int i = 0;i < strConttent.GetLength(); i++){
- if(strConttent.GetAt(i) == '@')
- useNo ++;
- }
- int k1 = strConttent.Find('$');
- int k2 = strConttent.Find('#');
- int k3 = strConttent.Find('@');
-
- AfxMessageBox(strConttent);
-
- }
- void CPassWordDlg::OnOK()
- {
- // TODO: Add extra validation here
- UpdateData(TRUE);
- CUserSet cSet;
- if(cSet.CheckLogin(m_strUsers,m_strPassWord))
- {
- theApp.m_strLoginUser = m_strUsers;
- CDialog::OnOK();
- }
- }