用SDK玩转ActiveX
2006-04-11 22:54:07 来源:WEB开发网case WM_INITDIALOG:
{
CAxWindow wndAgent;
IAgentCtlExPtr pAgent;
IAgentCtlCharactersPtr pChars;
IAgentCtlCharacterExPtr pMerlin;
IAgentCtlRequestPtr pRequest;
HRESULT hr;
wndAgent = GetDlgItem( hDlg, IDC_AGENT );
hr = wndAgent.QueryControl( __uuidof( IAgentCtlEx ), ( LPVOID * )&pAgent );
// 获取角色文件路径
TCHAR szPath[MAX_PATH];
GetWindowsDirectory( szPath, MAX_PATH );
lstrcat( szPath, _T("\\msagent\\chars\\merlin.acs") );
// 进行连接
hr = pAgent->put_Connected( (VARIANT_BOOL)-1 );
// 获得角色列表
hr = pAgent->get_Characters( &pChars );
// 装载角色
pRequest = pChars->Load( _bstr_t("merlin"), CComVariant(szPath) );
pMerlin = pChars->Character( _bstr_t("merlin") );
// 显示角色
pMerlin->Show();
// 计算屏幕中央坐标,并移动
short x = ( GetSystemMetrics( SM_CXFULLSCREEN ) - pMerlin->GetWidth() ) / 2;
short y = ( GetSystemMetrics( SM_CYFULLSCREEN ) - pMerlin->GetHeight() ) / 2;
pRequest = pMerlin->MoveTo( x, y );
pRequest = pMerlin->Speak( CComVariant("右键单击我,选择“隐藏”以结束程序。") );
}
break;
更多精彩
赞助商链接