Click here to Skip to main content
15,902,842 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: help needed Pin
Christian Graus29-Apr-02 2:35
protectorChristian Graus29-Apr-02 2:35 
GeneralRe: help needed Pin
29-Apr-02 2:46
suss29-Apr-02 2:46 
GeneralRe: help needed Pin
29-Apr-02 2:51
suss29-Apr-02 2:51 
GeneralRe: help needed Pin
29-Apr-02 3:05
suss29-Apr-02 3:05 
GeneralRe: help needed Pin
29-Apr-02 3:32
suss29-Apr-02 3:32 
Generali have trouble with my static backgrounds... Pin
Atilla Selem29-Apr-02 2:28
Atilla Selem29-Apr-02 2:28 
GeneralWindows Script Host Pin
soup29-Apr-02 1:42
soup29-Apr-02 1:42 
GeneralRe: Windows Script Host Pin
Michael P Butler29-Apr-02 3:31
Michael P Butler29-Apr-02 3:31 
I think you need to look into using AddNamedItem which is part of IActiveScript.

My code uses something like

void CLittleScript::ParseScript(LPCTSTR sScript)
{
    EXCEPINFO ei;
    _bstr_t bstrParseText(sScript);

    HRESULT hr = m_iScriptParse->ParseScriptText(bstrParseText.copy(),  
                 NULL /*L"MyApp"*/, NULL,NULL,0,0,SCRIPTTEXT_ISVISIBLE, NULL, 
                 &ei);

  if(hr == S_OK)
  {
    hr = m_iScript->SetScriptState(SCRIPTSTATE_CONNECTED);
  }
  else
  {
    littleDebugger()->Error("Failed to Parse Script Text %x", hr);
  }
}

HRESULT CLittleScript::AddScriptObject(LPCSTR sObjectName, IUnknown* pObject)
{
  m_ScriptSite.AddScriptObject(sObjectName, pObject);
  HRESULT hr = m_iScript->AddNamedItem(_bstr_t(sObjectName),
  SCRIPTITEM_ISVISIBLE | SCRIPTITEM_ISSOURCE);

  if(hr != S_OK)
  {
    littleDebugger()->Error("Failed to add named item %x", hr);
  }

  return hr;
}


In my ActiveScriptSite::GetItemInfo, I loop through for the required object interface.

if(dwReturnMask & SCRIPTINFO_IUNKNOWN)
{
  for(int nLoop = 0; nLoop < m_collectionObjects.Count(); nLoop++)
  {
    SCRIPTOBJECT* pObject = m_collectionObjects.GetItem(nLoop);
    if(pObject)
    {
	_bstr_t a(pObject->m_sName.c_str());

	if(!_wcsicmp((const wchar_t*)a, pstrName)) 
	{
      	  (*ppunkItem) = pObject->m_pObject;
	  pObject->m_pObject->AddRef();
	  break;
	}
    }
  }
}


Michael Smile | :)

Communication is the first step towards enlightenment.
GeneralSilly MFC CString Question Pin
carrie29-Apr-02 1:42
carrie29-Apr-02 1:42 
GeneralRe: Silly MFC CString Question Pin
Christian Graus29-Apr-02 2:43
protectorChristian Graus29-Apr-02 2:43 
GeneralToolTip Problem Pin
Kyudos29-Apr-02 1:36
Kyudos29-Apr-02 1:36 
GeneralRe: ToolTip Problem Pin
Ravi Bhavnani29-Apr-02 3:21
professionalRavi Bhavnani29-Apr-02 3:21 
QuestionA bug? And what to do to fix it? Pin
Igor Urdenko29-Apr-02 0:23
Igor Urdenko29-Apr-02 0:23 
AnswerRe: A bug? And what to do to fix it? Pin
Roger Allen29-Apr-02 0:28
Roger Allen29-Apr-02 0:28 
GeneralI did, but... Pin
Igor Urdenko29-Apr-02 0:43
Igor Urdenko29-Apr-02 0:43 
GeneralRe: I did, but... Pin
Roger Allen29-Apr-02 1:38
Roger Allen29-Apr-02 1:38 
GeneralThank you. Pin
Igor Urdenko29-Apr-02 3:16
Igor Urdenko29-Apr-02 3:16 
AnswerRe: A bug? And what to do to fix it? Pin
Maxwell Chen29-Apr-02 1:42
Maxwell Chen29-Apr-02 1:42 
GeneralYES!!! Pin
Igor Urdenko29-Apr-02 3:14
Igor Urdenko29-Apr-02 3:14 
GeneralRe: A bug? And what to do to fix it? Pin
Roger Allen29-Apr-02 3:46
Roger Allen29-Apr-02 3:46 
Generalmore info about the tli tlh files editing Q Pin
Aviv Halperin29-Apr-02 0:02
Aviv Halperin29-Apr-02 0:02 
GeneralRe: more info about the tli tlh files editing Q Pin
Christian Graus29-Apr-02 0:10
protectorChristian Graus29-Apr-02 0:10 
GeneralRe: more info about the tli tlh files editing Q Pin
Aviv Halperin29-Apr-02 0:25
Aviv Halperin29-Apr-02 0:25 
Generalarrays Pin
Jasmin Khan28-Apr-02 23:16
Jasmin Khan28-Apr-02 23:16 
GeneralRe: arrays Pin
Niklas L28-Apr-02 23:43
Niklas L28-Apr-02 23:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.