Direct90Dlg.cpp
资源名称:Direct90.rar [点击查看]
上传用户:maxzhb99
上传日期:2013-03-13
资源大小:48k
文件大小:5k
源码类别:
DirextX编程
开发平台:
Visual C++
- // Direct90Dlg.cpp : 僀儞僾儕儊儞僥乕僔儑儞 僼傽僀儖
- //
- #include "stdafx.h"
- #include "Direct90.h"
- #include "Direct90Dlg.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // 傾僾儕働乕僔儑儞偺僶乕僕儑儞忣曬偱巊傢傟偰偄傞 CAboutDlg 僟僀傾儘僌
- class CAboutDlg : public CDialog
- {
- public:
- CAboutDlg();
- // 僟僀傾儘僌 僨乕僞
- //{{AFX_DATA(CAboutDlg)
- enum { IDD = IDD_ABOUTBOX };
- //}}AFX_DATA
- // ClassWizard 偼壖憐娭悢偺僆乕僶乕儔僀僪傪惗惉偟傑偡
- //{{AFX_VIRTUAL(CAboutDlg)
- protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 偺僒億乕僩
- //}}AFX_VIRTUAL
- // 僀儞僾儕儊儞僥乕僔儑儞
- protected:
- //{{AFX_MSG(CAboutDlg)
- //}}AFX_MSG
- DECLARE_MESSAGE_MAP()
- };
- CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
- {
- //{{AFX_DATA_INIT(CAboutDlg)
- //}}AFX_DATA_INIT
- }
- void CAboutDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CAboutDlg)
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
- //{{AFX_MSG_MAP(CAboutDlg)
- // 儊僢僙乕僕 僴儞僪儔偑偁傝傑偣傫丅
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CDirect90Dlg 僟僀傾儘僌
- CDirect90Dlg::CDirect90Dlg(CWnd* pParent /*=NULL*/)
- : CDialog(CDirect90Dlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CDirect90Dlg)
- m_str = _T("");
- //}}AFX_DATA_INIT
- // 儊儌: LoadIcon 偼 Win32 偺 DestroyIcon 偺僒僽僔乕働儞僗傪梫媮偟傑偣傫丅
- m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
- }
- void CDirect90Dlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CDirect90Dlg)
- DDX_Control(pDX, IDC_STATIC_CAPSHOW, m_CapShow);
- DDX_Text(pDX, IDC_EDIT_TEXT, m_str);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CDirect90Dlg, CDialog)
- //{{AFX_MSG_MAP(CDirect90Dlg)
- ON_WM_SYSCOMMAND()
- ON_WM_PAINT()
- ON_WM_QUERYDRAGICON()
- ON_BN_CLICKED(IDC_BUTTON_FONT, OnButtonFont)
- ON_BN_CLICKED(IDC_BUTTON_ADD, OnButtonAdd)
- ON_BN_CLICKED(IDC_BUTTON_SAVE, OnButtonSave)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CDirect90Dlg 儊僢僙乕僕 僴儞僪儔
- BOOL CDirect90Dlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
- // "僶乕僕儑儞忣曬..." 儊僯儏乕崁栚傪僔僗僥儉 儊僯儏乕傊捛壛偟傑偡丅
- // IDM_ABOUTBOX 偼僐儅儞僪 儊僯儏乕偺斖埻偱側偗傟偽側傝傑偣傫丅
- ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
- ASSERT(IDM_ABOUTBOX < 0xF000);
- CMenu* pSysMenu = GetSystemMenu(FALSE);
- if (pSysMenu != NULL)
- {
- CString strAboutMenu;
- strAboutMenu.LoadString(IDS_ABOUTBOX);
- if (!strAboutMenu.IsEmpty())
- {
- pSysMenu->AppendMenu(MF_SEPARATOR);
- pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
- }
- }
- // 偙偺僟僀傾儘僌梡偺傾僀僐儞傪愝掕偟傑偡丅僼儗乕儉儚乕僋偼傾僾儕働乕僔儑儞偺儊僀儞
- // 僂傿儞僪僂偑僟僀傾儘僌偱側偄帪偼帺摦揑偵愝掕偟傑偣傫丅
- SetIcon(m_hIcon, TRUE); // 戝偒偄傾僀僐儞傪愝掕
- SetIcon(m_hIcon, FALSE); // 彫偝偄傾僀僐儞傪愝掕
- // TODO: 摿暿側弶婜壔傪峴偆帪偼偙偺応強偵捛壛偟偰偔偩偝偄丅
- return TRUE; // TRUE 傪曉偡偲僐儞僩儘乕儖偵愝掕偟偨僼僅乕僇僗偼幐傢傟傑偣傫丅
- }
- void CDirect90Dlg::OnSysCommand(UINT nID, LPARAM lParam)
- {
- if ((nID & 0xFFF0) == IDM_ABOUTBOX)
- {
- CAboutDlg dlgAbout;
- dlgAbout.DoModal();
- }
- else
- {
- CDialog::OnSysCommand(nID, lParam);
- }
- }
- // 傕偟僟僀傾儘僌儃僢僋僗偵嵟彫壔儃僞儞傪捛壛偡傞側傜偽丄傾僀僐儞傪昤夋偡傞
- // 僐乕僪傪埲壓偵婰弎偡傞昁梫偑偁傝傑偡丅MFC 傾僾儕働乕僔儑儞偼 document/view
- // 儌僨儖傪巊偭偰偄傞偺偱丄偙偺張棟偼僼儗乕儉儚乕僋偵傛傝帺摦揑偵張棟偝傟傑偡丅
- void CDirect90Dlg::OnPaint()
- {
- if (IsIconic())
- {
- CPaintDC dc(this); // 昤夋梡偺僨僶僀僗 僐儞僥僉僗僩
- SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
- // 僋儔僀傾儞僩偺嬮宍椞堟撪偺拞墰
- int cxIcon = GetSystemMetrics(SM_CXICON);
- int cyIcon = GetSystemMetrics(SM_CYICON);
- CRect rect;
- GetClientRect(&rect);
- int x = (rect.Width() - cxIcon + 1) / 2;
- int y = (rect.Height() - cyIcon + 1) / 2;
- // 傾僀僐儞傪昤夋偟傑偡丅
- dc.DrawIcon(x, y, m_hIcon);
- }
- else
- {
- CDialog::OnPaint();
- }
- }
- // 僔僗僥儉偼丄儐乕僓乕偑嵟彫壔僂傿儞僪僂傪僪儔僢僌偟偰偄傞娫丄
- // 僇乕僜儖傪昞帵偡傞偨傔偵偙偙傪屇傃弌偟傑偡丅
- HCURSOR CDirect90Dlg::OnQueryDragIcon()
- {
- return (HCURSOR) m_hIcon;
- }
- void CDirect90Dlg::OnOK()
- {
- if(m_CapShow.m_hWnd)
- {
- HRESULT hr;
- // Create DirectShow graph and start capturing video
- hr = m_Show.CaptureVideo(m_CapShow.m_hWnd);
- if (FAILED (hr))
- {
- m_Show.ResizeVideoWindow(m_CapShow.m_hWnd);
- m_Show.CloseInterfaces();
- }
- }
- }
- void CDirect90Dlg::OnButtonFont()
- {
- // TODO: 偙偺埵抲偵僐儞僩儘乕儖捠抦僴儞僪儔梡偺僐乕僪傪捛壛偟偰偔偩偝偄
- m_Show.SetFont(m_CapShow.m_hWnd);
- }
- void CDirect90Dlg::OnButtonAdd()
- {
- // TODO: 偙偺埵抲偵僐儞僩儘乕儖捠抦僴儞僪儔梡偺僐乕僪傪捛壛偟偰偔偩偝偄
- UpdateData(TRUE);
- m_Show.UpdataStr(m_CapShow.m_hWnd, m_str);
- }
- void CDirect90Dlg::OnButtonSave()
- {
- // TODO: 偙偺埵抲偵僐儞僩儘乕儖捠抦僴儞僪儔梡偺僐乕僪傪捛壛偟偰偔偩偝偄
- }