📄 vddlg.cpp
字号:
// vdDlg.cpp : implementation file
//
#include "stdafx.h"
#include "vd.h"
#include "vdDlg.h"
#include "h263.h"
#include <vfw.h>
#include <mmsystem.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
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)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CVdDlg dialog
CVdDlg::CVdDlg(CWnd* pParent /*=NULL*/)
: CDialog(CVdDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CVdDlg)
// m_send = _T("");
m_localport = 0;
m_remoteport = 0;
m_remotepc = _T("");
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CVdDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CVdDlg)
// DDX_Control(pDX, IDC_LIST1, m_list);
// DDX_Control(pDX, IDC_EDITR, m_re);
// DDX_Text(pDX, IDC_EDITS, m_send);
DDX_Text(pDX, IDC_LOCALPROT, m_localport);
DDX_Text(pDX, IDC_remoteport, m_remoteport);
DDX_Text(pDX, IDC_remotepc, m_remotepc);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CVdDlg, CDialog)
//{{AFX_MSG_MAP(CVdDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
ON_BN_CLICKED(IDC_BIND, OnBind)
ON_WM_SHOWWINDOW()
ON_BN_CLICKED(IDC_STOP, OnStop)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CVdDlg message handlers
BOOL CVdDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
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);
}
}
// 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
// m_ss=new CMysock;
// UINT m_iPort=4000;
m_localport=4000;
m_remoteport=4000;
m_remotepc="wang";
UpdateData(FALSE);
m_ss.SetParent(this);
/* RECT m_rOutputArea;
m_rOutputArea.left =1;
m_rOutputArea.top =1;
m_rOutputArea.right=176;
m_rOutputArea.bottom=144;
MPEGDEC_InitStream (this->m_hWnd, m_rOutputArea);
*/
//m_ss->Bind(m_iPort,"199.0.0.100");
return TRUE; // return TRUE unless you set the focus to a control
}
void CVdDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// 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 CVdDlg::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 CVdDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
////////////////////////////////
////////////////////////////////
////////////////////////////////
LRESULT FAR PASCAL VideoCallbackProc(HWND, LPVIDEOHDR);
UINT FilePlayThreadProc(LPVOID pParam);
CWinThread* pFilePlayThread=NULL;
BOOL bFilePlay;
HWND hMainWnd, hCapWnd;
DWORD FrameNo = 0, PlayFrameNo;
BITMAPINFO m_biInput,bmi;
int VideoW=176, VideoH=144;
//int VideoW=352,VideoH=288;
long dwSize;
HANDLE m_hdib;
BYTE *CodeSrc, *CodeDest;
BYTE *DecodeSrc,*DecodeDest;
int ratio = 6;
FILE *fpCode, *fpDecode;
char CodeFile[120], DecodeFile[120];
DWORD time1, time2;
//DWORD FrameSize,decodesize;
unsigned long FrameSize,decodesize,currentsize;
CVdDlg *vdlg;
//char *name="filea.263";
//extern CFile f(name,CFile::modeCreate|CFile::modeWrite);
/*
void CVdDlg::OnButtons()
{
// TODO: Add your control notification handler code here
int iSent,i;
// char buffer[10]="this is s";
//UINT m_iPort=4000;
// CString str="wang";
// i=str.GetLength();
UpdateData(TRUE);
iSent = m_ss.SendTo(LPCTSTR(m_send), m_send.GetLength(),m_remoteport,m_remotepc);
// iSent = m_ss.SendTo(buffer, 10,m_iPort,str);
}
*/
void CVdDlg::OnButton2()
{
// TODO: Add your control notification handler code here
// m_re.SetWindowText("strre");
// MessageBox("this",NULL,MB_ICONEXCLAMATION);
/* UpdateData(TRUE);
if(!m_ss.Create(m_localport, SOCK_DGRAM, FD_READ|FD_WRITE|FD_OOB))
{//套接字创建失败
// delete m_ss;
// m_ss = NULL;
// return -3;
MessageBox("err");
}
CString name="wang";
m_ss.Bind(m_localport,name);
// SetCompressRatio(6);
// SetVideoFormat(888);
DWORD frames=100;
f.Write(&frames, sizeof(DWORD));
time1 = GetTickCount();*/
capCaptureSequenceNoFile(hCapWnd);
}
//char decodesrc[10240];
void CVdDlg::OnReceive()
{
char buf[1050];
// char test[20];
int num=1024;
CString Host;
CString strre;
UINT Port;
int RecieveLen;
// unsigned int temp,currentsize=0;
// CString frame;
RecieveLen = m_ss.ReceiveFrom(buf, num, Host, Port);
// _itoa( RecieveLen, test, 10 );
//sprintf(test,"%d",RecieveLen);
// m_re.SetWindowText(test);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -