16 #define CheckConnected(pin,code) \
19 ASSERT(!TEXT("Pin not set")); \
20 } else if (pin->IsConnected() == FALSE) { \
33 if (hwndDrain !=
NULL && !InSendMessage())
41 case WM_LBUTTONDBLCLK:
44 case WM_MBUTTONDBLCLK:
47 case WM_MOUSEACTIVATE:
51 case WM_NCLBUTTONDBLCLK:
52 case WM_NCLBUTTONDOWN:
54 case WM_NCMBUTTONDBLCLK:
55 case WM_NCMBUTTONDOWN:
58 case WM_NCRBUTTONDBLCLK:
59 case WM_NCRBUTTONDOWN:
61 case WM_RBUTTONDBLCLK:
70 PostMessage(hwndDrain, uMsg, wParam, lParam);
89 __in_opt LPCTSTR
pName,
90 __inout_opt LPUNKNOWN pUnk,
91 __inout HRESULT *phr) :
94 m_pInterfaceLock(pInterfaceLock),
99 m_bCursorHidden(FALSE),
119 SetWindowText(
m_hwnd, strCaption);
124 SetWindowText(
m_hwnd, Caption);
149 MultiByteToWideChar(CP_ACP,0,Caption,-1,WideCaption,
CAPTION);
151 return WriteBSTR(pstrCaption,WideCaption);
163 if (GetWindowLong(
m_hwnd,GWL_EXSTYLE) & WS_EX_TOPMOST) {
164 if ((WindowStyleEx & WS_EX_TOPMOST) == 0) {
171 if (WindowStyleEx & WS_EX_TOPMOST) {
173 WindowStyleEx &= (~WS_EX_TOPMOST);
174 if (WindowStyleEx == 0)
return NOERROR;
196 if ((WindowStyle & WS_DISABLED) ||
197 (WindowStyle & WS_ICONIC) ||
198 (WindowStyle & WS_MAXIMIZE) ||
199 (WindowStyle & WS_MINIMIZE) ||
200 (WindowStyle & WS_HSCROLL) ||
201 (WindowStyle & WS_VSCROLL)) {
233 BOOL bVisible = IsWindowVisible(
m_hwnd);
237 SetWindowLong(
m_hwnd,WindowLong,Style);
238 UINT WindowFlags = SWP_SHOWWINDOW | SWP_FRAMECHANGED | SWP_NOACTIVATE;
239 WindowFlags |= SWP_NOZORDER | SWP_NOSIZE | SWP_NOMOVE;
243 if (bVisible == TRUE) {
256 GetSystemMetrics(SM_CXSCREEN),
257 GetSystemMetrics(SM_CYSCREEN),
269 ShowWindow(
m_hwnd,SW_HIDE);
273 MapWindowPoints(HWND_DESKTOP, GetParent(
m_hwnd), (LPPOINT)&WindowRect, 2);
291 *pStyle = GetWindowLong(
m_hwnd,WindowLong);
320 *pWindowState = FALSE;
326 if (IsWindowVisible(
m_hwnd) == TRUE) {
329 if (IsIconic(
m_hwnd) == TRUE) {
330 *pWindowState |= SW_MINIMIZE;
334 else if (IsZoomed(
m_hwnd) == TRUE) {
335 *pWindowState |= SW_MAXIMIZE;
340 *pWindowState |= SW_SHOW;
344 *pWindowState |= SW_HIDE;
363 if (BackgroundPalette !=
OATRUE) {
364 if (BackgroundPalette !=
OAFALSE) {
411 INT Mode = (Visible ==
OATRUE ? SW_SHOWNORMAL : SW_HIDE);
428 BOOL Mode = IsWindowVisible(
m_hwnd);
449 MapWindowPoints(HWND_DESKTOP, GetParent(
m_hwnd), (LPPOINT)&WindowRect, 2);
456 WindowRect.bottom = WindowRect.bottom - WindowRect.top;
457 WindowRect.right = WindowRect.right - WindowRect.left;
458 UINT WindowFlags = SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOACTIVATE;
460 bSuccess = SetWindowPos(
m_hwnd,
468 if (bSuccess == FALSE) {
484 *pLeft = WindowRect.left;
508 MapWindowPoints(HWND_DESKTOP, GetParent(
m_hwnd), (LPPOINT)&WindowRect, 2);
511 WindowRect.bottom = WindowRect.bottom - WindowRect.top;
512 UINT WindowFlags = SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOACTIVATE;
518 bSuccess = SetWindowPos(
m_hwnd,
526 if (bSuccess == FALSE) {
542 *pWidth = WindowRect.right - WindowRect.left;
562 MapWindowPoints(HWND_DESKTOP, GetParent(
m_hwnd), (LPPOINT)&WindowRect, 2);
569 WindowRect.bottom = WindowRect.bottom - WindowRect.top;
570 WindowRect.right = WindowRect.right - WindowRect.left;
571 UINT WindowFlags = SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOACTIVATE;
573 bSuccess = SetWindowPos(
m_hwnd,
581 if (bSuccess == FALSE) {
597 *pTop = WindowRect.top;
621 MapWindowPoints(HWND_DESKTOP, GetParent(
m_hwnd), (LPPOINT)&WindowRect, 2);
624 WindowRect.right = WindowRect.right - WindowRect.left;
625 UINT WindowFlags = SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOACTIVATE;
627 bSuccess = SetWindowPos(
m_hwnd,
635 if (bSuccess == FALSE) {
651 *pHeight = WindowRect.bottom - WindowRect.top;
677 LONG Style = GetWindowLong(
m_hwnd,GWL_STYLE);
679 Style &= (~WS_CHILD);
683 SetWindowLong(
m_hwnd,GWL_STYLE,Style);
687 SetParent(
m_hwnd,hwndParent);
690 NOTE1(
"Changed parent %lx",hwndParent);
756 case WM_SYSCOLORCHANGE:
757 case WM_PALETTECHANGED:
758 case WM_PALETTEISCHANGING:
759 case WM_QUERYNEWPALETTE:
760 case WM_DEVMODECHANGE:
761 case WM_DISPLAYCHANGE:
769 SendMessage(
m_hwnd,uMsg,(WPARAM)wParam,(LPARAM)lParam);
777 PostMessage(
m_hwnd,WM_PAINT,0,0);
801 BOOL bFocus = (Focus ==
OATRUE ? TRUE : FALSE);
820 UINT WindowFlags = SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOACTIVATE;
823 bSuccess = SetWindowPos(
m_hwnd,
834 if (bSuccess == FALSE) {
864 *pLeft = WindowRect.left;
865 *pTop = WindowRect.top;
866 *pWidth = WindowRect.right - WindowRect.left;
867 *pHeight = WindowRect.bottom - WindowRect.top;
892 WINDOWPLACEMENT Place;
893 Place.length =
sizeof(WINDOWPLACEMENT);
900 if (SystemParametersInfo(SPI_GETWORKAREA,0,&WorkArea,FALSE) == TRUE) {
902 Place.rcNormalPosition.top += WorkArea.top;
903 Place.rcNormalPosition.bottom += WorkArea.top;
904 Place.rcNormalPosition.left += WorkArea.left;
905 Place.rcNormalPosition.right += WorkArea.left;
911 *pLeft = Place.rcNormalPosition.left;
912 *pTop = Place.rcNormalPosition.top;
913 *pWidth = Place.rcNormalPosition.right - Place.rcNormalPosition.left;
914 *pHeight = Place.rcNormalPosition.bottom - Place.rcNormalPosition.top;
1017 if (State == State_Stopped) {
1018 return VFW_E_WRONG_STATE;
1022 *pWidth =
WIDTH(&DefaultRect);
1023 *pHeight =
HEIGHT(&DefaultRect);
1044 if (State == State_Stopped) {
1045 return VFW_E_WRONG_STATE;
1049 *pWidth =
WIDTH(&DefaultRect);
1050 *pHeight =
HEIGHT(&DefaultRect);
1066 return E_INVALIDARG;
1096 __in_opt LPCTSTR
pName,
1097 __inout_opt LPUNKNOWN pUnk,
1098 __inout HRESULT *phr) :
1102 m_pInterfaceLock(pInterfaceLock),
1119 if (pVideoInfo ==
NULL)
1120 return E_OUTOFMEMORY;
1121 COARefTime AvgTime(pVideoInfo->AvgTimePerFrame);
1122 *pAvgTimePerFrame = (REFTIME) AvgTime;
1137 if (pVideoInfo ==
NULL)
1138 return E_OUTOFMEMORY;
1139 *pBitRate = pVideoInfo->dwBitRate;
1153 if (pVideoInfo ==
NULL)
1154 return E_OUTOFMEMORY;
1155 *pBitErrorRate = pVideoInfo->dwBitErrorRate;
1169 if (pVideoInfo ==
NULL)
1170 return E_OUTOFMEMORY;
1171 *pVideoWidth = pVideoInfo->bmiHeader.biWidth;
1185 if (pVideoInfo ==
NULL)
1186 return E_OUTOFMEMORY;
1187 *pVideoHeight = pVideoInfo->bmiHeader.biHeight;
1201 __out
long *pRetrieved,
1202 __out_ecount_part(Entries, *pRetrieved)
long *pPalette)
1212 if (pVideoInfo ==
NULL)
1213 return E_OUTOFMEMORY;
1214 BITMAPINFOHEADER *pHeader = HEADER(pVideoInfo);
1218 if (PALETTISED(pVideoInfo) == FALSE) {
1220 return VFW_E_NO_PALETTE_AVAILABLE;
1225 if (pPalette ==
NULL) {
1226 *pRetrieved = pHeader->biClrUsed;
1232 if (StartIndex >= (LONG) pHeader->biClrUsed || StartIndex < 0) {
1234 return E_INVALIDARG;
1239 LONG Available = (LONG) pHeader->biClrUsed - StartIndex;
1240 *pRetrieved = max(0,min(Available,Entries));
1241 if (*pRetrieved == 0) {
1247 PALETTEENTRY *pEntries = (PALETTEENTRY *) pPalette;
1248 RGBQUAD *pColours = COLORS(pVideoInfo) + StartIndex;
1250 for (LONG Count = 0;Count < *pRetrieved;Count++) {
1251 pEntries[Count].peRed = pColours[Count].rgbRed;
1252 pEntries[Count].peGreen = pColours[Count].rgbGreen;
1253 pEntries[Count].peBlue = pColours[Count].rgbBlue;
1254 pEntries[Count].peFlags = 0;
1274 if (pVideoInfo ==
NULL)
1275 return E_OUTOFMEMORY;
1276 *pWidth = pVideoInfo->bmiHeader.biWidth;
1277 *pHeight = pVideoInfo->bmiHeader.biHeight;
1292 SourceRect.left = Left;
1293 SourceRect.top = Top;
1294 SourceRect.right = Left + Width;
1295 SourceRect.bottom = Top + Height;
1333 *pLeft = SourceRect.left;
1334 *pTop = SourceRect.top;
1335 *pWidth =
WIDTH(&SourceRect);
1336 *pHeight =
HEIGHT(&SourceRect);
1351 RECT DestinationRect;
1353 DestinationRect.left = Left;
1354 DestinationRect.top = Top;
1355 DestinationRect.right = Left + Width;
1356 DestinationRect.bottom = Top + Height;
1389 RECT DestinationRect;
1394 *pLeft = DestinationRect.left;
1395 *pTop = DestinationRect.top;
1396 *pWidth =
WIDTH(&DestinationRect);
1397 *pHeight =
HEIGHT(&DestinationRect);
1414 SourceRect.right = SourceLeft +
WIDTH(&SourceRect);
1415 SourceRect.left = SourceLeft;
1444 *pSourceLeft = SourceRect.left;
1459 SourceRect.right = SourceRect.left + SourceWidth;
1488 *pSourceWidth =
WIDTH(&SourceRect);
1504 SourceRect.bottom = SourceTop +
HEIGHT(&SourceRect);
1505 SourceRect.top = SourceTop;
1534 *pSourceTop = SourceRect.top;
1547 SourceRect.bottom = SourceRect.top + SourceHeight;
1576 *pSourceHeight =
HEIGHT(&SourceRect);
1590 RECT DestinationRect;
1592 DestinationRect.right = DestinationLeft +
WIDTH(&DestinationRect);
1593 DestinationRect.left = DestinationLeft;
1619 RECT DestinationRect;
1622 *pDestinationLeft = DestinationRect.left;
1633 RECT DestinationRect;
1635 DestinationRect.right = DestinationRect.left + DestinationWidth;
1661 RECT DestinationRect;
1664 *pDestinationWidth =
WIDTH(&DestinationRect);
1678 RECT DestinationRect;
1680 DestinationRect.bottom = DestinationTop +
HEIGHT(&DestinationRect);
1681 DestinationRect.top = DestinationTop;
1707 RECT DestinationRect;
1710 *pDestinationTop = DestinationRect.top;
1721 RECT DestinationRect;
1723 DestinationRect.bottom = DestinationRect.top + DestinationHeight;
1749 RECT DestinationRect;
1752 *pDestinationHeight =
HEIGHT(&DestinationRect);
1817 if (pVideoImage !=
NULL) {
1819 if (State != State_Paused) {
1820 return VFW_E_NOT_PAUSED;
1828 if (pVideoInfo ==
NULL)
1829 return E_OUTOFMEMORY;
1832 return GetImageSize(pVideoInfo,pBufferSize,&SourceRect);
1844 __out
long *pBufferSize,
1845 __in RECT *pSourceRect)
1847 NOTE(
"Entering GetImageSize");
1852 if (pSourceRect ==
NULL ||
1853 pVideoInfo ==
NULL ||
1854 pBufferSize ==
NULL) {
1856 return E_UNEXPECTED;
1861 if (pVideoInfo->bmiHeader.biCompression != BI_RGB) {
1862 if (pVideoInfo->bmiHeader.biCompression != BI_BITFIELDS) {
1863 return E_INVALIDARG;
1867 ASSERT(IsRectEmpty(pSourceRect) == FALSE);
1869 BITMAPINFOHEADER bih;
1870 bih.biWidth =
WIDTH(pSourceRect);
1871 bih.biHeight =
HEIGHT(pSourceRect);
1872 bih.biBitCount = pVideoInfo->bmiHeader.biBitCount;
1873 LONG Size = DIBSIZE(bih);
1874 Size += GetBitmapFormatSize(HEADER(pVideoInfo)) - SIZE_PREHEADER;
1875 *pBufferSize = Size;
1889 __in VIDEOINFOHEADER *pVideoInfo,
1890 __inout
long *pBufferSize,
1891 __out_bcount_part(*pBufferSize, *pBufferSize) BYTE *pVideoImage,
1892 __in RECT *pSourceRect)
1894 NOTE(
"Entering CopyImage");
1896 BYTE *pCurrentImage;
1900 if (pMediaSample ==
NULL || pSourceRect ==
NULL ||
1901 pVideoInfo ==
NULL || pVideoImage ==
NULL ||
1902 pBufferSize ==
NULL) {
1904 return E_UNEXPECTED;
1909 if (pVideoInfo->bmiHeader.biCompression != BI_RGB) {
1910 if (pVideoInfo->bmiHeader.biCompression != BI_BITFIELDS) {
1911 return E_INVALIDARG;
1915 if (*pBufferSize < 0) {
1916 return E_INVALIDARG;
1920 if (pVideoInfo->bmiHeader.biSize > 4096)
1922 return E_INVALIDARG;
1925 ASSERT(IsRectEmpty(pSourceRect) == FALSE);
1927 BITMAPINFOHEADER bih;
1928 bih.biWidth =
WIDTH(pSourceRect);
1929 bih.biHeight =
HEIGHT(pSourceRect);
1930 bih.biBitCount = pVideoInfo->bmiHeader.biBitCount;
1931 DWORD Size = GetBitmapFormatSize(HEADER(pVideoInfo)) - SIZE_PREHEADER;
1935 if( !ValidateBitmapInfoHeader( HEADER(pVideoInfo), Size)) {
1936 return E_INVALIDARG;
1941 __analysis_assume(Size >=
sizeof(BITMAPINFOHEADER));
1943 if (FAILED(SAFE_DIBSIZE(&bih, &dwDibSize))) {
1944 return E_INVALIDARG;
1947 if (FAILED(DWordAdd(Size, dwDibSize, &Total))) {
1948 return E_INVALIDARG;
1953 if ((DWORD)*pBufferSize < Total) {
1954 return E_OUTOFMEMORY;
1960 ((BITMAPINFOHEADER *)pVideoImage)->biWidth =
WIDTH(pSourceRect);
1961 ((BITMAPINFOHEADER *)pVideoImage)->biHeight =
HEIGHT(pSourceRect);
1962 ((BITMAPINFOHEADER *)pVideoImage)->biSizeImage = DIBSIZE(bih);
1963 BYTE *pImageData = pVideoImage + Size;
1967 HRESULT
hr = pMediaSample->GetPointer(&pCurrentImage);
1974 LONG ScanLine = (pVideoInfo->bmiHeader.biBitCount / 8) *
WIDTH(pSourceRect);
1975 LONG LinesToSkip = pVideoInfo->bmiHeader.biHeight;
1976 LinesToSkip -= pSourceRect->top +
HEIGHT(pSourceRect);
1977 pCurrentImage += LinesToSkip * DIBWIDTHBYTES(pVideoInfo->bmiHeader);
1978 pCurrentImage += pSourceRect->left * (pVideoInfo->bmiHeader.biBitCount / 8);
1982 for (LONG Line = 0;Line <
HEIGHT(pSourceRect);Line++) {
1984 pImageData += DIBWIDTHBYTES(*(BITMAPINFOHEADER *)pVideoImage);
1985 pCurrentImage += DIBWIDTHBYTES(pVideoInfo->bmiHeader);
2001 if (pVideoInfo ==
NULL)
2002 return E_OUTOFMEMORY;
2003 WORD Width = (WORD) pVideoInfo->bmiHeader.biWidth;
2004 WORD Height = (WORD) pVideoInfo->bmiHeader.biHeight;
2007 MAKELPARAM(Width,Height),
2029 if ((pSourceRect->left >= pSourceRect->right) ||
2030 (pSourceRect->left < 0) ||
2031 (pSourceRect->top >= pSourceRect->bottom) ||
2032 (pSourceRect->top < 0)) {
2034 return E_INVALIDARG;
2039 if ((pSourceRect->right > Width) ||
2040 (pSourceRect->bottom > Height)) {
2042 return E_INVALIDARG;
2061 if (pTargetRect ==
NULL) {
2067 if (pTargetRect->left > pTargetRect->right ||
2068 pTargetRect->top > pTargetRect->bottom) {
2069 return E_INVALIDARG;
2074 if (
WIDTH(pTargetRect) <= 0 ||
HEIGHT(pTargetRect) <= 0) {
2075 return E_INVALIDARG;
2078 ASSERT(IsRectEmpty(pTargetRect) == FALSE);