- LPDISPATCH 를 사용하여 Object를 넘기는 Interface 구현
[id(1), helpstring("method SetControlObject")] HRESULT SetControlObject([in]LPDISPATCH ControObject);
- VB에서 Object를 넘겨 받는 부분 구현
Private Sub DeviceLinker_SetControlObject(ByVal ControObject As Object) Dim tObject As Object Dim msim As ECUSIMULATORLib.Simulator Set tObject = ControObject Set MultiSim = ControObject End sub
VC에서 Object를 넘겨 주는 부분 구현
CWnd* p_Wnd=NULL;
CString m_fmt,s_Setting;
try
{
HRESULT hr=NULL;
sz=p_App->m_objArray.GetSize();
for(i=0;i<sz;i++)
{
m_fmt=p_App->m_objArray[i];
p_Wnd=(CWnd*)wnd_arr[i];
if(!p_Wnd->CreateControl(m_fmt,"",WS_VISIBLE,rc,(CWnd*)&m_TAB,5000,NULL,FALSE,NULL))
{
m_str.Format("Could not place control\r\n\"%s\"",m_fmt);
::MessageBox (m_hWnd,m_str,"CreateControl Error!!",MB_OK);
continue;
}
//CComPtr<ISupportErrorInfo> iErrInfo;
ISupportErrorInfo* iErrInfo;
IDeviceLinkerPtr pUI=NULL;
pUI = p_Wnd->GetControlUnknown();
if((NULL!=pUI) && (NULL!=p_App))//상속 되지 않은 것은 다른 종류의 OCX임
{
hr = pUI->SetControlObject((IDispatch*)p_App->p_SimMulti);
if(hr!=S_OK)
{
hr = pUI->QueryInterface(IID_ISupportErrorInfo,(LPVOID*)&iErrInfo);
if( iErrInfo->InterfaceSupportsErrorInfo(IID_IDeviceLinker) == S_OK)
{
IErrorInfo* iErrInfo;
hr = GetErrorInfo(NULL,&iErrInfo);
BSTR bstr = NULL;
iErrInfo->GetDescription(&bstr);
_bstr_t Bstr(bstr,false);
m_str= bstr;
s_Setting.Format("SetControlObject()\r\n%s",m_str);
MessageBox(s_Setting,m_fmt,MB_OK);
} }
}
if(i>0)
{
p_Wnd->ShowWindow(SW_HIDE);
}
}
}
catch (_com_error &e)
{
::MessageBox(NULL,e.ErrorMessage(),m_fmt,MB_OK);
}
'개발언어 > VisualBasic' 카테고리의 다른 글
| 비주얼베이직(VB)에서 마우스 스크롤 (0) | 2016.06.13 |
|---|---|
| VB에서 다수의 이벤트를 받기 (0) | 2016.06.13 |
| Licenses (0) | 2016.06.13 |
| VB6.0 컨트롤 동적생성 (0) | 2016.06.13 |
| vb에서 mscomctl.ocx 사용관련 에러 (0) | 2016.06.13 |