vs_integration/src/Commands.cpp
//-------------------------------------------------------------------------------------------
// This public member function opens file with the given name in the Developer Studio
// and highlights the siven line. It also gives focus to the  Developer Studio.
//-------------------------------------------------------------------------------------------
This public member function opens file with the given name in the Developer Studio
and highlights the siven line. It also gives focus to the  Developer Studio.
This public member function opens file with the given name in the Developer Studio and highlights the siven line . It also gives focus to the Developer Studio .
bool CCommands::MakeSelection(CString& file, int line, int col, int len) {
ITextDocument* iDocument;
IDocuments* iDocuments;
ITextSelection* iSelection;
    if(_access(file,04)==-1) return false;
    if(m_pApplication->get_Documents((IDispatch **)&iDocuments)!=S_OK) 
		return false;
    if(iDocuments==NULL) return false;
    VARIANT varType;
	varType.vt = VT_BSTR;
	varType.bstrVal=CString("Auto").AllocSysString();
    VARIANT varReadonly;
	varReadonly.vt = VT_BOOL;
	varReadonly.boolVal = FALSE;
    if(iDocuments->Open(file.AllocSysString(),varType,varReadonly,(IDispatch **)&iDocument)!=S_OK) {
		 iDocuments->Release();
		 return false;
	}
	iDocuments->Release();
    if(iDocument==NULL) return false;
    if(iDocument->get_Selection((IDispatch **)&iSelection)!=S_OK) return false;
	iDocument->Release();
    if(iSelection==NULL) return false;
    VARIANT selAct;
	selAct.vt = VT_INT;
	selAct.intVal = dsMove;
	iSelection->MoveTo(line,1,selAct);
	VARIANT repCount;
	repCount.vt = VT_INT;
	repCount.intVal = col-1;
	iSelection->CharRight(selAct, repCount);
	selAct.intVal = dsExtend;
	repCount.intVal = len;
	iSelection->CharRight(selAct, repCount);
	iSelection->Release();
	m_pApplication->put_Active(VARIANT_TRUE);
	return true;
}
bool CCommands :: MakeSelection ( CString & file , int line , int col , int len ) { ITextDocument * iDocument ; IDocuments * iDocuments ; ITextSelection * iSelection ; if ( _access ( file , 04 ) == -1 ) return false ; if ( m_pApplication -> get_Documents ( ( IDispatch * * ) & iDocuments ) != S_OK ) return false ; if ( iDocuments == NULL ) return false ; VARIANT varType ; varType . vt = VT_BSTR ; varType . bstrVal = CString ( " " ) . AllocSysString ( ) ; VARIANT varReadonly ; varReadonly . vt = VT_BOOL ; varReadonly . boolVal = FALSE ; if ( iDocuments -> Open ( file . AllocSysString ( ) , varType , varReadonly , ( IDispatch * * ) & iDocument ) != S_OK ) { iDocuments -> Release ( ) ; return false ; } iDocuments -> Release ( ) ; if ( iDocument == NULL ) return false ; if ( iDocument -> get_Selection ( ( IDispatch * * ) & iSelection ) != S_OK ) return false ; iDocument -> Release ( ) ; if ( iSelection == NULL ) return false ; VARIANT selAct ; selAct . vt = VT_INT ; selAct . intVal = dsMove ; iSelection -> MoveTo ( line , 1 , selAct ) ; VARIANT repCount ; repCount . vt = VT_INT ; repCount . intVal = col - 1 ; iSelection -> CharRight ( selAct , repCount ) ; selAct . intVal = dsExtend ; repCount . intVal = len ; iSelection -> CharRight ( selAct , repCount ) ; iSelection -> Release ( ) ; m_pApplication -> put_Active ( VARIANT_TRUE ) ; return true ; }
This public member function opens file with the given name in the Developer Studio
and highlights the siven line.
This public member function opens file with the given name in the Developer Studio and highlights the siven line .
// First, check if the given file exists. (Developer Studio will hang for a while // trying to open non-existing file). // Get document collection from the application object. // Open new document and add it to the documents collection (if not exists). // We do not need documents collection any more // Get text selection from the current document // We do not need document object any more. // Move to the first position in the given line // Move to the end of this line in "Shift key pressed" mode. // We do not need text selection object any more // Pop-up MSDEV application.