EDN Admin
Well-known member
Hi, All
I am trying to create and activeX control in an ALT control, I have a demo, and it contains two way to create a activeX control in ALT control. i.e. by using class string and used the activeX control file name. the following is the demo code.
<div style="color:Black;background-color:White; <pre>
LRESULT CEmbed::OnCreate(UINT <span style="color:Green; /*uMsg*/, WPARAM <span style="color:Green; /*wParam*/, LPARAM <span style="color:Green; /*lParam*/, BOOL& <span style="color:Green; /*bHandled*/)
{
AtlAxWinInit(); <span style="color:Green; //初始化容器窗口的注册类
MessageBox(0,0,0);
RECT rc;
GetWindowRect(&rc);
rc.right -= rc.left;
rc.bottom -= rc.top;
rc.top = rc.left = 0;
RECT rect = rc;
<span style="color:Green; //Create Shock wave flash control
TCHAR* controlName = L<span style="color:#A31515; "ShockwaveFlash.ShockwaveFlash";
m_FlashWin.Create(m_hWnd, rect, controlName, WS_CHILD | WS_VISIBLE, 0, ID_FLASHCTRL );
DWORD error = ::GetLastError();
CComPtr< IAxWinAmbientDispatch > ambient;
m_FlashWin.QueryHost( &ambient );
CComPtr<IAxWinHostWindow> hostwin;
m_FlashWin.QueryHost(&hostwin);
hostwin->QueryControl(__uuidof(IDispatch),(<span style="color:Blue; void**)&m_ptrFlash.p);
<span style="color:Green; /*CComQIPtr<IShockwaveFlash> ptrFlash = m_ptrFlash;
ptrFlash->put_BackgroundColor(RGB( 0, 0, 0 ) );*/
<span style="color:Green; //create Windows Media Play control
controlName = L<span style="color:#A31515; "WMPlayer.OCX";
<span style="color:Green; //CLSID cld;
<span style="color:Green; //::CLSIDFromProgID(controlName,&cld);
m_WmvWin.Create(m_hWnd, rect,controlName,WS_CHILD, 0,ID_WMPCTRL);
<span style="color:Blue; if(hostwin)
hostwin.Release();
m_WmvWin.QueryHost(&hostwin);
hostwin->QueryControl(__uuidof(IDispatch),(<span style="color:Blue; void**)&m_ptrWmv.p);
<span style="color:Blue; return 0;
}
[/code]
And I have a ActiveX control named BioKey.ocx provided by another company. I do not know the classs string of it, so I try the second way just to put the control file name to create a instance, by the resulted window handle is NULL.
<div style="color:Black;background-color:White; <pre>
m_wndFingerPrintCtrol.Create(m_hWnd, rect,L<span style="color:#A31515; "Biokey.ocx",WS_CHILD, 0,ID_WMPCTRL);
[/code]
<br/>
I am not sure for this way to create a control. And I wish to use the class string to create one, but how to know the class string of the control? furthermore, if you know other way, please let me know, I am a fleshmen in ATL. Thanks a lot!
<hr class="sig The only thing greater than the power of mind is the courage of heart.
View the full article
I am trying to create and activeX control in an ALT control, I have a demo, and it contains two way to create a activeX control in ALT control. i.e. by using class string and used the activeX control file name. the following is the demo code.
<div style="color:Black;background-color:White; <pre>
LRESULT CEmbed::OnCreate(UINT <span style="color:Green; /*uMsg*/, WPARAM <span style="color:Green; /*wParam*/, LPARAM <span style="color:Green; /*lParam*/, BOOL& <span style="color:Green; /*bHandled*/)
{
AtlAxWinInit(); <span style="color:Green; //初始化容器窗口的注册类
MessageBox(0,0,0);
RECT rc;
GetWindowRect(&rc);
rc.right -= rc.left;
rc.bottom -= rc.top;
rc.top = rc.left = 0;
RECT rect = rc;
<span style="color:Green; //Create Shock wave flash control
TCHAR* controlName = L<span style="color:#A31515; "ShockwaveFlash.ShockwaveFlash";
m_FlashWin.Create(m_hWnd, rect, controlName, WS_CHILD | WS_VISIBLE, 0, ID_FLASHCTRL );
DWORD error = ::GetLastError();
CComPtr< IAxWinAmbientDispatch > ambient;
m_FlashWin.QueryHost( &ambient );
CComPtr<IAxWinHostWindow> hostwin;
m_FlashWin.QueryHost(&hostwin);
hostwin->QueryControl(__uuidof(IDispatch),(<span style="color:Blue; void**)&m_ptrFlash.p);
<span style="color:Green; /*CComQIPtr<IShockwaveFlash> ptrFlash = m_ptrFlash;
ptrFlash->put_BackgroundColor(RGB( 0, 0, 0 ) );*/
<span style="color:Green; //create Windows Media Play control
controlName = L<span style="color:#A31515; "WMPlayer.OCX";
<span style="color:Green; //CLSID cld;
<span style="color:Green; //::CLSIDFromProgID(controlName,&cld);
m_WmvWin.Create(m_hWnd, rect,controlName,WS_CHILD, 0,ID_WMPCTRL);
<span style="color:Blue; if(hostwin)
hostwin.Release();
m_WmvWin.QueryHost(&hostwin);
hostwin->QueryControl(__uuidof(IDispatch),(<span style="color:Blue; void**)&m_ptrWmv.p);
<span style="color:Blue; return 0;
}
[/code]
And I have a ActiveX control named BioKey.ocx provided by another company. I do not know the classs string of it, so I try the second way just to put the control file name to create a instance, by the resulted window handle is NULL.
<div style="color:Black;background-color:White; <pre>
m_wndFingerPrintCtrol.Create(m_hWnd, rect,L<span style="color:#A31515; "Biokey.ocx",WS_CHILD, 0,ID_WMPCTRL);
[/code]
<br/>
I am not sure for this way to create a control. And I wish to use the class string to create one, but how to know the class string of the control? furthermore, if you know other way, please let me know, I am a fleshmen in ATL. Thanks a lot!
<hr class="sig The only thing greater than the power of mind is the courage of heart.
View the full article