3,245
社区成员
发帖
与我相关
我的任务
分享
HWND CreateNetMeetingWindow(HWND hWndParent, int x, int y, LPCTSTR szMode)
{
USES_CONVERSION;
TCHAR szFormatModeString[MAX_PATH];
wsprintf(szFormatModeString, _T("MODE=%s"), szMode);
NmInitStruct nmis;
nmis.wSize = sizeof(nmis.str);
wcscpy(nmis.str, T2OLE(szFormatModeString));
LPOLESTR strGUIDNetMeetingActiveXControl = NULL;
StringFromCLSID(CLSID_NetMeeting, &strGUIDNetMeetingActiveXControl);
HWND hWndCtl =
::CreateWindow("AtlAxWin",
// Use ATL's string conversion routine to convert to a LPTSTR from an LPOLESTR
OLE2T(strGUIDNetMeetingActiveXControl),
WS_CHILD | WS_VISIBLE | WS_GROUP,
x,
y,
0,
0,
hWndParent,
NULL,
::GetModuleHandle(NULL),
&nmis
);
// Remember to free memory given to you by StringFromCLSID
CoTaskMemFree(strGUIDNetMeetingActiveXControl );
if(hWndCtl)
{
// get the IUnknown for the video window (we want to get it's size)
IUnknown* pUnk = NULL;
HRESULT hr = AtlAxGetControl(hWndCtl, &pUnk);
if(SUCCEEDED(hr))
{
// Now get the IOleObject interface for the netmeeting control
IOleObject* pOleObjVideoWindow = NULL;
hr = pUnk->QueryInterface(&pOleObjVideoWindow);
if(SUCCEEDED(hr))
{
// get the Extent
SIZEL sizel = {0, 0};
hr = pOleObjVideoWindow->GetExtent(DVASPECT_CONTENT, &sizel);
if(SUCCEEDED(hr))
{
// Convert the Extent from HIMETRIC to pixels.
SIZEL sizeInPixels = {0, 0};
AtlHiMetricToPixel(&sizel, &sizeInPixels);
SetWindowPos(hWndCtl, NULL, 0, 0, sizeInPixels.cx, sizeInPixels.cy, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
}
// Don't forget to release interfaces!
pOleObjVideoWindow->Release();
}
// Don't forget to release interfaces!
pUnk->Release();
}
}
return hWndCtl;
}