/* ======================================================================================= Name :DlgMain.cpp Author :vincent lhullier Date :18/07/97 Description :main dialog box , implementation file ======================================================================================= Modification -> Author : Date : Description : ======================================================================================= */ /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ #include "stdafx.h" #include "shlobj.h" #include #include "MngData5.h" #include "DlgMain.h" #include "DlgModif.h" #include "DlgFile.h" #include "DlgUpdOp.h" #include "DlgAbout.h" #include "DlgObtai.h" #include "HelpId.h" #include "constant.h" #include "LogFile.h" #include "SaveMngr.h" #include "MajData.h" #include "Vss5_fct.h" #include "Error.h" #include "Constant.h" #include "ProgBar.h" /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ /* ======================================================================================= GLOBALS ======================================================================================= */ /* * Color for line in Rich edit ctrl */ static COLORREF gs_a_xColor[3] = { RGB( 0, 255,255), RGB( 0,255,64), RGB(255,128,128) }; /* ======================================================================================= MACROS ======================================================================================= */ #define M_DisplayInfoLine( _szInfo )\ {\ m_fn_Result_vAddLine( _szInfo, C_Result_cInfoLine );\ m_fn_vPause();\ m_oProgress.StepIt();\ } /* ======================================================================================= CMngDataDlg class ======================================================================================= */ /* --------------------------------------------------------------------------------------- constructor --------------------------------------------------------------------------------------- */ CMngDataDlg::CMngDataDlg(CWnd* pParent /*=NULL*/) : CDialog(CMngDataDlg::IDD, pParent) { //{{AFX_DATA_INIT(CMngDataDlg) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); // init cheat code string memset( m_szCheat, 0, 6); m_lCheatFlag = 0; // init work status m_bWorkInProgress = FALSE; m_bRequestToStop = FALSE; m_bBatchObtain = FALSE; m_bInitOK = FALSE; m_bBaseStatusTimerOn = FALSE; // Init Vss database (OLE Server) OLE_fn_bInitVss( ); // init random number list srand( (unsigned) time ( NULL ) ); // init list of controls m_a_uiEditControl[0] = IDC_EDIT_LOCALPATH; m_a_uiEditControl[1] = IDC_EDIT_VSSPATH; m_a_uiEditControl[2] = IDC_EDIT_INUPDATE; m_a_uiEditControl[3] = IDC_EDIT_INOBTAIN; m_a_uiEditControl[4] = IDC_EDIT_MODIFFILE; m_a_uiEditControl[5] = IDC_EDIT_MODIFICATION; m_a_uiEditControl[6] = IDC_EDIT_OBTAINTIME; m_cNbEditBox = 7; m_a_uiRightAlignedButton[0] = IDC_BUTTON_BROWSE; m_a_uiRightAlignedButton[1] = IDC_BUTTON_VSSFILES; m_a_uiRightAlignedButton[2] = IDC_BUTTON_LOOKUPDATE; m_a_uiRightAlignedButton[3] = IDC_BUTTON_LOOKOBTAIN; m_a_uiRightAlignedButton[4] = IDC_BUTTON_CLEARMODIF; m_a_uiRightAlignedButton[5] = IDC_BUTTON_VIEWMODIF; m_cNbRightButtons = 6; m_a_uiBottomButton[0] = IDC_BUTTON_REFRESH; m_a_uiBottomButton[1] = IDC_CHECK_OBTAINMENU; m_a_uiBottomButton[2] = IDC_CHECK_UPDATE; m_a_uiBottomButton[3] = IDCANCEL; m_a_uiBottomButton[4] = IDC_CHECK_HELP; m_cNbBottomButtons = 5; m_bQuitFromSysCommand = FALSE; } /* --------------------------------------------------------------------------------------- On command --------------------------------------------------------------------------------------- */ BOOL CMngDataDlg::OnCommand(WPARAM wParam, LPARAM lParam) { if (HIWORD(wParam) == 0) { switch (LOWORD(wParam)) { /* display about box */ case IDM_ABOUTBOX: { CAboutDlg dlgAbout; dlgAbout.DoModal(); break; } /* display help file */ case IDM_SHOWHELPFILE: ::WinHelp( this->GetSafeHwnd(), C_szHelpFile, HELP_CONTEXT, IDH_J_SUMMARY); break; /* update */ case IDM_UPDATE: if (AfxMessageBox( "Are you sure you want to\nUpdate data ?", MB_YESNO | MB_ICONQUESTION) == IDYES) { if (m_fn_bOnCommandUpdate()) { if ( g_stWinPref.lUpdateFlags & C_UpdateOption_lObtainAfter ) { BOOL bObtain = TRUE; if ( g_stWinPref.lUpdateFlags & C_UpdateOption_lConfirmObtainAfter ) bObtain = AfxMessageBox("Do you want to obtain data now ?\r\n(it is recommended)", MB_YESNO | MB_ICONQUESTION ) == IDYES; if (bObtain) m_fn_vOnCommandObtain(); } } } break; /* show update history */ case IDM_UPDATEHISTORY: { CUpdateHistoryDlg dlgHistory( this ); dlgHistory.DoModal(); } break; /* show update options dialog */ case IDM_UPDATEOPTIONS: { CUpdateOptionsDlg dlgOptions( this ); dlgOptions.DoModal(); } break; /* show update history */ case IDM_UPDATEWITHCONFIG: { CUpdateFileListDlg dlgFileList; dlgFileList.m_fn_vSetFileDialog( &m_oFileDlg ); if (dlgFileList.DoModal() == IDOK) { m_fn_bOnCommandUpdateWithConfig(); } } break; /* obtain */ case IDM_OBTAINNOW: { if (AfxMessageBox( "Are you sure you want to\nObtain data ?", MB_YESNO | MB_ICONQUESTION) == IDYES) m_fn_vOnCommandObtain(); } break; /* batch obtain */ case IDM_OBTAIN: { if (g_lNumberOfFatherModifs != 0) { AfxMessageBox( "To do a batch obtain there must be no more modification in list\r\nclean modif list and try again", MB_OK | MB_ICONINFORMATION); } else { CBatchObtainDlg dlgObtain; m_fn_vKillTimerForBaseStatus(); dlgObtain.DoModal(); m_fn_vSetTimerForBaseStatus(); if (dlgObtain.fn_bDoObtain()) { m_bBatchObtain = TRUE; m_fn_vOnCommandObtain(); fn_bEndObtaining(); m_bBatchObtain = FALSE; } } } } } return CDialog::OnCommand(wParam, lParam); } /* --------------------------------------------------------------------------------------- message map --------------------------------------------------------------------------------------- */ BEGIN_MESSAGE_MAP(CMngDataDlg, CDialog) //{{AFX_MSG_MAP(CMngDataDlg) ON_WM_DESTROY() ON_WM_PAINT() ON_WM_QUERYDRAGICON() ON_BN_CLICKED(IDC_CHECK_OBTAINMENU, OnCheckObtainMenu) ON_BN_CLICKED(IDC_BUTTON_VIEWMODIF, OnButtonViewmodif) ON_BN_CLICKED(IDC_BUTTON_BROWSE, OnButtonBrowse) ON_BN_CLICKED(IDC_BUTTON_REFRESH, OnButtonRefresh) ON_BN_CLICKED(IDC_BUTTON_LOOKOBTAIN, OnButtonLookobtain) ON_BN_CLICKED(IDC_BUTTON_LOOKUPDATE, OnButtonLookupdate) ON_BN_CLICKED(IDC_BUTTON_VSSFILES, OnButtonVssfiles) ON_WM_SIZE() ON_WM_SIZING() ON_WM_SYSCOMMAND() ON_BN_CLICKED(IDC_CHECK_HELP, OnCheckHelp) ON_BN_CLICKED(IDC_BUTTON_CLEARMODIF, OnButtonClearmodif) ON_BN_CLICKED(IDC_CHECK_UPDATE, OnCheckUpdate) ON_BN_CLICKED(IDC_BUTTON_STOP, OnButtonStop) ON_WM_HELPINFO() ON_WM_TIMER() ON_BN_CLICKED(IDC_BUTTON_CHANGEMODIF, OnButtonChangemodif) //}}AFX_MSG_MAP END_MESSAGE_MAP() /* ======================================================================================= specific functions ======================================================================================= */ /* --------------------------------------------------------------------------------------- enable/disable all the buttons swap between running display (bEnable = FALSE : progress bar and no buttons) and waiting display (bEnable = TRUE : no progress bad, buttons are visible ) --------------------------------------------------------------------------------------- */ void CMngDataDlg::m_fn_vEnableButton( BOOL bEnable ) { /* * bEnable = TRUE -> show/enable buttons, else Hide/disable them */ GetDlgItem( IDC_BUTTON_BROWSE )->EnableWindow( bEnable ); GetDlgItem( IDC_BUTTON_VSSFILES )->EnableWindow( bEnable ); GetDlgItem( IDC_BUTTON_LOOKOBTAIN )->EnableWindow( bEnable ); GetDlgItem( IDC_BUTTON_LOOKUPDATE )->EnableWindow( bEnable ); GetDlgItem( IDC_BUTTON_CLEARMODIF )->EnableWindow( bEnable ); GetDlgItem( IDC_BUTTON_VIEWMODIF )->EnableWindow( bEnable ); GetDlgItem( IDC_BUTTON_REFRESH )->ShowWindow( bEnable ); GetDlgItem( IDC_CHECK_OBTAINMENU )->ShowWindow( bEnable ); GetDlgItem( IDC_CHECK_UPDATE )->ShowWindow( bEnable ); GetDlgItem( IDCANCEL )->ShowWindow( bEnable ); GetDlgItem( IDC_CHECK_HELP )->ShowWindow( bEnable ); /* * bEnable = TRUE -> Hide progress bar, else Show it */ GetDlgItem( IDC_PROGRESS )->ShowWindow( !bEnable ); GetDlgItem( IDC_BUTTON_STOP )->ShowWindow( !bEnable ); GetDlgItem( IDC_BUTTON_STOP )->EnableWindow( TRUE ); } /* --------------------------------------------------------------------------------------- display program information in Edit box --------------------------------------------------------------------------------------- */ void CMngDataDlg::m_fn_vDisplayProgramData( void ) { /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ char szString[100]; /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ /* write obtaining time in a string */ m_fn_vGetObtainingTimeString( szString ); GetDlgItem( IDC_EDIT_OBTAINTIME )->SetWindowText( szString ); /* write local path */ GetDlgItem( IDC_EDIT_LOCALPATH ) ->SetWindowText( g_stIniData.szLocalPath ); /* obtaining data : vss path & config */ sprintf ( szString, "%s (Config : %s)", g_stIniData.szVssPath, *g_stIniData.stObtainConfig.szName == 0 ? "None" : g_stIniData.stObtainConfig.szName ); GetDlgItem( IDC_EDIT_VSSPATH ) ->SetWindowText( szString ); /* semaphore & modif file */ GetDlgItem( IDC_EDIT_INUPDATE ) ->SetWindowText( g_stIniData.szInUpdateSem ); GetDlgItem( IDC_EDIT_INOBTAIN ) ->SetWindowText( g_stIniData.szInObtainSem ); GetDlgItem( IDC_EDIT_MODIFFILE ) ->SetWindowText( g_stIniData.szModifFile ); /* number of modifs */ GetDlgItem( IDC_EDIT_MODIFICATION)->SetWindowText( itoa( g_lNumberOfFatherModifs, szString, 10) ); GetDlgItem( IDC_BUTTON_VIEWMODIF )->EnableWindow( g_lNumberOfFatherModifs != 0 ); GetDlgItem( IDC_BUTTON_CLEARMODIF )->EnableWindow( g_lNumberOfFatherModifs != 0 ); } /* --------------------------------------------------------------------------------------- * make a pause --------------------------------------------------------------------------------------- */ void CMngDataDlg::m_fn_vPause( void ) { if (m_lCheatFlag & C_lCheatPause) { char szString[50]; sprintf(szString, "Progress : %d <-- %d --> %d", m_oProgress.m_iStart, m_oProgress.OffsetPos(0), m_oProgress.m_iEnd ); MessageBox( szString, "A little pause", MB_ICONSTOP ); } } /* --------------------------------------------------------------------------------------- * convert obtaining time into a string * szString -> buffer where time string is written must be at least 20 octets long --------------------------------------------------------------------------------------- */ void CMngDataDlg::m_fn_vGetObtainingTimeString( char *szString ) { if (g_stIniData.p_oObtainingTime->GetYear() == 100) strcpy( szString, "None"); else strcpy( szString, (char *) (LPCTSTR) g_stIniData.p_oObtainingTime->Format() ); } /* --------------------------------------------------------------------------------------- Display a fatal error and post WM_QUIT message --------------------------------------------------------------------------------------- */ void CMngDataDlg::m_fn_vFatalError( char *_szMessage ) { MessageBox(_szMessage, "MngData5 - Fatal Error", MB_ICONSTOP ); OLE_g_oDatabase.ReleaseDispatch(); PostQuitMessage( -1 ); } /* ---------------------------------------------------------------------------------------- Description : add a line in RichEdit box for result szLine -> line to add cLineType -> type of line (info, ok, error) ---------------------------------------------------------------------------------------- */ void CMngDataDlg::m_fn_Result_vAddLine( char *szLine, char cLineType ) { /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ long lOldLength; long lNewLength; long lSize; /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ m_stCharFormat.crTextColor = gs_a_xColor[ cLineType ]; m_stCharFormat.dwEffects = 0; lOldLength = m_oRichEdit.GetTextLength(); lNewLength = lOldLength + strlen( szLine ); lSize = m_oRichEdit.GetLimitText(); if (lNewLength > lSize) { lSize += 10000; m_oRichEdit.LimitText( lSize ); } m_oRichEdit.ReplaceSel( szLine ); m_oRichEdit.SetSel( lOldLength, -1 ); m_oRichEdit.SetSelectionCharFormat( m_stCharFormat ); m_oRichEdit.SetSel( lNewLength, lNewLength ); } /* ---------------------------------------------------------------------------------------- Description : delete content of result window ---------------------------------------------------------------------------------------- */ void CMngDataDlg::m_fn_Result_vResetContent( void ) { m_oRichEdit.SetWindowText( "" ); } /* --------------------------------------------------------------------------------------- Display content off result window into log file --------------------------------------------------------------------------------------- */ void CMngDataDlg::m_fn_vWriteResultToLogFile( char *szString ) { /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ char szTemp[200]; CString oStr; /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ sprintf( szTemp, "********************\n %s\n********************\n", szString ); LOG_fn_lWriteInLogFile( szTemp ); m_oRichEdit.GetWindowText( oStr ); LOG_fn_lWriteInLogFile( (char *) (LPCTSTR) oStr ); } /* ---------------------------------------------------------------------------------------- Description : init progress bar ---------------------------------------------------------------------------------------- */ void CMngDataDlg::m_fn_vInitProgessBar( int _iStart, int _iEnd ) { /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ tdstProgressBarDrawingData stPBDD; char cCol; int a_iCol[9]; /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ m_oProgress.m_fn_vSetRange( _iStart, _iEnd ); m_oProgress.m_fn_vReinit(); srand( (unsigned)time( NULL ) ); switch (rand() & 7) { case 0: stPBDD.uiAnimBitmap = IDB_BITMAP_ANIM1; stPBDD.cAnimNbFrames = 8; stPBDD.cAnimFrameWidth = 16; break; case 1: stPBDD.uiAnimBitmap = IDB_BITMAP_ANIM2; stPBDD.cAnimNbFrames = 10; stPBDD.cAnimFrameWidth = 8; break; case 2: stPBDD.uiAnimBitmap = IDB_BITMAP_ANIM4; stPBDD.cAnimNbFrames = 24; stPBDD.cAnimFrameWidth = 9; break; default: stPBDD.cAnimNbFrames = 0; } for (cCol = 0; cCol < 6; cCol ++ ) a_iCol[ cCol ] = 128 + (rand() & 0x7F); for (cCol = 0; cCol < 3; cCol ++ ) a_iCol[ 6 + cCol] = 255 - (a_iCol[ cCol ] + a_iCol[ cCol + 3 ]) / 2; stPBDD.xBackColor = 0; stPBDD.xHeadColor = RGB(a_iCol[0], a_iCol[1], a_iCol[2]); stPBDD.xTailColor = RGB(a_iCol[3], a_iCol[4], a_iCol[5]); stPBDD.xTextColor = RGB(a_iCol[6], a_iCol[7], a_iCol[8]); switch( rand() & 7 ) { case 0: strcpy( stPBDD.szText, "Ca va t'y comme vous voulez ?" ); break; case 1: strcpy( stPBDD.szText, "Vive la Bretagne libre !" ); break; case 2: sprintf( stPBDD.szText, "Salut %s", g_stIniData.szVssUserName ); break; case 3: strcpy( stPBDD.szText, "A la santé des Normands" ); break; case 4: strcpy( stPBDD.szText, "Boire un petit coup c'est..." ); break; case 5: strcpy( stPBDD.szText, "Baissons les yeux devant Serge" ); break; default: *stPBDD.szText = 0; } m_oProgress.m_fn_vInitDrawing( &stPBDD ); } /* ======================================================================================= Functions for New update function ======================================================================================= */ /* ---------------------------------------------------------------------------------------- Description : do a modif that consist on deleting a file _p_stModif -> current modif Returns (char ) -1 if fails, 0 if OK ---------------------------------------------------------------------------------------- */ char CMngDataDlg::m_fn_cDoModifFileDelete( tdstModif *_p_stModif ) { COleDateTime oDate; BOOL bContinue = TRUE; if (m_bLocalExist) { // warning a faire } if (m_cVssStatus != VSSFILE_NOTFOUND) { if (OLE_fn_bGetItemLastVersionDate( g_szVssFileName, &oDate )) { if ( oDate > *g_stIniData.p_oObtainingTime ) { bContinue = FALSE; OLE_fn_bGetItemLastVersionUserName( g_szVssFileName ); if ( g_stWinPref.lUpdateFlags & C_UpdateOption_lForce ) { bContinue = TRUE; if (g_stWinPref.lUpdateFlags & C_UpdateOption_lConfirmForce ) { sprintf (m_szMessage, "There's a conflict for %s file\nOverwrite previous modification done by %s ?", _p_stModif->szName, g_a_szUserName[0] ); bContinue = AfxMessageBox( m_szMessage, MB_YESNO | MB_ICONQUESTION ) == IDYES; } } } } if (bContinue) { if ( !OLE_fn_bDeleteFile( g_szVssFileName ) ) { Error_fn_vSetFmt( Error_eCantDeleteFile, "%s -> Error (can't delete vss file)\r\n", _p_stModif->szName ); return -1; } } else { Error_fn_vSetFmt( Error_eVssFileNewer, "%s -> Error (%s updated data before you)\r\n", _p_stModif->szName, g_a_szUserName[0] ); return -1; } } return 0; } /* ---------------------------------------------------------------------------------------- Description : do a modif that consist on modifying a file _p_stModif -> current modif _bForFile -> indicate if it's a file modification or for a section modif Returns (char ) -1 if fails, 0 if OK, 1 : ok and file was added ---------------------------------------------------------------------------------------- */ char CMngDataDlg::m_fn_cDoModifFileModif( tdstModif *_p_stModif, BOOL _bForFile ) { BOOL bContinue = TRUE; COleDateTime oDate; int cChoice; if (!m_bLocalExist) { Error_fn_vSetFmt( Error_eLocalFileNotFound, "%s -> Error : Local file not found\r\n", g_stSource.szFullName ); return -1; } if (m_cVssStatus == VSSFILE_NOTFOUND) { if (g_cAddModifiedFile == 0) { CYesNoAllDlg oQuestion; sprintf( m_szMessage, "Apparently you have modified %s file\nthat doesn't exist in vss database\n--------------------------\nAdd it ?", g_szVssFileName ); oQuestion.fn_vSetMessage( m_szMessage ); oQuestion.DoModal(); cChoice = oQuestion.fn_cGetChoice(); switch( cChoice ) { case C_CHOICE_cYesAll: g_cAddModifiedFile = cChoice; cChoice = C_CHOICE_cYes; break; case C_CHOICE_cNoAll: g_cAddModifiedFile = cChoice; cChoice = C_CHOICE_cNo; break; } } else { cChoice = (g_cAddModifiedFile == C_CHOICE_cYesAll) ? C_CHOICE_cYes : C_CHOICE_cNo; } if (cChoice == C_CHOICE_cYes) { return (m_fn_cDoModifFileAdd( _p_stModif ) == -1) ? -1 : 1; } else { Error_fn_vSetFmt( Error_eVssFileNotFound, "%s -> Error : Vss file not found\r\n", g_stSource.szFullName ); return -1; } } if (!_bForFile) return 0; if (!OLE_fn_bGetItemLastVersionDate( g_szVssFileName, &oDate )) oDate = COleDateTime::GetCurrentTime(); if ( oDate > *g_stIniData.p_oObtainingTime ) { OLE_fn_bGetItemLastVersionUserName( g_szVssFileName ); /* * check if last updater is the same as current one */ if ( stricmp( g_a_szUserName[0], g_stIniData.szVssUserName ) != 0 ) { bContinue = FALSE; if ( g_stWinPref.lUpdateFlags & C_UpdateOption_lForce ) { bContinue = TRUE; if (g_stWinPref.lUpdateFlags & C_UpdateOption_lConfirmForce ) { sprintf (m_szMessage, "There's a conflict for %s file\nOverwrite previous modification done by %s ?", _p_stModif->szName, g_a_szUserName[0] ); bContinue = AfxMessageBox( m_szMessage, MB_YESNO | MB_ICONQUESTION ) == IDYES; } } } } if (bContinue) { OLE_fn_bCheckoutFile( g_szVssFileName, g_stTarget.szFullName, VSSFLAG_REPREPLACE ); CopyFile( g_stSource.szFullName, g_stTarget.szFullName, FALSE ); OLE_fn_bCheckinFile( g_szVssFileName, g_stTarget.szFullName, VSSFLAG_DELYES ); return 0; } else { Error_fn_vSetFmt( Error_eVssFileNewer, "%s -> Error (%s updated data before you)\r\n", _p_stModif->szName, g_a_szUserName[0] ); return -1; } } /* ---------------------------------------------------------------------------------------- Description : do a modif that consist on adding a file _p_stModif -> current modif Returns (char ) -1 if fails, 0 if OK ---------------------------------------------------------------------------------------- */ char CMngDataDlg::m_fn_cDoModifFileAdd( tdstModif *_p_stModif ) { BOOL bAdd; int cChoice; if (!m_bLocalExist) { Error_fn_vSetFmt( Error_eLocalFileNotFound, "%s -> Error : Local file not found\n", g_stSource.szFullName ); return -1; } if (m_cVssStatus == VSSFILE_NOTFOUND) { sprintf( m_szMessage, "%s -> Vss file doesn't exist add it\n", g_szVssFileName ); m_fn_Result_vAddLine( m_szMessage, C_Result_cInfoLine ); char *p_szBeginFile = strrchr( g_szVssFileName,'\\' ); *p_szBeginFile = 0; bAdd = OLE_fn_bAddFile( g_szVssFileName, g_stSource.szFullName ); *p_szBeginFile = '\\'; //_p_stModif->cType = C_ModifType_cModif; return bAdd ? 0 : -1; } if (g_cDeleteSectionModif == 0) { CYesNoAllDlg oQuestion; char szMessage[1024], *p_szMessage = szMessage; p_szMessage += sprintf( p_szMessage, "Warning : %s file\n", _p_stModif->szName ); p_szMessage += sprintf( p_szMessage, "was created in your local directory but already exist in vss data\n"); p_szMessage += sprintf( p_szMessage, "-------------------------------------\n" ); p_szMessage += sprintf( p_szMessage, "Do you want I delete this file modification and \n"); p_szMessage += sprintf( p_szMessage, "take care of file section modification ?"); oQuestion.fn_vSetMessage( szMessage ); oQuestion.DoModal(); cChoice = oQuestion.fn_cGetChoice(); switch( cChoice ) { case C_CHOICE_cYesAll: g_cDeleteSectionModif = cChoice; cChoice = C_CHOICE_cYes; break; case C_CHOICE_cNoAll: g_cDeleteSectionModif = cChoice; cChoice = C_CHOICE_cNo; break; } } else { cChoice = (g_cDeleteSectionModif == C_CHOICE_cYesAll) ? C_CHOICE_cYes : C_CHOICE_cNo; } if (cChoice == C_CHOICE_cNo) { Error_fn_vSet( Error_eVssSectionAlreadyCreated, "Created local file already exist in vss database\n" ); return -1; } else { fn_vRestoreSubModif( _p_stModif ); return 0; } } /* --------------------------------------------------------------------------------------- update all modifications --------------------------------------------------------------------------------------- */ BOOL CMngDataDlg::m_fn_bUpdate( void ) { /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ char szFileName[MAX_PATH]; char szShortFileName[MAX_PATH]; tdstModif *p_stCurModif = g_p_stFirstModif; BOOL bModifEntireFile; BOOL bErrorOnCurrent; long lNumberOfErrors = 0; long lStart; char cResult; /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ while (1) { /* * get next not marqued modification */ if (( p_stCurModif = fn_p_stGetFirstNotMarkedModif() ) == NULL) break; /* * mark current modif */ p_stCurModif->bConflict = TRUE; bErrorOnCurrent = TRUE; /* * get filename and short filename from modified section name */ bModifEntireFile = fn_bGetModifiedFile( p_stCurModif, szFileName, szShortFileName ); /* * check validity of filename */ if (*szShortFileName == 0) { Error_fn_vSetFmt( Error_eInvalidFileName, "%s -> Error : Invalid File Name\r\n", szFileName ); cResult = -1; } else { /* * build vss filename, extracting temp file, and local file */ sprintf(g_szVssFileName , "%s\\%s", g_stIniData.szVssPath, szFileName ); sprintf(g_stTarget.szFullName, "%s\\%s", g_stIniData.szTempPath, szShortFileName ); sprintf(g_stSource.szFullName, "%s\\%s", g_stIniData.szLocalPath, szFileName ); m_bLocalExist = (_access( g_stSource.szFullName, 0 ) == 0); m_cVssStatus = OLE_fn_cGetVssFileStatus(g_szVssFileName); if ( (m_cVssStatus == VSSFILE_CHECKEDOUT_ME) || (m_cVssStatus == VSSFILE_CHECKEDOUT) ) { lNumberOfErrors ++; Error_fn_vSetFmt( Error_eFileAlreadyCheckOut, "%s -> Error vss file is already checked out by %s; see admin\r\n", g_szVssFileName, g_a_szUserName[0] ); m_oProgress.OffsetPos(fn_iMarkAllModifForAFile( szFileName )); m_fn_Result_vAddLine( Error_fn_p_szGetMessage(), C_Result_cErrorLine ); p_stCurModif = NULL; } else { if (bModifEntireFile) { switch (p_stCurModif->cType) { case C_ModifType_cDelete: cResult = m_fn_cDoModifFileDelete( p_stCurModif ); break; case C_ModifType_cRebuild: case C_ModifType_cModif: cResult = m_fn_cDoModifFileModif( p_stCurModif, TRUE ); break; case C_ModifType_cAdd: cResult = m_fn_cDoModifFileAdd( p_stCurModif ); break; } } else { cResult = m_fn_cDoModifFileModif( p_stCurModif, FALSE ); if (cResult == 0) { if ( !OLE_fn_bCheckoutFile( g_szVssFileName, g_stTarget.szFullName, VSSFLAG_REPREPLACE )) { cResult = -1; sprintf( m_szMessage, "%s -> Error ( %s )\r\n", p_stCurModif->szName, Error_fn_p_szGetMessage() ); Error_fn_vSet( Error_fn_eGet(), m_szMessage ); } else { SCR_fn_v_RdL0_OpenFile( g_stTarget.szFullName ); g_stTarget.p_stFile = SCR_fnp_st_RdL0_GetOpenFile( g_stTarget.szFullName ); SCR_fn_v_RdL0_OpenFile( g_stSource.szFullName ); g_stSource.p_stFile = SCR_fnp_st_RdL0_GetOpenFile( g_stSource.szFullName ); do { m_fn_vPause(); p_stCurModif->bConflict = TRUE; sprintf (m_szMessage, "%s -> ", p_stCurModif->szName); lStart = m_oRichEdit.GetTextLength( ); m_fn_Result_vAddLine( m_szMessage, C_Result_cInfoLine ); m_oRichEdit.SetSel( lStart, -1 ); m_oProgress.StepIt(); /* doing current modif */ if (fn_bDoModif( p_stCurModif )) { sprintf( m_szMessage, "%s -> OK\r\n", p_stCurModif->szName ); m_oProgress.OffsetPos( fn_lDeleteModif( p_stCurModif, TRUE ) - 1 ); m_fn_Result_vAddLine( m_szMessage, C_Result_cOkLine ); } else { strcpy( m_szMessage, Error_fn_p_szGetMessage() ); Error_fn_vSetFmt( Error_eCantUpdateModification, "%s -> Error ( %s )\r\n", p_stCurModif->szName, m_szMessage ); lNumberOfErrors ++; m_fn_Result_vAddLine( Error_fn_p_szGetMessage(), C_Result_cErrorLine ); m_oProgress.OffsetPos( fn_lNumberOfChildModif( p_stCurModif ) ); } /* search for modif in same file */ p_stCurModif = fnp_stGetModifInFile( szFileName, FALSE, FALSE ); } while (p_stCurModif != NULL ); /* deleting opened script file */ SCR_fn_v_RdL0_DelOpenFile( g_stTarget.szFullName, SCR_CDR_c_RdL0_Match); SCR_fn_v_RdL0_DelOpenFile( g_stSource.szFullName, SCR_CDR_c_RdL0_Match); SCR_fn_v_SvL1_UpdateAllNotify(); /* archiving file */ m_fn_vPause(); OLE_fn_bCheckinFile( g_szVssFileName, g_stTarget.szFullName, VSSFLAG_DELYES ); } } } } } if (p_stCurModif != NULL) { if (cResult == -1) { lNumberOfErrors ++; m_oProgress.OffsetPos( fn_lNumberOfChildModif( p_stCurModif ) + 1); m_fn_Result_vAddLine( Error_fn_p_szGetMessage(), C_Result_cErrorLine ); } else { if (cResult == 0) { sprintf (m_szMessage, "%s -> OK\r\n", p_stCurModif->szName); m_oProgress.OffsetPos( fn_lDeleteModif( p_stCurModif, TRUE )); } else /* cResult = 1*/ { sprintf( m_szMessage, "%s -> OK\r\n", szFileName ); m_oProgress.OffsetPos( fn_iDeleteAllModifForAFile( szFileName ) ); } m_fn_Result_vAddLine( m_szMessage, C_Result_cOkLine ); } } } if (lNumberOfErrors != 0) { sprintf( m_szMessage, "######## %d Error%s detected ########\r\n", lNumberOfErrors, (lNumberOfErrors == 1)?"":"s" ); m_fn_Result_vAddLine( m_szMessage, C_Result_cErrorLine ); } return TRUE; } /* --------------------------------------------------------------------------------------- main function for updating operation --------------------------------------------------------------------------------------- */ BOOL CMngDataDlg::m_fn_bOnCommandUpdate( ) { /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ BOOL bResult = FALSE; /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ /* * init display */ m_fn_vKillTimerForBaseStatus(); m_fn_vInitProgessBar( 0, g_lNumberOfModifs + 5 ); m_fn_Result_vResetContent(); m_fn_vEnableButton(FALSE); GetDlgItem( IDC_BUTTON_STOP )->EnableWindow( FALSE ); g_cDeleteSectionModif = 0; g_cAddModifiedFile = 0; m_bWorkInProgress = TRUE; m_bRequestToStop = FALSE; /* * look if someone is obtaining data */ M_DisplayInfoLine( "-> Look if someone's obtaining data\r\n" ); if (fn_bSomeoneObtain( TRUE )) { if (g_cNbUsers) Error_fn_vSetFmt( Error_eSomeoneObtain, "Can't update cause %s is obtaining\r\n", g_a_szUserName[0] ); else Error_fn_vSet( Error_eCantAccessServer, "Can't access Server\r\n" ); } else { /* * look if someone is updating data */ M_DisplayInfoLine( "-> Look if someone's updating data\r\n" ); if (fn_bSomeoneUpdate(TRUE, TRUE)) { if (g_cNbUsers) Error_fn_vSetFmt( Error_eSomeoneUpdate, "Can't update cause %s is obtaining\r\n", g_a_szUserName[0] ); else Error_fn_vSet( Error_eCantAccessServer, "Can't access Server\r\n" ); } else { /* * synchronisation with time server */ M_DisplayInfoLine( "-> Synchronizing time with server\r\n" ); if (!fn_bSynchronizeTime( TRUE )) Error_fn_vSet( Error_eCantAccessTimeServer, "Time server doesn't respond !" ); else { fn_vInitUpdateTime(); sprintf( m_szMessage, "%s\r\n", g_szUpdateTimeString ); m_fn_Result_vAddLine( m_szMessage, C_Result_cOkLine ); m_fn_vPause(); M_DisplayInfoLine( "-> Beginning updating\r\n" ); if (!fn_bBeginUpdating() ) Error_fn_vSet( Error_eCantAccessServer, "Can't access Server\r\n" ); else { m_fn_bUpdate(); M_DisplayInfoLine( "-> Update's done\r\n"); fn_bEndUpdating(); fn_vUpdateModifFile(); OnButtonRefresh(); bResult = TRUE; } } } } /* * Display error if something happends */ if (!bResult) m_fn_Result_vAddLine( Error_fn_p_szGetMessage() , C_Result_cErrorLine ); /* * LOG FILE */ m_fn_vWriteResultToLogFile( "Updating result" ); m_oProgress.SetPos( m_oProgress.m_iEnd ); m_bWorkInProgress = FALSE; m_fn_vEnableButton(TRUE); OnButtonRefresh(); m_fn_vSetTimerForBaseStatus(); return bResult; } /* ======================================================================================= Function for updating a list file of file / project this functiosn replace vss file with local file without verification ======================================================================================= */ /* --------------------------------------------------------------------------------------- update all file that are in config --------------------------------------------------------------------------------------- */ BOOL CMngDataDlg::m_fn_bUpdateWithConfig( long _lNumberOfFiles, char **d_szFile ) { /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ char cResult; long lNumberOfErrors = 0; long lStart; long lFile; /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ for (lFile = 0; lFile < _lNumberOfFiles; lFile++) { /* * get filename and short filename from modified section name */ sprintf (m_szMessage, "%s -> ", d_szFile[ lFile ] + 3); lStart = m_oRichEdit.GetTextLength( ); m_fn_Result_vAddLine( m_szMessage, C_Result_cInfoLine ); //m_oRichEdit.SetSel( lStart, -1 ); m_oProgress.StepIt(); cResult = fn_cUpdateFile( d_szFile[ lFile ] + 3); switch (cResult) { case C_Vss_cUpdateError: strcpy( m_szMessage, Error_fn_p_szGetMessage() ); Error_fn_vSetFmt( Error_eCantUpdateModification, "Error ( %s )\n", m_szMessage ); lNumberOfErrors ++; m_fn_Result_vAddLine( Error_fn_p_szGetMessage(), C_Result_cErrorLine ); break; case C_Vss_cUpdateNothing: m_oRichEdit.SetSel( lStart, -1); m_fn_Result_vAddLine( "", C_Result_cInfoLine ); break; case C_Vss_cUpdateAdd: m_fn_Result_vAddLine( "Added\n", C_Result_cOkLine ); break; case C_Vss_cUpdateModify: m_fn_Result_vAddLine( "Updated\n", C_Result_cOkLine ); break; } } if (lNumberOfErrors != 0) { sprintf( m_szMessage, "######## %d Error%s detected ########\r\n", lNumberOfErrors, (lNumberOfErrors == 1)?"":"s" ); m_fn_Result_vAddLine( m_szMessage, C_Result_cErrorLine ); } return TRUE; } /* --------------------------------------------------------------------------------------- main function for updating operation --------------------------------------------------------------------------------------- */ BOOL CMngDataDlg::m_fn_bOnCommandUpdateWithConfig( ) { /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ BOOL bResult = FALSE; tdstFileListConfig *p_stConfig = &g_stIniData.stUpdateConfig; long lNbFiles; char **d_szFile; /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ /* * get all files that are to update */ if (g_p_stLocalRootProject == NULL) { fn_Tree_bBuildFromDisk( &g_p_stLocalRootProject, g_stIniData.szLocalPath ); fn_Tree_vRefreshWithFileList( g_p_stLocalRootProject, &g_stIniData.stUpdateConfig ); } lNbFiles = fn_TREE_lBuildListOfFilesToGet( g_p_stLocalRootProject, &d_szFile ); if ( lNbFiles == 0) return TRUE; /* * init display */ m_fn_vKillTimerForBaseStatus(); m_fn_vInitProgessBar( 0, lNbFiles + 4 ); m_fn_Result_vResetContent(); m_fn_vEnableButton(FALSE); GetDlgItem( IDC_BUTTON_STOP )->EnableWindow( TRUE ); m_bWorkInProgress = TRUE; m_bRequestToStop = FALSE; /* * look if someone is obtaining data */ M_DisplayInfoLine( "-> Look if someone's obtaining data\r\n" ); if (fn_bSomeoneObtain( TRUE )) { if (g_cNbUsers) Error_fn_vSetFmt( Error_eSomeoneObtain, "Can't update cause %s is obtaining\r\n", g_a_szUserName[0] ); else Error_fn_vSet( Error_eCantAccessServer, "Can't access Server\r\n" ); } else { /* * look if someone is updating data */ M_DisplayInfoLine( "-> Look if someone's updating data\r\n" ); if (fn_bSomeoneUpdate(TRUE, TRUE)) { if (g_cNbUsers) Error_fn_vSetFmt( Error_eSomeoneUpdate, "Can't update cause %s is obtaining\r\n", g_a_szUserName[0] ); else Error_fn_vSet( Error_eCantAccessServer, "Can't access Server\r\n" ); } else { M_DisplayInfoLine( "-> Beginning updating\r\n" ); if (!fn_bBeginUpdating() ) Error_fn_vSet( Error_eCantAccessServer, "Can't access Server\r\n" ); else { m_fn_bUpdateWithConfig( lNbFiles, d_szFile ); M_DisplayInfoLine( "-> Update's done\r\n"); fn_bEndUpdating(); bResult = TRUE; } } } /* * Display error if something happends */ if (!bResult) m_fn_Result_vAddLine( Error_fn_p_szGetMessage() , C_Result_cErrorLine ); /* * free list of files */ fn_TREE_vFreeListOfFilesToGet( lNbFiles, d_szFile ); /* * LOG FILE */ m_fn_vWriteResultToLogFile( "Updating with config result" ); m_oProgress.SetPos( m_oProgress.m_iEnd ); m_bWorkInProgress = FALSE; m_fn_vEnableButton(TRUE); //OnButtonRefresh(); m_fn_vSetTimerForBaseStatus(); return bResult; } /* ======================================================================================= Function for obtaining ======================================================================================= */ /* --------------------------------------------------------------------------------------- Obtain command : main function for obtaining operation --------------------------------------------------------------------------------------- */ void CMngDataDlg::m_fn_vOnCommandObtain() { /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ BOOL bDeleteModifFile = TRUE; BOOL bContinue = TRUE; BOOL bObtain; long lTextStart, lTextEnd; MSG stMessage; int iResult; long lNbFiles, lFile; char **d_szFile = NULL; char szTemp[256]; char *p_szTemp; /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ /* * build file list that are to be obtained */ lFile = 0; fn_Tree_vGetNumberOfFilesToGet( g_p_stVssRootProject, &lFile, FALSE ); if ( lFile == 0) return; /* init display */ m_fn_vKillTimerForBaseStatus(); //m_fn_vInitProgessBar( 0, 7 + g_stIniData.lNumberOfFilesToObtain ); m_fn_vInitProgessBar( 0, 7 + lFile ); m_fn_Result_vResetContent(); m_fn_vEnableButton(FALSE); m_bWorkInProgress = TRUE; m_bRequestToStop = FALSE; /* * stop immediatly if there's still modifications and if it's a batch obtain */ if ( (g_lNumberOfFatherModifs != 0) && !m_bBatchObtain ) { sprintf( m_szMessage, "there is still %d modif in file\r\nDelete all modif ?", g_lNumberOfFatherModifs ); iResult = MessageBox( m_szMessage, "Warning", MB_ICONQUESTION | MB_YESNOCANCEL ); bContinue = iResult != IDCANCEL; bDeleteModifFile = (iResult == IDYES); } if (bContinue && !m_bRequestToStop ) { M_DisplayInfoLine( "-> Look if someone's updating data\n" ); if (fn_bSomeoneUpdate(FALSE, !m_bBatchObtain)) { if (g_cNbUsers) { sprintf( m_szMessage, "Can't obtain cause %s is updating\n", g_a_szUserName[0] ); m_fn_Result_vAddLine( m_szMessage, C_Result_cErrorLine ); } else m_fn_Result_vAddLine( "Can't access server", C_Result_cErrorLine ); } else if (!m_bRequestToStop) { if ( bDeleteModifFile && (g_lNumberOfFatherModifs != 0) ) { m_fn_Result_vAddLine( "-> Deleting modification file\n", C_Result_cInfoLine ); fn_bDeleteModifFile(); OnButtonRefresh(); if (g_lNumberOfFatherModifs != 0) { m_fn_Result_vAddLine( "Can't delete modification file\n", C_Result_cErrorLine ); bContinue = FALSE; } } m_oProgress.StepIt(); if (bContinue && !m_bRequestToStop) { m_fn_Result_vAddLine( "-> Synchronizing time with server\n", C_Result_cInfoLine ); m_oProgress.StepIt(); if (!fn_bSynchronizeTime( !m_bBatchObtain )) { m_fn_Result_vAddLine( "Error with time server\n", C_Result_cErrorLine ); } else if (!m_bRequestToStop) { fn_vFormatDateTime( 0, szTemp ); strcat( szTemp, "\r\n"); m_fn_Result_vAddLine( szTemp, C_Result_cOkLine ); m_fn_Result_vAddLine( "-> Beginning obtaining\n", C_Result_cInfoLine ); m_oProgress.StepIt(); if (!fn_bBeginObtaining() ) { m_fn_Result_vAddLine( "Can't access server", C_Result_cErrorLine ); } else if (!m_bRequestToStop) { /* * refresh file list that are to obtain */ M_DisplayInfoLine( "-> Refresh vss data tree\n" ); fn_vRefreshVssTreeAndFilesToObtainList(); lNbFiles = fn_TREE_lBuildListOfFilesToGet( g_p_stVssRootProject, &d_szFile ); if (lNbFiles != lFile) { m_fn_Result_vAddLine(" Number of file to obtain has changed : resizing progress bar\n", C_Result_cInfoLine ); m_oProgress.m_fn_vSetRange( 0, 7 + lNbFiles ); } sprintf( m_szMessage, " obtaining %d files\n", lNbFiles ); m_fn_Result_vAddLine(m_szMessage, C_Result_cInfoLine ); /* * Save obtaining info and init result display */ fn_IniD_vSaveObtainingInfo( ); m_oRichEdit.GetSel( lTextStart, lTextEnd ); p_szTemp = szTemp + sprintf( szTemp, " Obtaining " ); for (lFile = 0; lFile < lNbFiles; lFile ++) { //strcpy( p_szTemp, g_stIniData.d_szFileToObtain[iFile] ); strcpy( p_szTemp, d_szFile[lFile] ); m_oRichEdit.SetSel( lTextStart, -1 ); m_fn_Result_vAddLine( szTemp, C_Result_cInfoLine ); //if (!fn_bObtainFile( g_stIniData.d_szFileToObtain[iFile], &bObtain )) if (!fn_bObtainFile( d_szFile[lFile], &bObtain )) { m_fn_Result_vAddLine( "\nObtaining aborted\n", C_Result_cInfoLine ); m_fn_Result_vAddLine( Error_fn_p_szGetMessage(), C_Result_cErrorLine ); break; } if (bObtain) { m_fn_Result_vAddLine( "\n", C_Result_cInfoLine ); m_oRichEdit.GetSel( lTextStart, lTextEnd ); } m_oProgress.StepIt(); if ( PeekMessage( &stMessage, NULL, 0, 0, PM_REMOVE ) ) DispatchMessage( &stMessage ); if (m_bRequestToStop) { if (AfxMessageBox( "Stopping obtaining operation could invalidate data\non your local disk\n---------------------\nDo you want to abort anyway ?", MB_YESNO | MB_ICONSTOP ) == IDYES) { m_fn_Result_vAddLine( "\nObtaining aborted by user\n", C_Result_cErrorLine ); break; } else m_bRequestToStop = FALSE; } } //if (lFile == g_stIniData.lNumberOfFilesToObtain) if (lFile == lNbFiles) { if (!bObtain) { m_oRichEdit.SetSel( lTextStart, -1); m_fn_Result_vAddLine( "", C_Result_cInfoLine ); } m_fn_Result_vAddLine( "-> Obtain's done\n", C_Result_cInfoLine ); m_oProgress.StepIt(); m_fn_Result_vAddLine("-> Deleting old security saved directory\n" , C_Result_cInfoLine ); SAVE_fn_bDeleteAllVersions(); m_oProgress.StepIt(); } if (!fn_bEndObtaining()) m_fn_Result_vAddLine( "Can't access server\nContact administrator", C_Result_cErrorLine ); /* * free list of file to obtain */ fn_TREE_vFreeListOfFilesToGet( lNbFiles, d_szFile ); } } } } } m_oProgress.SetPos( m_oProgress.m_iEnd ); m_bWorkInProgress = FALSE; m_fn_vEnableButton(TRUE); OnButtonRefresh(); m_fn_vSetTimerForBaseStatus(); /* * LOG FILE */ m_fn_vWriteResultToLogFile( "obtaining" ); } /* ======================================================================================= Functions for base status ======================================================================================= */ /* ---------------------------------------------------------------------------------------- Description : display base status ---------------------------------------------------------------------------------------- */ void CMngDataDlg::m_fn_vDisplayBaseStatus( void ) { fn_bGetUpdateStatus( m_szMessage ); GetDlgItem( IDC_EDIT_INUPDATE )->SetWindowText( m_szMessage ); fn_bGetObtainStatus( m_szMessage ); GetDlgItem( IDC_EDIT_INOBTAIN )->SetWindowText( m_szMessage ); } /* ---------------------------------------------------------------------------------------- Description : create timer to display base status sometimes ---------------------------------------------------------------------------------------- */ void CMngDataDlg::m_fn_vSetTimerForBaseStatus( void ) { if (!m_bBaseStatusTimerOn) { m_uiBaseStatusTimer = SetTimer( C_uiBaseStatusTimer, 10000, NULL ); m_bBaseStatusTimerOn = TRUE; } } /* ---------------------------------------------------------------------------------------- Description : kill timer created to display base status ---------------------------------------------------------------------------------------- */ void CMngDataDlg::m_fn_vKillTimerForBaseStatus( void ) { if (m_bBaseStatusTimerOn) { KillTimer( m_uiBaseStatusTimer ); m_bBaseStatusTimerOn = FALSE; } } /* ======================================================================================= Message handlers ======================================================================================= */ /* --------------------------------------------------------------------------------------- call back for wait dialog --------------------------------------------------------------------------------------- */ BOOL CALLBACK fn_bWaitDialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) { /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ static UINT uiTimer; static char cInit; BOOL bResult; /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ switch (uMsg) { case WM_INITDIALOG: SetWindowText(hwndDlg, "Loading Vss Tree" ); cInit = 1; return TRUE; case WM_SHOWWINDOW: if (cInit) { cInit = 0; uiTimer = SetTimer( hwndDlg, 1, 100, NULL ); } break; case WM_TIMER: KillTimer( hwndDlg, uiTimer ); bResult = OLE_fn_bGetVssProjectTree( FALSE, GetDlgItem( hwndDlg, IDC_STATIC_PROJECT ) ); //bResult = OLE_fn_bGetVssProjectTree( TRUE, GetDlgItem( hwndDlg, IDC_STATIC_PROJECT ) ); EndDialog( hwndDlg, bResult?1:0 ); break; } return FALSE; } /* --------------------------------------------------------------------------------------- WM_INITDIALOG --------------------------------------------------------------------------------------- */ BOOL CMngDataDlg::OnInitDialog() { /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ RECT stRect; RECT stDlgRect; long lDlgWidth; long lDlgHeight; /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ CDialog::OnInitDialog(); /* * append about entry in system menu */ CMenu* pSysMenu = GetSystemMenu(FALSE); pSysMenu->AppendMenu(MF_SEPARATOR); pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, "About ..."); /* * Set icons */ SetIcon(m_hIcon, TRUE); SetIcon(m_hIcon, FALSE); /* * Get ini Data */ fn_IniD_vGetAllFromIniFile( TRUE ); /* * Init script module */ Mmg_fn_vFirstInitMmgModule(1); SCR_fn_v_RdL0_Init(); /* * OLE initialisation : opening the database */ if (!OLE_fn_bVssLogin( NULL ) ) { m_fn_vFatalError("Can't log to vss database" ); return FALSE; } /* * getting tree project */ int iResult = DialogBox( AfxGetInstanceHandle(), MAKEINTRESOURCE( IDD_DIALOG_WAIT ), ::GetDesktopWindow(), fn_bWaitDialogProc ); if ( iResult != 1) { m_fn_vFatalError("Can't access vss database" ); return FALSE; } /* * set getting state of vss tree and build list of all files that are to obtain */ fn_Tree_vRefreshWithFileList( g_p_stVssRootProject, &g_stIniData.stObtainConfig ); //fn_vUpdateFilesToObtainList(); /* * read modification list */ fn_iReadModificationFile(); /* * display data in window */ m_fn_vDisplayProgramData(); /* * init progression bar */ m_oProgress.SubclassDlgItem( IDC_PROGRESS, this ); m_oProgress.SetStep( 1 ); /* * init LOG FILE */ LOG_fn_vInitLogFile(); /* * get current posistion of all control in window for resizing operation */ GetClientRect( &stDlgRect ); lDlgWidth = stDlgRect.right - stDlgRect.left + 1; lDlgHeight = stDlgRect.bottom - stDlgRect.top + 1; for (int iEdit = 0; iEdit < m_cNbEditBox; iEdit ++) { GetDlgItem(m_a_uiEditControl[iEdit])->GetWindowRect( &stRect ); m_a_iSizeLeft[iEdit] = lDlgWidth - (stRect.right - stRect.left + 1); } GetDlgItem( IDC_STATIC_FORRICHEDIT)->GetWindowRect( &stRect ); m_iHeightLeft = lDlgHeight - (stRect.bottom - stRect.top + 1); /* * Create RichEditControl */ m_oRichEdit.Create ( WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | ES_MULTILINE | ES_AUTOVSCROLL | ES_WANTRETURN | ES_AUTOHSCROLL | ES_READONLY, stRect, this, IDC_RICHEDIT_RESULT ); m_oRichEdit.SetBackgroundColor( FALSE, 0 ); m_oRichEdit.GetDefaultCharFormat( m_stCharFormat ); m_stCharFormat.dwEffects = 0; m_stCharFormat.crTextColor = RGB(255,255,255); strcpy ( m_stCharFormat.szFaceName, "Arial" ); m_stCharFormat.dwMask = CFM_COLOR | CFM_BOLD | CFM_FACE; m_oRichEdit.SetDefaultCharFormat( m_stCharFormat ); /* * Set timer for base status on */ m_fn_vSetTimerForBaseStatus(); /* * change size of window according to preference */ MoveWindow( &g_stWinPref.stMainPos ); m_bInitOK = TRUE; return TRUE; // return TRUE unless you set the focus to a control } /* --------------------------------------------------------------------------------------- WM_SYSCOMMAND --------------------------------------------------------------------------------------- */ void CMngDataDlg::OnSysCommand(UINT nID, LPARAM lParam) { if ((nID & 0xFFF0) == IDM_ABOUTBOX) { CAboutDlg dlgAbout; dlgAbout.DoModal(); } else { if (nID == SC_CLOSE) { if (m_bWorkInProgress) return; if (AfxMessageBox( "Are you sure you want to Quit ?", MB_YESNO | MB_ICONQUESTION) == IDNO) return; m_bQuitFromSysCommand = TRUE; } CDialog::OnSysCommand(nID, lParam); } } /* --------------------------------------------------------------------------------------- WM_DESTROY --------------------------------------------------------------------------------------- */ void CMngDataDlg::OnDestroy() { WinHelp(0L, HELP_QUIT); fn_vDeleteAllModifs(); fn_Tree_vFreeProjectTree(g_p_stVssRootProject, TRUE ); fn_Tree_vFreeProjectTree(g_p_stLocalRootProject, TRUE ); fn_IniD_vFreeFileList( &g_stIniData.stObtainConfig ); fn_IniD_vFreeFileList( &g_stIniData.stUpdateConfig ); //fn_IniD_vFreeObtainedFileList(); //fn_IniD_vFreeFileListToObtain(); m_fn_vKillTimerForBaseStatus(); /* * save new position and size */ if (m_bInitOK) { GetWindowRect( &g_stWinPref.stMainPos ); fn_IniD_vWriteWindowPreference(); } SCR_fn_v_RdL0_Close(); Mmg_fn_vStopMmgModule(); CDialog::OnDestroy(); } /* --------------------------------------------------------------------------------------- WM_PAINT --------------------------------------------------------------------------------------- */ void CMngDataDlg::OnPaint() { CPaintDC dc(this); // device context for painting if (IsIconic()) { SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); // Center icon in client rectangle int cxIcon = GetSystemMetrics(SM_CXICON); int cyIcon = GetSystemMetrics(SM_CYICON); CRect rect; GetClientRect(&rect); int x = (rect.Width() - cxIcon + 1) / 2; int y = (rect.Height() - cyIcon + 1) / 2; // Draw the icon dc.DrawIcon(x, y, m_hIcon); } else { CDialog::OnPaint(); CBitmap oBitmap; oBitmap.LoadBitmap( IDB_BITMAP_LENNON ); dc.DrawState( CPoint( 5, 5), CSize(50,100), &oBitmap, DST_BITMAP ); oBitmap.DeleteObject(); } } /* --------------------------------------------------------------------------------------- WM_QUERYDRAGICON --------------------------------------------------------------------------------------- */ HCURSOR CMngDataDlg::OnQueryDragIcon() { return (HCURSOR) m_hIcon; } /* --------------------------------------------------------------------------------------- WM_TIMER --------------------------------------------------------------------------------------- */ void CMngDataDlg::OnTimer(UINT nIDEvent) { if ( nIDEvent == C_uiBaseStatusTimer ) { m_fn_vDisplayBaseStatus(); } CDialog::OnTimer(nIDEvent); } /* --------------------------------------------------------------------------------------- BN_CLIKED on IDC_Check_OBTAINMENU --------------------------------------------------------------------------------------- */ void CMngDataDlg::OnCheckObtainMenu() { /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ CButton *p_oCheck = ((CButton *) GetDlgItem (IDC_CHECK_OBTAINMENU)); RECT stRect; /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ if ( p_oCheck->GetCheck() == 1 ) { CMenu oMenu; oMenu.CreatePopupMenu(); oMenu.AppendMenu( MF_STRING | MF_ENABLED, IDM_OBTAINNOW, "Obtain now"); oMenu.AppendMenu( MF_STRING | MF_ENABLED, IDM_OBTAIN, "Batch obtain"); //oMenu.AppendMenu( MF_STRING | MF_ENABLED, IDM_OBTAINOPTIONS, "Options..."); p_oCheck->GetWindowRect(&stRect); oMenu.TrackPopupMenu( TPM_LEFTBUTTON, stRect.left, stRect.bottom, this ); oMenu.DestroyMenu(); p_oCheck->SetCheck( 0 ); } } /* --------------------------------------------------------------------------------------- BN_CLIKED on IDC_BUTTON_VIEWMODIF --------------------------------------------------------------------------------------- */ void CMngDataDlg::OnButtonViewmodif() { CModifListDialog oDlgModif; oDlgModif.DoModal(); } /* --------------------------------------------------------------------------------------- BN_CLIKED on IDC_BUTTON_CLEARMODIF --------------------------------------------------------------------------------------- */ void CMngDataDlg::OnButtonClearmodif() { if (AfxMessageBox( "Are you sure you want to\nDelete modification list ?", MB_YESNO | MB_ICONQUESTION) == IDYES) { if ( !fn_bDeleteModifFile()) { AfxMessageBox( "Error : Can't delete modification file", MB_ICONSTOP | MB_OK ); } OnButtonRefresh(); } } /* --------------------------------------------------------------------------------------- BN_CLIKED on IDC_BUTTON_CHANGEMODIF --------------------------------------------------------------------------------------- */ void CMngDataDlg::OnButtonChangemodif() { static char BASED_CODE szFilter[] = "Modif list file(*.txt)|*.txt||"; char szFileName[ _MAX_PATH ]; char *p_szShortName; DWORD dwFlags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_NOCHANGEDIR; char szDir[ _MAX_PATH ]; CFileDialog oFD( TRUE, "txt", g_stIniData.szModifFile, dwFlags, szFilter, this); GetCurrentDirectory( _MAX_PATH, szDir ); if (SetCurrentDirectory( g_stIniData.szLocalPath )) { if (oFD.DoModal() == IDOK) { strcpy ( szFileName, (char *) (LPCTSTR) oFD.GetPathName() ); if (strnicmp( szFileName, g_stIniData.szLocalPath, strlen( g_stIniData.szLocalPath )) == 0) { p_szShortName = szFileName + strlen( g_stIniData.szLocalPath ); if (*p_szShortName == '\\' ) p_szShortName++; fn_IniD_vSetModifListFile( p_szShortName ); OnButtonRefresh(); } else { sprintf( m_szMessage,"Error : Modif list file must be in local path\n(%s)", g_stIniData.szLocalPath ); AfxMessageBox( m_szMessage, MB_OK | MB_ICONSTOP ); } } SetCurrentDirectory( szDir ); } else { sprintf( m_szMessage,"Error : Can't find local path (%s)", g_stIniData.szLocalPath ); AfxMessageBox( m_szMessage, MB_OK | MB_ICONSTOP ); } } /* --------------------------------------------------------------------------------------- BN_CLICKED on IDC_BUTTON_BROWSE --------------------------------------------------------------------------------------- */ void CMngDataDlg::OnButtonBrowse() { /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ BROWSEINFO stBI; ITEMIDLIST *p_stItem; char szDisplayName[ MAX_PATH ]; char szPath[ MAX_PATH ]; /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ stBI.hwndOwner = this->GetSafeHwnd(); stBI.pidlRoot = NULL; stBI.pszDisplayName = szDisplayName; stBI.lpszTitle = "Choose Target Path"; stBI.ulFlags = 0; stBI.lpfn = NULL; if ((p_stItem = SHBrowseForFolder( &stBI )) != NULL) { SHGetPathFromIDList( p_stItem, szPath ); fn_IniD_vSetLocalPath( szPath ); OnButtonRefresh(); } } /* --------------------------------------------------------------------------------------- BN_CLICKED on IDC_BUTTON_REFRESH --------------------------------------------------------------------------------------- */ void CMngDataDlg::OnButtonRefresh() { fn_IniD_vGetAllFromIniFile( FALSE ); fn_iReadModificationFile(); m_fn_vDisplayProgramData(); } /* --------------------------------------------------------------------------------------- BN_CLICKED on IDC_BUTTON_LOOKOBTAIN --------------------------------------------------------------------------------------- */ void CMngDataDlg::OnButtonLookobtain() { if (!fn_bSomeoneObtain( TRUE )) MessageBox( "Nobody is obtaining", "Info", MB_ICONASTERISK ); else { char szMessage[1024]; char cUser; char *p_szCur = szMessage; for (cUser = 0; cUser < g_cNbUsers; cUser ++) p_szCur += sprintf (p_szCur, "%s\r\n", g_a_szUserName[cUser] ); sprintf( p_szCur, "%s obtaining data base", (g_cNbUsers == 1)?"is":"are" ); MessageBox( szMessage, "Info", MB_ICONASTERISK); } } /* --------------------------------------------------------------------------------------- BN_CLICKED on IDC_BUTTON_LOOKUPDATE --------------------------------------------------------------------------------------- */ void CMngDataDlg::OnButtonLookupdate() { /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ char szMessage[1024]; /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ if (!fn_bSomeoneUpdate(FALSE, TRUE)) strcpy (szMessage, "Nobody is updating" ); else sprintf( szMessage, "%s is updating data base", g_a_szUserName[0] ); MessageBox( szMessage, "Info", MB_ICONASTERISK ); } /* --------------------------------------------------------------------------------------- Pre translate message --------------------------------------------------------------------------------------- */ BOOL CMngDataDlg::PreTranslateMessage(MSG* pMsg) { if (pMsg->message == WM_KEYDOWN) { memmove( m_szCheat, m_szCheat + 1, 5 ); m_szCheat[5] = (TCHAR) pMsg->wParam; /* * look if cheat string has one cheat code * Available cheat code are actually * pause * update * obtain * modlst * reset */ if (m_bWorkInProgress) { if (strnicmp( m_szCheat + 1, "reset", 5) == 0) { m_bWorkInProgress = FALSE; m_fn_vEnableButton(TRUE); OnButtonRefresh(); } } else { if (strnicmp(m_szCheat + 1, "pause", 5) == 0) { if (m_lCheatFlag & C_lCheatPause) { m_lCheatFlag &= !C_lCheatPause; MessageBox( "Pause unset", "Info", MB_ICONASTERISK ); } else { m_lCheatFlag |= C_lCheatPause; MessageBox( "Pause set", "Info", MB_ICONASTERISK ); } } else if (strnicmp( m_szCheat, "update", 6) == 0) { if ( m_lCheatFlag & C_lCheatUpdate) { m_lCheatFlag &= !C_lCheatUpdate; fn_bEndUpdating(); MessageBox( "Update unset", "Info", MB_ICONASTERISK ); } else { if (fn_bSomeoneUpdate(FALSE, TRUE)) { if (g_cNbUsers) { sprintf( m_szMessage, "Can't update cause %s is updating\r\n", g_a_szUserName[0] ); m_fn_Result_vAddLine( m_szMessage, C_Result_cErrorLine ); } else m_fn_Result_vAddLine( "Can't access server", C_Result_cErrorLine ); } else { fn_bBeginUpdating(); m_lCheatFlag |= C_lCheatUpdate; MessageBox( "Update set", "Info", MB_ICONASTERISK ); } } } else if (strnicmp( m_szCheat, "modlst", 6) == 0) { char szTxtFileName[ _MAX_PATH ]; char szBakFileName[ _MAX_PATH ]; BOOL bContinue; sprintf( szTxtFileName, "%s\\%s", g_stIniData.szLocalPath, g_stIniData.szModifFile ); strcpy(szBakFileName, szTxtFileName ); strcpy( strrchr( szBakFileName, '.'), ".bak" ); if ( _access( szBakFileName, 0) != 0) { sprintf( m_szMessage, "Can't recuperate old modif list\n%s file doesn't exist", szBakFileName ); AfxMessageBox( m_szMessage, MB_OK | MB_ICONSTOP ); } else { if (_access( szTxtFileName, 0) == 0) { sprintf( m_szMessage, "There's a current modif list file\nDo you want to replace it with old modif list file ?"); bContinue = (AfxMessageBox( m_szMessage, MB_YESNO | MB_ICONQUESTION ) == IDYES ); } else bContinue = TRUE; if (bContinue) { if (!CopyFile( szBakFileName, szTxtFileName, FALSE ) ) { sprintf( m_szMessage, "Error while trying to copy\n%s file to\n%s file", szBakFileName, szTxtFileName ); AfxMessageBox( m_szMessage, MB_OK | MB_ICONSTOP ); } else { sprintf( m_szMessage, "Old list of modification recovered" ); AfxMessageBox( m_szMessage, MB_OK | MB_ICONINFORMATION ); } OnButtonRefresh(); } } } else if (strnicmp( m_szCheat, "obtain", 6) == 0) { fn_IniD_vSaveObtainingDate(); OnButtonRefresh(); } } return TRUE; } return CDialog::PreTranslateMessage(pMsg); } /* --------------------------------------------------------------------------------------- BN_CLICKED on IDC_BUTTON_VSSFILES --------------------------------------------------------------------------------------- */ void CMngDataDlg::OnButtonVssfiles() { m_oFileDlg.m_fn_vSetConfigType( C_ConfigType_cObtain ); if ( m_oFileDlg.DoModal() == IDOK ) { fn_IniD_vWriteFileList( &g_stIniData.stObtainConfig, g_szIniFile ); m_fn_vDisplayProgramData(); } else { if (g_stIniData.a_cAvailableConfig[ g_stIniData.stObtainConfig.cIndex ] == 0) { g_stIniData.stObtainConfig.cIndex = -1; fn_IniD_vSetSingleFileList( &g_stIniData.stObtainConfig, g_stIniData.szVssPath ); m_fn_vDisplayProgramData(); } } } /* --------------------------------------------------------------------------------------- WM_SIZE --------------------------------------------------------------------------------------- */ void CMngDataDlg::OnSize(UINT nType, int cx, int cy) { /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ RECT stRect; CWnd *p_oWnd; int iWnd; long lWidth; long lX; /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ CDialog::OnSize(nType, cx, cy); if (nType != SIZE_MINIMIZED) { /* * resize edit box control */ for (iWnd = 0; iWnd < m_cNbEditBox; iWnd ++) { p_oWnd = GetDlgItem( m_a_uiEditControl[iWnd] ); p_oWnd->GetWindowRect( &stRect ); ScreenToClient( &stRect ); stRect.right = stRect.left + (cx - m_a_iSizeLeft[iWnd]); p_oWnd->MoveWindow(&stRect, FALSE); } /* * resize right button control */ for (iWnd = 0; iWnd < m_cNbRightButtons; iWnd ++) { p_oWnd = GetDlgItem( m_a_uiRightAlignedButton[iWnd] ); p_oWnd->GetWindowRect( &stRect ); ScreenToClient( &stRect ); lWidth = stRect.right - stRect.left; stRect.right = cx - 7; stRect.left = stRect.right - lWidth; p_oWnd->MoveWindow(&stRect, FALSE); } /* * special resizing for IDC_BUTTON_CHANGEMODIF */ p_oWnd = GetDlgItem( IDC_BUTTON_CHANGEMODIF ); p_oWnd->GetWindowRect( &stRect ); ScreenToClient( &stRect ); lX = stRect.right - stRect.left; stRect.right = cx - 7 - lWidth; stRect.left = stRect.right - lX; p_oWnd->MoveWindow(&stRect, FALSE); /* * resize bottom buttons control */ lWidth = (cx - 12) / m_cNbBottomButtons; lX = 4; stRect.bottom = cy - 5; stRect.top = stRect.bottom - 20; for (iWnd = 0; iWnd < m_cNbBottomButtons; iWnd ++) { stRect.left = ++lX; stRect.right = (lX += lWidth); GetDlgItem( m_a_uiBottomButton[iWnd] )->MoveWindow(&stRect, FALSE); } /* * resize window result */ p_oWnd = GetDlgItem( IDC_RICHEDIT_RESULT ); if (p_oWnd != NULL) { p_oWnd->GetWindowRect( &stRect ); ScreenToClient( &stRect ); stRect.left = 7; stRect.right = stRect.left + cx - 14; stRect.bottom = stRect.top + (cy - m_iHeightLeft); p_oWnd->MoveWindow(&stRect, FALSE); } /* * resize progress bar */ stRect.bottom = cy - 5; stRect.top = stRect.bottom - 21; stRect.right -= 40; GetDlgItem( IDC_PROGRESS )->MoveWindow( &stRect, FALSE ); /* * resize Stop button */ stRect.left = stRect.right + 1; stRect.right += 40; GetDlgItem( IDC_BUTTON_STOP )->MoveWindow( &stRect, FALSE ); Invalidate(); } } /* --------------------------------------------------------------------------------------- WM_SIZING --------------------------------------------------------------------------------------- */ void CMngDataDlg::OnSizing( UINT nSide, LPRECT lpRect ) { /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ long lWidth = lpRect->right - lpRect->left + 1; long lHeight= lpRect->bottom - lpRect->top + 1; /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ /* * limit width : can't be less than 300 pixels */ if (lWidth < C_iMainMinWidth) { switch (nSide) { case WMSZ_BOTTOMLEFT: case WMSZ_LEFT: case WMSZ_TOPLEFT: lpRect->left = lpRect->right - C_iMainMinWidth; break; case WMSZ_BOTTOMRIGHT: case WMSZ_RIGHT: case WMSZ_TOPRIGHT: lpRect->right = lpRect->left + C_iMainMinWidth; break; } } /* * limit height : can't be less than 300 pixels */ if (lHeight < C_iMainMinHeight) { switch (nSide) { case WMSZ_BOTTOM: case WMSZ_BOTTOMLEFT: case WMSZ_BOTTOMRIGHT: lpRect->bottom = lpRect->top + C_iMainMinHeight; break; case WMSZ_TOP: case WMSZ_TOPLEFT: case WMSZ_TOPRIGHT: lpRect->top = lpRect->bottom - C_iMainMinHeight; } } CDialog::OnSizing( nSide, lpRect ); } /* --------------------------------------------------------------------------------------- BN_CLICKED on IDC_CHECK_HELP --------------------------------------------------------------------------------------- */ void CMngDataDlg::OnCheckHelp() { /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ CButton *p_oCheck = ((CButton *) GetDlgItem (IDC_CHECK_HELP)); RECT stRect; /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ if ( p_oCheck->GetCheck() == 1 ) { CMenu oMenu; oMenu.CreatePopupMenu(); oMenu.AppendMenu( MF_STRING | MF_ENABLED, IDM_ABOUTBOX, "About ..."); oMenu.AppendMenu( MF_STRING | MF_ENABLED, IDM_SHOWHELPFILE, "Help"); p_oCheck->GetWindowRect(&stRect); oMenu.TrackPopupMenu( TPM_LEFTBUTTON, stRect.left, stRect.bottom, this ); oMenu.DestroyMenu(); p_oCheck->SetCheck( 0 ); } } /* --------------------------------------------------------------------------------------- BN_CLICKED on IDC_CHECK_UPDATE --------------------------------------------------------------------------------------- */ void CMngDataDlg::OnCheckUpdate() { /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ CButton *p_oCheck = ((CButton *) GetDlgItem (IDC_CHECK_UPDATE)); RECT stRect; BOOL bUpdatePossible; /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ if ( p_oCheck->GetCheck() == 1 ) { CMenu oMenu; oMenu.CreatePopupMenu(); bUpdatePossible = (g_stIniData.p_oObtainingTime->GetYear() != 100 ) && (g_lNumberOfFatherModifs != 0 ); oMenu.AppendMenu( MF_STRING | MF_ENABLED | (bUpdatePossible?0:MF_GRAYED), IDM_UPDATE, "Update"); oMenu.AppendMenu( MF_STRING | MF_ENABLED, IDM_UPDATEHISTORY, "History"); oMenu.AppendMenu( MF_STRING | MF_ENABLED, IDM_UPDATEOPTIONS, "Options..."); oMenu.AppendMenu( MF_STRING | MF_ENABLED, IDM_UPDATEWITHCONFIG, "Update with config"); p_oCheck->GetWindowRect(&stRect); oMenu.TrackPopupMenu( TPM_LEFTBUTTON, stRect.left, stRect.bottom, this ); oMenu.DestroyMenu(); p_oCheck->SetCheck( 0 ); } } /* --------------------------------------------------------------------------------------- BN_CLICKED on IDC_BUTTON_STOP --------------------------------------------------------------------------------------- */ void CMngDataDlg::OnButtonStop() { if (m_bWorkInProgress) m_bRequestToStop = TRUE; } /* --------------------------------------------------------------------------------------- WM_HELPINFO --------------------------------------------------------------------------------------- */ BOOL CMngDataDlg::OnHelpInfo(HELPINFO* pHelpInfo) { ::WinHelp( this->GetSafeHwnd(), C_szHelpFile, HELP_CONTEXT, IDH_J_INTERFACE); return TRUE; } /* --------------------------------------------------------------------------------------- BN_CLICKED on IDCANCEL button --------------------------------------------------------------------------------------- */ void CMngDataDlg::OnCancel() { if (!m_bQuitFromSysCommand) { if (AfxMessageBox( "Are you sure you want to Quit ?", MB_YESNO | MB_ICONQUESTION) == IDNO) return; } CDialog::OnCancel(); }