/* ======================================================================================= Name : DlgLogin.cpp Author : vincent lhullier Date :27/07/97 Description : implementation fiole for login dialog box ======================================================================================= Modification -> Author : Date : Description : ======================================================================================= */ /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ #include "stdafx.h" #include #include "MngData5.h" #include "DlgLogin.h" #include "HelpId.h" /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ /* ======================================================================================= CLoginDialog dialog ======================================================================================= */ /* ---------------------------------------------------------------------------------------- Description : constructor ---------------------------------------------------------------------------------------- */ CLoginDialog::CLoginDialog(CWnd* pParent /*=NULL*/) : CDialog(CLoginDialog::IDD, pParent) { //{{AFX_DATA_INIT(CLoginDialog) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT *m_szUserName = 0; *m_szDatabase = 0; *m_szPassword = 0; } /* ---------------------------------------------------------------------------------------- Description : Message map ---------------------------------------------------------------------------------------- */ BEGIN_MESSAGE_MAP(CLoginDialog, CDialog) //{{AFX_MSG_MAP(CLoginDialog) ON_BN_CLICKED(IDC_BUTTON_BROWSE, OnButtonBrowse) ON_WM_SHOWWINDOW() ON_WM_HELPINFO() //}}AFX_MSG_MAP END_MESSAGE_MAP() /* ======================================================================================= Specific functions ======================================================================================= */ /* ---------------------------------------------------------------------------------------- Description : Set user name that will be in Username edit box ---------------------------------------------------------------------------------------- */ void CLoginDialog::m_fn_vSetUserName( char *_szName ) { DWORD dwUserLength = 100; if (*_szName == 0) GetUserName( m_szUserName, &dwUserLength ); else strcpy ( m_szUserName, _szName ); } /* ---------------------------------------------------------------------------------------- Description : Set database name that will be in database edit box ---------------------------------------------------------------------------------------- */ void CLoginDialog::m_fn_vSetDatabase( char *_szDatabase ) { strcpy( m_szDatabase, _szDatabase ); } /* ======================================================================================= CLoginDialog message handlers ======================================================================================= */ /* ---------------------------------------------------------------------------------------- Description : WM_INITDIALOG ---------------------------------------------------------------------------------------- */ BOOL CLoginDialog::OnInitDialog() { CDialog::OnInitDialog(); m_bInit = TRUE; GetDlgItem( IDC_EDIT_USERNAME ) ->SetWindowText( m_szUserName ); GetDlgItem( IDC_EDIT_PASSWORD ) ->SetWindowText( m_szPassword ); GetDlgItem( IDC_EDIT_DATABASE ) ->SetWindowText( m_szDatabase ); if (*m_szPassword != 0) { ((CEdit *) GetDlgItem( IDC_EDIT_PASSWORD ))->SetSel( 0, -1 ); } SetWindowPos( &wndTopMost, 0,0,0,0, SWP_NOSIZE | SWP_NOMOVE ); return TRUE; } /* ---------------------------------------------------------------------------------------- Description : BN_CLICKED on IDOK button ---------------------------------------------------------------------------------------- */ void CLoginDialog::OnOK() { GetDlgItem( IDC_EDIT_USERNAME )->GetWindowText( m_szUserName, 100 ); GetDlgItem( IDC_EDIT_PASSWORD )->GetWindowText( m_szPassword, 100 ); GetDlgItem( IDC_EDIT_DATABASE )->GetWindowText( m_szDatabase, MAX_PATH ); CDialog::OnOK(); } /* ---------------------------------------------------------------------------------------- Description : BN_CLICKED on IDC_BUTTON_BROWSE ---------------------------------------------------------------------------------------- */ void CLoginDialog::OnButtonBrowse() { static char BASED_CODE szFilter[] = "Vss Database(srcsafe.ini)|srcsafe.ini||"; DWORD dwFlags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_NOCHANGEDIR; CFileDialog oFD( TRUE, "ini", "srcsafe.ini", dwFlags, szFilter, this); if (oFD.DoModal() == IDOK) { strcpy ( m_szDatabase, (char *) (LPCTSTR) oFD.GetPathName() ); GetDlgItem( IDC_EDIT_DATABASE ) ->SetWindowText( m_szDatabase ); } } /* ---------------------------------------------------------------------------------------- Description : WM_SHOWWINDOW ---------------------------------------------------------------------------------------- */ void CLoginDialog::OnShowWindow(BOOL bShow, UINT nStatus) { CDialog::OnShowWindow(bShow, nStatus); /* * Assure that PASSWORD edit box has the focus */ if (m_bInit) { m_bInit = FALSE; GetDlgItem( IDC_EDIT_PASSWORD )->SetFocus(); } } /* ---------------------------------------------------------------------------------------- Description : WM_HELPINFO ---------------------------------------------------------------------------------------- */ BOOL CLoginDialog::OnHelpInfo(HELPINFO* pHelpInfo) { ::WinHelp(this->GetSafeHwnd(), C_szHelpFile, HELP_CONTEXT, IDH_J_LOGIN ); return TRUE; }