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
MainWnd.cpp
Package: VfwExample.zip [view]
Upload User: qianbin
Upload Date: 2009-10-23
Package Size: 617k
Code Size: 4k
Category:
Video Capture
Development Platform:
Visual C++
- // MainWnd.cpp : implementation file
- //
- #include "stdafx.h"
- #include "VfwExample.h"
- #include "MainWnd.h"
- #include "TipsWareVideoCapture.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- TipsWareVideoCapture *gp_capture_engine;
- /////////////////////////////////////////////////////////////////////////////
- // MainWnd
- MainWnd::MainWnd() : StandardWnd()
- {
- m_caption_main = "VFW_Ex.";
- m_accelerators_key = ::LoadAccelerators(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDR_MAINFRAME));
- m_tray_tip = "[VfwExample] 涝聪促";
- }
- MainWnd::~MainWnd()
- {
- }
- void MainWnd::TrayStateSetup(int parm_command, const char *parm_tip_string)
- {
- NOTIFYICONDATA taskbar_notify_data;
- strcpy(taskbar_notify_data.szTip, parm_tip_string);
- switch(parm_command){
- case NIM_ADD :
- taskbar_notify_data.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;
- break;
- case NIM_DELETE :
- taskbar_notify_data.uFlags = 0;
- break;
- case NIM_MODIFY :
- taskbar_notify_data.uFlags = NIF_TIP | NIF_ICON;
- break;
- }
- taskbar_notify_data.uID = (UINT)IDR_MAINFRAME;
- taskbar_notify_data.cbSize = sizeof(NOTIFYICONDATA);
- taskbar_notify_data.hWnd = this->m_hWnd;
- taskbar_notify_data.uCallbackMessage = LM_TRAY_TIP_MESSAGE;
- taskbar_notify_data.hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
- Shell_NotifyIcon(parm_command, &taskbar_notify_data);
- }
- BEGIN_MESSAGE_MAP(MainWnd, StandardWnd)
- //{{AFX_MSG_MAP(MainWnd)
- ON_WM_PAINT()
- ON_WM_CREATE()
- ON_WM_DESTROY()
- ON_WM_SYSCOMMAND()
- //}}AFX_MSG_MAP
- ON_MESSAGE(LM_TRAY_TIP_MESSAGE, OnTrayMessage)
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // MainWnd message handlers
- void MainWnd::OnPaint()
- {
- // CPaintDC dc(this);
- StandardWnd::OnPaint();
- }
- int MainWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
- {
- if(StandardWnd::OnCreate(lpCreateStruct) == -1) return -1;
- SetWindowSystemMenu(1, 0, 1);
- ::SetCursor(::LoadCursor(NULL, IDC_ARROW));
- TrayStateSetup(NIM_ADD, (const char *)m_tray_tip);
- // VFW甫 积己茄促.
- gp_capture_engine = new TipsWareVideoCapture(this);
- gp_capture_engine->SetWindowSize(5, 36);
- if(gp_capture_engine->InitialVideoCapture(this)){
- gp_capture_engine->SetVideoSize(176, 144);
- if((gp_capture_engine->GetImageX() != 176) || (gp_capture_engine->GetImageY() != 144)){
- MessageBox("厚叼坷 康惑 农扁甫 176*144 农扁肺 嘎苗林技夸!!", "康惑 器镐 促矫瘤沥", MB_ICONASTERISK | MB_ICONINFORMATION);
- gp_capture_engine->SetVideoFormat();
- }
- return 0;
- } else {
- delete gp_capture_engine;
- gp_capture_engine = NULL;
- return -1;
- }
- return 0;
- }
- void MainWnd::OnDestroy()
- {
- if(gp_capture_engine != NULL){
- gp_capture_engine->DisconnectCaptureDriver();
- delete gp_capture_engine;
- gp_capture_engine = NULL;
- }
- TrayStateSetup(NIM_DELETE, (const char *)m_tray_tip);
- StandardWnd::OnDestroy();
- }
- BOOL MainWnd::PreCreateWindow(CREATESTRUCT& cs)
- {
- cs.lpszClass = "VfwExample";
- return StandardWnd::PreCreateWindow(cs);
- }
- BOOL MainWnd::PreTranslateMessage(MSG* pMsg)
- {
- if(::TranslateAccelerator(this->m_hWnd, m_accelerators_key, pMsg)) return TRUE;
- return StandardWnd::PreTranslateMessage(pMsg);
- }
- LRESULT MainWnd::OnTrayMessage(WPARAM wParam,LPARAM lParam)
- {
- if(UINT(wParam)==IDR_MAINFRAME){
- if(lParam==WM_LBUTTONDOWN){
- OnTrayLeftButton();
- }
- }
- return 0;
- }
- void MainWnd::OnTrayLeftButton()
- {
- ShowWindow(SW_SHOWNORMAL);
- BringWindowToTop();
- SetForegroundWindow();
- }
- void MainWnd::OnSysCommand(UINT nID, LPARAM lParam)
- {
- if((nID & 0xFFF0) == SC_MINIMIZE) {
- ShowWindow(SW_HIDE);
- return;
- }
- StandardWnd::OnSysCommand(nID, lParam);
- }