void CThingTreeCtrl::OnReloadModule() { // FireReLoadModule(); HTREEITEM hSelected; CString strModuleName; IModule *pModule = NULL; HRESULT hr = S_OK; if (!m_pWorld) return; hSelected = m_treeCtrl.GetNextItem(m_hModules, TVGN_CARET); if (!hSelected) return; // get the module name from the tree strModuleName = m_treeCtrl.GetItemText(hSelected); // get the module from the world if (FAILED(hr = m_pWorld->get_Module(CComBSTR(strModuleName), &pModule))) goto exit; // call reload on the module if (FAILED(hr = pModule->Reload(VARIANT_TRUE))) { CComBSTR bstrDescription("Error reloading module."); CComPtr<IErrorInfo> pErrorInfo; CString strError; CString strTitle; CString strInfo; strTitle.LoadString(IDS_RELOAD_MODULE); strInfo.LoadString(IDS_ERROR_MODULE_RELOAD); ::GetErrorInfo(0L, &pErrorInfo); // we possibly could have no errorinfo from server-side/sync method, // if HRESULT isn't in the IThing range (the ReportThingError above will format // error strings in the proper range) if (pErrorInfo) { //pErrorInfo->GetSource(&bstrSource.m_str); pErrorInfo->GetDescription(&bstrDescription.m_str); } strError = strInfo + CString(bstrDescription); MessageBox(strError, strTitle, MB_ICONERROR); } exit: SAFERELEASE(pModule); }
bool ScriptEngine::OnChildReload(IModule& child, IEventArg& e /*= IEventArg::Empty*/) { UserDataEventArg<ScriptState*> e1(mCurrent->CurrentState()); return child.Reload(e1); }