2012年3月8日 星期四

[VC(Visual C++) ]- 02_VFW網路攝影機驅動範例

[VC(Visual C++) ]- 02_VFW網路攝影機驅動範例



本篇分享02_VFW網路攝影機驅動範例程式,有興趣的(C/P)同好,歡迎來http://filemarkets.com/file/jashliao/b2fdf33a/索取,因為我不會上傳檔案分享 ^ ^












主要程式碼



0001    // VFWView.cpp : implementation of the CVFWView class                                        

0002    //                                        

0003                                            

0004    #include "stdafx.h"                                        

0005    #include "VFW.h"                                        

0006    #include <vfw.h>                                        

0007    #include "VFWDoc.h"                                        

0008    #include "VFWView.h"                                        

0009                                            

0010    #ifdef _DEBUG                                        

0011    #definenew DEBUG_NEW                                        

0012    #undef THIS_FILE                                        

0013    staticchar THIS_FILE[] = __FILE__;                                        

0014    #endif                                        

0015                                            

0016    /////////////////////////////////////////////////////////////////////////////                                        

0017    // CVFWView                                        

0018                                            

0019    IMPLEMENT_DYNCREATE(CVFWView, CView)                                        

0020                                            

0021    BEGIN_MESSAGE_MAP(CVFWView, CView)                                        

0022        //{{AFX_MSG_MAP(CVFWView)                                    

0023        ON_COMMAND(ID_GetNumber, OnGetNumber)                                    

0024        //}}AFX_MSG_MAP                                    

0025        // Standard printing commands                                    

0026        ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)                                    

0027        ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)                                    

0028        ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)                                    

0029    END_MESSAGE_MAP()                                        

0030                                            

0031    /////////////////////////////////////////////////////////////////////////////                                        

0032    // CVFWView construction/destruction                                        

0033                                            

0034    CVFWView::CVFWView()                                        

0035    {                                        

0036        // TODO: add construction code here                                    

0037                                            

0038    }                                        

0039                                            

0040    CVFWView::~CVFWView()                                        

0041    {                                        

0042    }                                        

0043                                            

0044    BOOL CVFWView::PreCreateWindow(CREATESTRUCT& cs)                                        

0045    {                                        

0046        // TODO: Modify the Window class or styles here by modifying                                    

0047        //  the CREATESTRUCT cs                                    

0048                                            

0049        return CView::PreCreateWindow(cs);                                    

0050    }                                        

0051                                            

0052    /////////////////////////////////////////////////////////////////////////////                                        

0053    // CVFWView drawing                                        

0054                                            

0055    void CVFWView::OnDraw(CDC* pDC)                                        

0056    {                                        

0057        CVFWDoc* pDoc = GetDocument();                                    

0058        ASSERT_VALID(pDoc);                                    

0059        // TODO: add draw code for native data here                                    

0060    }                                        

0061                                            

0062    /////////////////////////////////////////////////////////////////////////////                                        

0063    // CVFWView printing                                        

0064                                            

0065    BOOL CVFWView::OnPreparePrinting(CPrintInfo* pInfo)                                        

0066    {                                        

0067        // default preparation                                    

0068        return DoPreparePrinting(pInfo);                                    

0069    }                                        

0070                                            

0071    void CVFWView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)                                        

0072    {                                        

0073        // TODO: add extra initialization before printing                                    

0074    }                                        

0075                                            

0076    void CVFWView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)                                        

0077    {                                        

0078        // TODO: add cleanup after printing                                    

0079    }                                        

0080                                            

0081    /////////////////////////////////////////////////////////////////////////////                                        

0082    // CVFWView diagnostics                                        

0083                                            

0084    #ifdef _DEBUG                                        

0085    void CVFWView::AssertValid() const                                        

0086    {                                        

0087        CView::AssertValid();                                    

0088    }                                        

0089                                            

0090    void CVFWView::Dump(CDumpContext& dc) const                                        

0091    {                                        

0092        CView::Dump(dc);                                    

0093    }                                        

0094                                            

0095    CVFWDoc* CVFWView::GetDocument() // non-debug version is inline                                        

0096    {                                        

0097        ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CVFWDoc)));                                    

0098        return (CVFWDoc*)m_pDocument;                                    

0099    }                                        

0100    #endif//_DEBUG                                        

0101                                            

0102    /////////////////////////////////////////////////////////////////////////////                                        

0103    // CVFWView message handlers                                        

0104                                            

0105    void CVFWView::OnGetNumber()                                         

0106    {                                        

0107        // TODO: Add your command handler code here                                    

0108        char DrvName[80];                                    

0109        char DrvVer[80];                                    

0110        BOOL res;                                    

0111        res=capGetDriverDescription(0,DrvName,sizeof(DrvName),DrvVer,sizeof(DrvVer));                                    

0112        if(res)                                    

0113        {                                    

0114            MessageBox(DrvName);                                

0115            MessageBox(DrvVer);                                

0116            m_hWndCap=capCreateCaptureWindow("Video Window",                                

0117                                            WS_CHILD | WS_VISIBLE ,

0118                                            0, 0, 640, 480,this->m_hWnd, 0);

0119            res=capDriverConnect(m_hWndCap,0);                                

0120            /*                                

0121            res=capOverlay(m_hWndCap,TRUE);                                

0122            if(res)                                

0123            {                                

0124                MessageBox("it is ok");                            

0125            }                                

0126            else                                

0127            {                                

0128                MessageBox("it is not ok");                            

0129            }                                

0130            */                                

0131            capPreviewScale(m_hWndCap,FALSE);                                

0132            capPreviewRate(m_hWndCap,33);                                

0133            res=capPreview(m_hWndCap,TRUE);                                

0134        }                                    

0135        else                                    

0136        {                                    

0137            MessageBox("沒有");                                

0138        }                                    

0139        //this->m_hWnd                                    

0140    }                                        

 



 


沒有留言:

張貼留言