- Code/Resource
- Windows Develop
- Linux-Unix program
- Internet-Socket-Network
- Web Server
- Browser Client
- Ftp Server
- Ftp Client
- Browser Plugins
- Proxy Server
- Email Server
- Email Client
- WEB Mail
- Firewall-Security
- Telnet Server
- Telnet Client
- ICQ-IM-Chat
- Search Engine
- Sniffer Package capture
- Remote Control
- xml-soap-webservice
- P2P
- WEB(ASP,PHP,...)
- TCP/IP Stack
- SNMP
- Grid Computing
- SilverLight
- DNS
- Cluster Service
- Network Security
- Communication-Mobile
- Game Program
- Editor
- Multimedia program
- Graph program
- Compiler program
- Compress-Decompress algrithms
- Crypt_Decrypt algrithms
- Mathimatics-Numerical algorithms
- MultiLanguage
- Disk/Storage
- Java Develop
- assembly language
- Applications
- Other systems
- Database system
- Embeded-SCM Develop
- FlashMX/Flex
- source in ebook
- Delphi VCL
- OS Develop
- MiddleWare
- MPI
- MacOS develop
- LabView
- ELanguage
- Software/Tools
- E-Books
- Artical/Document
Overlay.cpp
Package: VC++视频传输.rar [view]
Upload User: hxb_1234
Upload Date: 2010-03-30
Package Size: 8328k
Code Size: 4k
Category:
Visual C++ Books
Development Platform:
Visual C++
- // Overlay.cpp : implementation file
- //
- #include "stdafx.h"
- #include <windows.h>
- #include <mmsystem.h>
- #include "MAV8.h"
- #include "Overlay.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // COverlay
- IMPLEMENT_DYNCREATE(COverlay, CFrameWnd)
- COverlay::COverlay()
- {
- // g_hVFDrv = hVFDrv;
- CFrameWnd::Create(NULL, "Overlay Window");
- }
- COverlay::COverlay(HDRVR hVFDrv, RECT rectOverlay, WORD wSrcWidth, WORD wSrcHeight)
- {
- g_hVFDrv = hVFDrv;
- wOverlaySrcWidth=wSrcWidth;
- wOverlaySrcHeight=wSrcHeight;
- CFrameWnd::Create(NULL, "Video Window",WS_OVERLAPPEDWINDOW, rectOverlay);
- }
- COverlay::~COverlay()
- {
- }
- BEGIN_MESSAGE_MAP(COverlay, CFrameWnd)
- //{{AFX_MSG_MAP(COverlay)
- ON_WM_CREATE()
- ON_WM_MOVE()
- ON_WM_SIZE()
- ON_WM_CLOSE()
- ON_WM_PAINT()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- BOOL COverlay::SetSrc(WORD wSrcWidth, WORD wSrcHeight)
- {
- wOverlaySrcWidth=wSrcWidth;
- wOverlaySrcHeight=wSrcHeight;
- HVFSetOverlaySrc(g_hVFDrv, wOverlaySrcWidth, wOverlaySrcHeight);
- CRect rectOverlay;
- GetWindowRect(rectOverlay);
- SetWindowPos(&wndTop, rectOverlay.left, rectOverlay.top,
- wSrcWidth + GetSystemMetrics(SM_CXFRAME),
- wSrcHeight + GetSystemMetrics(SM_CYFRAME)+12+
- //GetSystemMetrics(SM_CYCAPTION)+GetSystemMetrics(SM_CYMENU),
- GetSystemMetrics(SM_CYCAPTION),
- SWP_SHOWWINDOW);
- return TRUE;
- }
- /////////////////////////////////////////////////////////////////////////////
- // COverlay message handlers
- BOOL COverlay::PreCreateWindow(CREATESTRUCT& cs)
- {
- /*// TODO: Add your specialized code here and/or call the base class
- HBRUSH hBrushMagenta=::CreateSolidBrush(RGB(255, 0, 255));
- HCURSOR hCursor=::LoadCursor(NULL, IDC_ARROW);
- //*** jsm, 1/9/98
- // added LoadIcon
- HICON hIcon = ::LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDR_TSTLOGO));
- cs.lpszClass=AfxRegisterWndClass(CS_HREDRAW | CS_VREDRAW,
- hCursor, hBrushMagenta, hIcon);
- DeleteObject(hBrushMagenta);
- */
- nScreenX=GetSystemMetrics(SM_CXSCREEN);
- nScreenY=GetSystemMetrics(SM_CYSCREEN);
- return CFrameWnd::PreCreateWindow(cs);
- }
- int COverlay::OnCreate(LPCREATESTRUCT lpCreateStruct)
- {
- if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
- return -1;
- // TODO: Add your specialized creation code here
- HVFSetOverlayWnd(g_hVFDrv, m_hWnd);
- HVFSetOverlaySrc(g_hVFDrv, wOverlaySrcWidth, wOverlaySrcHeight);
- return 0;
- }
- void COverlay::OnMove(int x, int y)
- {
- gnPosX=x;
- gnPosY=y;
- CFrameWnd::OnMove(x, y);
- // TODO: Add your message handler code here
- HVFSetOverlayPos(g_hVFDrv, x, y);
- }
- void COverlay::OnSize(UINT nType, int cx, int cy)
- {
- #define DIVIDEVALUE 40
- // TODO: Add your message handler code here
- if(cx+(cx/DIVIDEVALUE) > nScreenX ||
- cy+(cy/DIVIDEVALUE) > nScreenY){
- // make the window size smaller to avoid the 352 and 360 problem
- CRect rectOverlay;
- rectOverlay.left=0;
- rectOverlay.top=0;
- rectOverlay.right= nScreenX - (nScreenX/DIVIDEVALUE) ;
- rectOverlay.bottom= nScreenY- (nScreenY/DIVIDEVALUE) ;
- SetWindowPos(&wndTop, rectOverlay.left, rectOverlay.top,
- rectOverlay.right, rectOverlay.bottom+12, SWP_SHOWWINDOW);
- } else {
- // make the destination lager than window size, because 360 and 352 problem
- CFrameWnd::OnSize(nType, cx, cy);
- // SetOverlayDst(m_hWnd, cx+(cx/DIVIDEVALUE), cy+(cy/DIVIDEVALUE));
- HVFSetOverlayDst(g_hVFDrv, cx+(cx/DIVIDEVALUE), cy);
- }
- HVFSetOverlayPos(g_hVFDrv, gnPosX, gnPosY);
- }
- void COverlay::OnClose()
- {
- HVFUnloadOverlay (g_hVFDrv);
- CFrameWnd::OnClose();
- }
- void COverlay::OnPaint()
- {
- CPaintDC dc(this); // device context for painting
- if (g_hVFDrv)
- HVFPaintOverlay (g_hVFDrv, &dc.m_ps);
- }