📄 pidtestdlg.cpp
字号:
// PIDTestDlg.cpp : implementation file
//
#include "stdafx.h"
#include <streams.h>
#include "CDXGraph.h"
#include "IMPEG1Builder.h"
#include <initguid.h>
#include "FltGuids.h"
#include "PIDTest.h"
#include "PIDTestDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CPIDTestDlg dialog
CPIDTestDlg::CPIDTestDlg(CWnd* pParent /*=NULL*/)
: CDialog(CPIDTestDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CPIDTestDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
m_pGraph = NULL;
}
CPIDTestDlg::~CPIDTestDlg()
{
if (m_pGraph)
{
delete m_pGraph;
m_pGraph = NULL;
}
}
void CPIDTestDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPIDTestDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CPIDTestDlg, CDialog)
//{{AFX_MSG_MAP(CPIDTestDlg)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(ID_CMD_PAUSE, OnCmdPause)
ON_BN_CLICKED(ID_CMD_PLAY, OnCmdPlay)
ON_BN_CLICKED(ID_CMD_STOP, OnCmdStop)
ON_BN_CLICKED(ID_CMD_OPEN, OnCmdOpen)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPIDTestDlg message handlers
BOOL CPIDTestDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
SetWindowPos(&wndTopMost, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
return TRUE; // return TRUE unless you set the focus to a control
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CPIDTestDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
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;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CPIDTestDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CPIDTestDlg::OnCmdOpen()
{
CString strFilter = "MPEG File (*.mpg;*.mpeg)|*.mpg;*.mpeg|";
CFileDialog dlgOpen(TRUE, NULL, NULL, OFN_HIDEREADONLY, strFilter, NULL);
if (IDOK != dlgOpen.DoModal())
{
return;
}
mSourceFile = dlgOpen.GetPathName();
// Rebuild the filter graph
if (m_pGraph)
{
m_pGraph->Stop();
delete m_pGraph;
m_pGraph = NULL;
}
m_pGraph = new CDXGraph();
m_pGraph->Create();
IMPEG1Builder * pMPG1Builder = NULL;
m_pGraph->QueryInterface(IID_IMPEG1Builder, (void**)&pMPG1Builder);
if (pMPG1Builder)
{
pMPG1Builder->Release();
if (S_OK == pMPG1Builder->IsMPEG1File(mSourceFile))
{
pMPG1Builder->RenderMPEG1File(mSourceFile);
// Automatically play this MPEG1 file
OnCmdPlay();
}
else
{
AfxMessageBox("This is not a MPEG1 file!");
}
}
}
void CPIDTestDlg::OnCmdPause()
{
if (m_pGraph)
{
m_pGraph->Pause();
}
}
void CPIDTestDlg::OnCmdPlay()
{
if (m_pGraph)
{
m_pGraph->Run();
}
}
void CPIDTestDlg::OnCmdStop()
{
if (m_pGraph)
{
m_pGraph->Stop();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -