/* ======================================================================================= Name :DlgUpdOp.cpp Author :Vincent Date :17/07/97 Description :implementation file for dialog box with update options ======================================================================================= Modification -> Author : Date : Description : ======================================================================================= */ /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ #include "stdafx.h" #include "mngdata5.h" #include "dlgupdop.h" #include "inidata.h" #include "HelpId.h" #include "Vss5_fct.h" #include "constant.h" /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ /* ======================================================================================= ======================================================================================= CUpdateOptionsDlg dialog ======================================================================================= ======================================================================================= */ /* ---------------------------------------------------------------------------------------- Description : constructor ---------------------------------------------------------------------------------------- */ CUpdateOptionsDlg::CUpdateOptionsDlg(CWnd* pParent /*=NULL*/) : CDialog(CUpdateOptionsDlg::IDD, pParent) { //{{AFX_DATA_INIT(CUpdateOptionsDlg) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT } /* ---------------------------------------------------------------------------------------- Description : Message Map ---------------------------------------------------------------------------------------- */ BEGIN_MESSAGE_MAP(CUpdateOptionsDlg, CDialog) //{{AFX_MSG_MAP(CUpdateOptionsDlg) ON_BN_CLICKED(IDC_CHECK_OBTAINAFTERUPDATE, OnCheckObtainafterupdate) ON_BN_CLICKED(IDC_CHECK_FORCEUPDATE, OnCheckForceupdate) ON_WM_HELPINFO() //}}AFX_MSG_MAP END_MESSAGE_MAP() /* ======================================================================================= CUpdateOptionsDlg message handlers ======================================================================================= */ /* ---------------------------------------------------------------------------------------- Description : WM_INITDIALOG ---------------------------------------------------------------------------------------- */ BOOL CUpdateOptionsDlg::OnInitDialog() { /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ CButton *p_oBtObtain, *p_oBtConfirm, *p_oBtForce, *p_oBtDiff; BOOL bObtain, bForce, bConfirm, bDiff; /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ CDialog::OnInitDialog(); /* * Set first group of options buttons ( force updating ) */ p_oBtForce = (CButton *) GetDlgItem( IDC_CHECK_FORCEUPDATE ); p_oBtConfirm = (CButton *) GetDlgItem( IDC_CHECK_CONFIRMBEFOREMODIF ); p_oBtDiff = (CButton *) GetDlgItem( IDC_CHECK_SHOWDIFFERENCES ); bForce = g_stWinPref.lUpdateFlags & C_UpdateOption_lForce; bConfirm = g_stWinPref.lUpdateFlags & C_UpdateOption_lConfirmForce; bDiff = g_stWinPref.lUpdateFlags & C_UpdateOption_lShowDifferences; p_oBtForce->SetCheck( bForce ? 1 : 0 ); p_oBtConfirm->EnableWindow( bForce ? 1 : 0 ); p_oBtConfirm->SetCheck( bConfirm ? 1 : 0 ); p_oBtDiff->EnableWindow( bForce ? 1 : 0 ); p_oBtDiff->SetCheck( bDiff ? 1 : 0 ); /* * Set secong group of options buttons (obtain after updating ) */ p_oBtObtain = (CButton *) GetDlgItem( IDC_CHECK_OBTAINAFTERUPDATE ); p_oBtConfirm = (CButton *) GetDlgItem( IDC_CHECK_CONFIRMBEFOREOBTAIN ); bObtain = ( g_stWinPref.lUpdateFlags & C_UpdateOption_lObtainAfter ); bConfirm = ( g_stWinPref.lUpdateFlags & C_UpdateOption_lConfirmObtainAfter ); p_oBtObtain->SetCheck( bObtain ? 1 : 0 ); p_oBtConfirm->EnableWindow( bObtain ? 1 : 0 ); p_oBtConfirm->SetCheck( bConfirm ? 1 : 0 ); return TRUE; } /* ---------------------------------------------------------------------------------------- Description : BN_CLICKED on IDOK button ---------------------------------------------------------------------------------------- */ void CUpdateOptionsDlg::OnOK() { /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ BOOL bObtain, bForce, bConfirm, bDiff; /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ bForce = ((CButton *) GetDlgItem ( IDC_CHECK_FORCEUPDATE ))->GetCheck() == 1; fn_IniD_vSetUpdateFlag( C_UpdateOption_lForce, bForce ); bConfirm = ((CButton *) GetDlgItem ( IDC_CHECK_CONFIRMBEFOREMODIF))->GetCheck() == 1; fn_IniD_vSetUpdateFlag( C_UpdateOption_lConfirmForce, bConfirm ); bDiff = ((CButton *) GetDlgItem( IDC_CHECK_SHOWDIFFERENCES ))->GetCheck() == 1; fn_IniD_vSetUpdateFlag( C_UpdateOption_lShowDifferences, bDiff ); bObtain = ((CButton *) GetDlgItem (IDC_CHECK_OBTAINAFTERUPDATE))->GetCheck() == 1; fn_IniD_vSetUpdateFlag( C_UpdateOption_lObtainAfter, bObtain ); bConfirm = ((CButton *) GetDlgItem (IDC_CHECK_CONFIRMBEFOREOBTAIN))->GetCheck() == 1; fn_IniD_vSetUpdateFlag( C_UpdateOption_lConfirmObtainAfter, bConfirm ); CDialog::OnOK(); } /* ---------------------------------------------------------------------------------------- Description : BN_CLICKED on IDC_CHECK_OBTAINAFTERUPDATE ---------------------------------------------------------------------------------------- */ void CUpdateOptionsDlg::OnCheckObtainafterupdate() { BOOL bObtain = ((CButton *) GetDlgItem( IDC_CHECK_OBTAINAFTERUPDATE ))->GetCheck() == 1; GetDlgItem( IDC_CHECK_CONFIRMBEFOREOBTAIN )->EnableWindow( bObtain ); } /* ---------------------------------------------------------------------------------------- Description : BN_CLICKED on IDC_CHECK_FORCEUPDATE ---------------------------------------------------------------------------------------- */ void CUpdateOptionsDlg::OnCheckForceupdate() { BOOL bForce = ((CButton *) GetDlgItem( IDC_CHECK_FORCEUPDATE ))->GetCheck() == 1; GetDlgItem( IDC_CHECK_CONFIRMBEFOREMODIF )->EnableWindow( bForce ); GetDlgItem( IDC_CHECK_SHOWDIFFERENCES )->EnableWindow( bForce ); } /* ---------------------------------------------------------------------------------------- Description : WM_HELPINFO ---------------------------------------------------------------------------------------- */ BOOL CUpdateOptionsDlg::OnHelpInfo(HELPINFO* pHelpInfo) { ::WinHelp(this->GetSafeHwnd(), C_szHelpFile, HELP_CONTEXT, IDH_J_UPDATEOPTIONS ); return TRUE; } /* ======================================================================================= ======================================================================================= CUpdateHistoryDlg dialog ======================================================================================= ======================================================================================= */ /* ---------------------------------------------------------------------------------------- Description : constructor ---------------------------------------------------------------------------------------- */ CUpdateHistoryDlg::CUpdateHistoryDlg(CWnd* pParent): CDialog(CUpdateHistoryDlg::IDD, pParent) { //{{AFX_DATA_INIT(CUpdateHistoryDlg) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT } /* ---------------------------------------------------------------------------------------- Description : Message map ---------------------------------------------------------------------------------------- */ BEGIN_MESSAGE_MAP(CUpdateHistoryDlg, CDialog) //{{AFX_MSG_MAP(CUpdateHistoryDlg) ON_WM_HELPINFO() //}}AFX_MSG_MAP END_MESSAGE_MAP() /* ======================================================================================= CUpdateHistoryDlg message handlers ======================================================================================= */ /* ---------------------------------------------------------------------------------------- Description : WM_HELPINFO ---------------------------------------------------------------------------------------- */ BOOL CUpdateHistoryDlg::OnHelpInfo(HELPINFO* pHelpInfo) { ::WinHelp(this->GetSafeHwnd(), C_szHelpFile, HELP_CONTEXT, IDH_J_SUMMARY ); return TRUE; } /* ---------------------------------------------------------------------------------------- Description : WM_INITDIALOG ---------------------------------------------------------------------------------------- */ BOOL CUpdateHistoryDlg::OnInitDialog() { /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ BOOL bObtain; CListBox *p_oLB; FILE *hpFile; char szLine[1024]; char *p_szEndLine; BOOL bError = TRUE; /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ CDialog::OnInitDialog(); p_oLB = (CListBox *) GetDlgItem( IDC_LIST_HISTORY ); p_oLB->ResetContent(); /* * Get latest InUpdate file version */ if ( OLE_fn_bGetFile( g_stIniData.szVssInUpdate, g_stIniData.szLocalInUpdate, 0, TRUE, &bObtain ) ) { if ((hpFile = fopen( g_stIniData.szLocalInUpdate, "rt")) != NULL) { while (fgets( szLine, 1023, hpFile)) { if (*szLine != '*') { p_szEndLine = szLine + strlen(szLine) -1; while ((*p_szEndLine == '\n') || (*p_szEndLine == '\r')) *p_szEndLine-- = 0; p_oLB->InsertString( 0, szLine ); } } bError = FALSE; } } /* * display no history if an error occurs */ if (bError) p_oLB->AddString("No previous update operation found" ); return TRUE; } /* ======================================================================================= ======================================================================================= CUpdateFileListDlg dialog ======================================================================================= ======================================================================================= */ /* ---------------------------------------------------------------------------------------- Description : constructor ---------------------------------------------------------------------------------------- */ CUpdateFileListDlg::CUpdateFileListDlg(CWnd* pParent /*=NULL*/) : CDialog(CUpdateFileListDlg::IDD, pParent) { m_p_oFileDlg = NULL; //{{AFX_DATA_INIT(CUpdateFileListDlg) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT } /* ---------------------------------------------------------------------------------------- Description : MessageMap ---------------------------------------------------------------------------------------- */ BEGIN_MESSAGE_MAP(CUpdateFileListDlg, CDialog) //{{AFX_MSG_MAP(CUpdateFileListDlg) ON_BN_CLICKED(IDC_BUTTON_NEWCONFIG, OnButtonNewconfig) ON_WM_DESTROY() ON_WM_SIZE() ON_WM_SIZING() //}}AFX_MSG_MAP END_MESSAGE_MAP() /* ======================================================================================= CUpdateFileListDlg message handlers ======================================================================================= */ /* ---------------------------------------------------------------------------------------- Description : WM_INITDIALOG ---------------------------------------------------------------------------------------- */ BOOL CUpdateFileListDlg::OnInitDialog() { CDialog::OnInitDialog(); GetDlgItem( IDC_BUTTON_NEWCONFIG )->ShowWindow( m_p_oFileDlg != NULL ); m_p_stConfig = &g_stIniData.stUpdateConfig; m_fn_vRefreshFileList(); /* set color of certain Wnd */ CDC *p_oDC = GetDlgItem( IDC_STATIC_FILELIST )->GetDC(); p_oDC->SetBkColor( RGB(255,0, 255) ); p_oDC->SetTextColor( RGB( 0,0,0) ); MoveWindow( &g_stWinPref.stUpdateWithConfigPos ); return TRUE; } /* ---------------------------------------------------------------------------------------- Description : BN_CLICKED on IDC_BUTTON_NEWCONFIG ---------------------------------------------------------------------------------------- */ void CUpdateFileListDlg::OnDestroy() { CDialog::OnDestroy(); GetWindowRect( &g_stWinPref.stUpdateWithConfigPos ); } /* ---------------------------------------------------------------------------------------- Description : WM_SIZE ---------------------------------------------------------------------------------------- */ void CUpdateFileListDlg::OnSize(UINT nType, int cx, int cy) { if (GetDlgItem( IDC_STATIC_CONFIG) != NULL) { GetDlgItem( IDC_STATIC_CONFIG )->SetWindowPos( NULL, 5, 7, 0, 0, SWP_NOZORDER | SWP_NOSIZE ); GetDlgItem( IDC_EDIT_CONFIG )->SetWindowPos( NULL, 75 ,5, cx - 230, 20, SWP_NOZORDER ); GetDlgItem( IDC_BUTTON_NEWCONFIG )->SetWindowPos( NULL, cx - 150, 5,0, 0, SWP_NOZORDER | SWP_NOSIZE ); GetDlgItem( IDC_STATIC_FILELIST )->SetWindowPos( NULL, 5, 30, 0, 0, SWP_NOZORDER | SWP_NOSIZE ); GetDlgItem( IDC_LIST_FILES )->SetWindowPos( NULL, 5, 45, cx - 10, cy - 80, SWP_NOZORDER ); GetDlgItem( IDOK )->SetWindowPos( NULL, 5, cy - 25, 0, 0, SWP_NOZORDER | SWP_NOSIZE ); GetDlgItem( IDCANCEL )->SetWindowPos( NULL, cx- 80, cy - 25, 0, 0, SWP_NOZORDER | SWP_NOSIZE ); } CDialog::OnSize(nType, cx, cy); } /* ---------------------------------------------------------------------------------------- Description : WM_SIZING ---------------------------------------------------------------------------------------- */ void CUpdateFileListDlg::OnSizing(UINT nSide, LPRECT lpRect) { long lWidth = lpRect->right - lpRect->left + 1; long lHeight= lpRect->bottom - lpRect->top + 1; if (lWidth < C_iUpdateWithConfigMinWidth) { switch (nSide) { case WMSZ_BOTTOMLEFT: case WMSZ_LEFT: case WMSZ_TOPLEFT: lpRect->left = lpRect->right - C_iUpdateWithConfigMinWidth; break; case WMSZ_BOTTOMRIGHT: case WMSZ_RIGHT: case WMSZ_TOPRIGHT: lpRect->right = lpRect->left + C_iUpdateWithConfigMinWidth; break; } } if (lHeight < C_iUpdateWithConfigMinHeight) { switch (nSide) { case WMSZ_BOTTOM: case WMSZ_BOTTOMLEFT: case WMSZ_BOTTOMRIGHT: lpRect->bottom = lpRect->top + C_iUpdateWithConfigMinHeight; break; case WMSZ_TOP: case WMSZ_TOPLEFT: case WMSZ_TOPRIGHT: lpRect->top = lpRect->bottom - C_iUpdateWithConfigMinHeight; } } CDialog::OnSizing(nSide, lpRect); } /* ---------------------------------------------------------------------------------------- Description : BN_CLICKED on IDC_BUTTON_NEWCONFIG ---------------------------------------------------------------------------------------- */ void CUpdateFileListDlg::OnButtonNewconfig() { if (fn_Tree_bBuildFromDisk( &g_p_stLocalRootProject, g_stIniData.szLocalPath ) ) { fn_Tree_vRefreshWithFileList( g_p_stLocalRootProject, m_p_stConfig ); m_p_oFileDlg->m_fn_vSetConfigType( C_ConfigType_cUpdate ); if (m_p_oFileDlg->DoModal() == IDOK) { fn_IniD_vWriteFileList( m_p_stConfig, g_szIniFile ); m_fn_vRefreshFileList(); } else { if (g_stIniData.a_cAvailableConfig[ m_p_stConfig->cIndex ] == 0) { m_p_stConfig->cIndex = -1; fn_IniD_vFreeFileList( m_p_stConfig ); m_fn_vRefreshFileList(); } } } } /* ======================================================================================= CUpdateFileListDlg specific functions ======================================================================================= */ /* ---------------------------------------------------------------------------------------- Description : add to file list all file of file list configuration ---------------------------------------------------------------------------------------- */ void CUpdateFileListDlg::m_fn_vRefreshFileList( void ) { CListBox *p_oLB = (CListBox *) GetDlgItem( IDC_LIST_FILES ); int iFile; p_oLB->ResetContent(); if (m_p_stConfig->lNumberOfFiles == 0) { p_oLB->AddString( "" ); GetDlgItem ( IDOK )->EnableWindow( FALSE ); } else { GetDlgItem( IDC_EDIT_CONFIG ) ->SetWindowText( m_p_stConfig->szName ); for (iFile = 0; iFile < m_p_stConfig->lNumberOfFiles; iFile++ ) p_oLB->AddString( m_p_stConfig->d_szFile[ iFile ] ); GetDlgItem ( IDOK )->EnableWindow( TRUE ); } } /* ======================================================================================= ======================================================================================= CYesNoAllDlg dialog ======================================================================================= ======================================================================================= */ /* ---------------------------------------------------------------------------------------- Description : constructor ---------------------------------------------------------------------------------------- */ CYesNoAllDlg::CYesNoAllDlg(CWnd* pParent /*=NULL*/) : CDialog(CYesNoAllDlg::IDD, pParent) { //{{AFX_DATA_INIT(CYesNoAllDlg) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT m_p_stFont = (PLOGFONT) LocalAlloc(LPTR, sizeof(LOGFONT)); strcpy(m_p_stFont->lfFaceName, "Arial"); m_p_stFont->lfWeight = FW_NORMAL ; m_p_stFont->lfHeight = 16; m_p_stFont->lfEscapement = 0; m_oFont.CreateFontIndirect(m_p_stFont); } /* ---------------------------------------------------------------------------------------- Description : destructor ---------------------------------------------------------------------------------------- */ CYesNoAllDlg::~CYesNoAllDlg() { m_oFont.DeleteObject(); LocalFree(m_p_stFont); } /* ---------------------------------------------------------------------------------------- Description : Message map ---------------------------------------------------------------------------------------- */ BEGIN_MESSAGE_MAP(CYesNoAllDlg, CDialog) //{{AFX_MSG_MAP(CYesNoAllDlg) ON_BN_CLICKED(IDC_BUTTON_NOALL, OnButtonNoall) ON_BN_CLICKED(IDC_BUTTON_YESALL, OnButtonYesall) ON_WM_PAINT() //}}AFX_MSG_MAP END_MESSAGE_MAP() /* ======================================================================================= CYesNoAllDlg message handlers ======================================================================================= */ /* ---------------------------------------------------------------------------------------- Description : WM_INITDIALOG ---------------------------------------------------------------------------------------- */ BOOL CYesNoAllDlg::OnInitDialog() { int iX, iDeltaX, iY; CDialog::OnInitDialog(); fn_vComputeDialogSize(); //GetDlgItem( IDC_STATIC_MESSAGE )->SetWindowPos( NULL, 5, 5, m_oDialogSize.cx - 10, m_oDialogSize.cy - 40, SWP_NOZORDER ); GetDlgItem( IDC_STATIC_MESSAGE )->ShowWindow( FALSE ); iX = 5; iY = m_oDialogSize.cy - 25; iDeltaX = (m_oDialogSize.cx - 10) / 4; GetDlgItem( IDOK )->SetWindowPos( NULL, iX, iY, iDeltaX, 20, SWP_NOZORDER ); iX += iDeltaX; GetDlgItem( IDC_BUTTON_YESALL )->SetWindowPos( NULL, iX, iY, iDeltaX, 20, SWP_NOZORDER ); iX += iDeltaX; GetDlgItem( IDCANCEL )->SetWindowPos( NULL, iX, iY, iDeltaX, 20, SWP_NOZORDER ); iX += iDeltaX; GetDlgItem( IDC_BUTTON_NOALL )->SetWindowPos( NULL, iX, iY, iDeltaX, 20, SWP_NOZORDER ); iX = m_oDialogSize.cx + 2 * GetSystemMetrics( SM_CXSIZEFRAME ); iY = m_oDialogSize.cy + 2 * GetSystemMetrics( SM_CYSIZEFRAME ) + GetSystemMetrics( SM_CYCAPTION ); SetWindowPos( NULL, 0, 0, iX, iY, SWP_NOZORDER | SWP_NOMOVE); SetWindowText( cstrTitle ); //GetDlgItem( IDC_STATIC_MESSAGE )->SetWindowText( cstrMessage ); return TRUE; } /* ---------------------------------------------------------------------------------------- Description : BN_CLICKED on IDC_BUTTON_NOALL ---------------------------------------------------------------------------------------- */ void CYesNoAllDlg::OnButtonNoall() { cChoice = C_CHOICE_cNoAll; CDialog::OnCancel(); } /* ---------------------------------------------------------------------------------------- Description : BN_CLICKED on IDC_BUTTON_YESALL button ---------------------------------------------------------------------------------------- */ void CYesNoAllDlg::OnButtonYesall() { cChoice = C_CHOICE_cYesAll; CDialog::OnOK(); } /* ---------------------------------------------------------------------------------------- Description : BN_CLICKED on IDCANCEL button ---------------------------------------------------------------------------------------- */ void CYesNoAllDlg::OnCancel() { cChoice = C_CHOICE_cNo; CDialog::OnCancel(); } /* ---------------------------------------------------------------------------------------- Description : BN_CLICKED on IDOK button ---------------------------------------------------------------------------------------- */ void CYesNoAllDlg::OnOK() { cChoice = C_CHOICE_cYes; CDialog::OnOK(); } /* ======================================================================================= CYesNoAllDlg specific functions ======================================================================================= */ /* ---------------------------------------------------------------------------------------- Description : set title of YesallNo dialog box ---------------------------------------------------------------------------------------- */ void CYesNoAllDlg::fn_vSetTitle( char *_szTitle ) { cstrTitle = _szTitle; } /* ---------------------------------------------------------------------------------------- Description : Set message ---------------------------------------------------------------------------------------- */ void CYesNoAllDlg::fn_vSetMessage( char *_szMessage ) { cstrMessage = _szMessage; } /* ---------------------------------------------------------------------------------------- Description : Set message ---------------------------------------------------------------------------------------- */ void CYesNoAllDlg::fn_vComputeDialogSize( void ) { char *szBeginLine, *szEndLine; char cNbLines; CSize oLineSize, oMsgSize(0,0) ; CDC *p_oDC = GetDC(); p_oDC->SelectObject(&m_oFont); cNbLines = 0; szBeginLine = (char *) (LPCTSTR) cstrMessage; while ( *szBeginLine ) { cNbLines++; if ( (szEndLine = strchr( szBeginLine, '\n' )) == NULL) szEndLine = strchr( szBeginLine, 0 ); oLineSize = p_oDC->GetOutputTextExtent( szBeginLine, szEndLine - szBeginLine ); if (oLineSize.cx > oMsgSize.cx) oMsgSize.cx = oLineSize.cx; oMsgSize.cy += oLineSize.cy; szBeginLine = szEndLine + ((*szEndLine == 0) ? 0 : 1); } GetDlgItem( IDC_STATIC_MESSAGE )->ReleaseDC( p_oDC ); m_oDialogSize.cx = oMsgSize.cx + 10; m_oDialogSize.cy = oMsgSize.cy + 40; if (m_oDialogSize.cx < 200 ) m_oDialogSize.cx = 200; } /* ---------------------------------------------------------------------------------------- Description : WM_PAINT ---------------------------------------------------------------------------------------- */ void CYesNoAllDlg::OnPaint() { CPaintDC dc(this); // device context for painting RECT stRect; dc.SelectObject(&m_oFont); stRect.left = stRect.top = 5; stRect.right = m_oDialogSize.cx - 5; stRect.bottom = m_oDialogSize.cy - 35; dc.FillSolidRect( &stRect, RGB(247, 210, 213) ); dc.SetBkMode( TRANSPARENT ); dc.DrawText( cstrMessage, CRect(5,5,m_oDialogSize.cx-5, m_oDialogSize.cy - 35), 0 ); // Do not call CDialog::OnPaint() for painting messages }