Windows应用开发-解析MP4视频文件(第1部分)

下载本应用
本Windows应用解析MP4视频文件,以表格的方式显示MP4文件结构。并可以将结果保存到bmp图片。

使用方法

选择“打开MP4视频文件”菜单项,打开MP4文件,就可以获得如下图像:

box的每一项,用3个矩形表示;左侧矩形为该项占用的字节数量,中间矩形为读取该项获得的值,右侧矩形为该项值的含义。

双击中间矩形,可以获取该项的原始数据。

当右侧矩形为红色时,双击可以解析该项。弹出解析结果对话框。


还可以获取指定视频帧数据,点击“获取指定帧数据”菜单项,在弹出窗口编辑框中输入要获取的帧序号,按回车键,或点按“获取指定帧数据”按钮。
在这里插入图片描述

在图像右侧标注了每个box的起始位置值。如果需要保存当前图像,点击“保存到bmp图片”菜单项。

应用开发信息

本应用由MFC对话框程序创建。主界面为应用程序主对话框,CDlg1为主对话框的子窗口,CDlg2为CDlg1的子窗口,由于CDlg2较大,CDlg2在CDlg1范围内的部分才可以显示,CDlg1的窗口滚动条调整CDlg2的显示区域。
定义INFO结构,读取MP4每个box,根据box内容创建若干INFO结构,结构包含,在文件中的位置,读取的字节大小,矩形的大小和位置,矩形的显示文本,和一些其它的参数。将每个INFO结构加入指针数组。图像绘制在CDlg2的OnEraseBkgnd函数中进行。
没有添加安全代码,也就是说,对于box大小设置错误的MP4文件,可能会使程序崩溃,或进入死循环。

应用的全部代码


// 解析MP4Dlg.h : 头文件
//

#pragma once
#include "Dlg1.h"
#include "Dlg2.h"
#include "Dlg5.h"
#include "COp.h"

struct INFO
{
	ULONGLONG uPos = 0;
	UINT len = 0;
	CString ID;
	CString item;
	CRect rect;
	COLORREF color;
	BYTE version;
};

struct LINE
{
	CPoint star;
	CPoint end;
	CString pos;
};

class C解析MP4Dlg : public CDialogEx
{
// 构造
public:
	C解析MP4Dlg(CWnd* pParent = NULL);	// 标准构造函数

// 对话框数据
#ifdef AFX_DESIGN_TIME
	enum { IDD = IDD_MP4_DIALOG };
#endif

	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV 支持


// 实现
protected:
	HICON m_hIcon;

	// 生成的消息映射函数
	virtual BOOL OnInitDialog();
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	DECLARE_MESSAGE_MAP()
public:
	afx_msg void OnBnClickedOk();
	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
	CDlg1 dlg1;
	CDlg2 dlg2;
	CDlg5 dlg5;
	CString Name;
	CString Path;
	afx_msg void On32771();
	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
	void SetDlg2Size(int w, int h);
	afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
	void AryDeleteAll();
	afx_msg void OnDestroy();
	afx_msg void On32772();
	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg void On32773();
};


// 解析MP4Dlg.cpp : 实现文件
//

#include "stdafx.h"
#include "解析MP4.h"
#include "解析MP4Dlg.h"
#include "afxdialogex.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif


extern CObArray ar;
extern CObArray arLine;
extern int LineRight;
extern int TrakIndex;

C解析MP4Dlg::C解析MP4Dlg(CWnd* pParent /*=NULL*/)
	: CDialogEx(IDD_MP4_DIALOG, pParent)
{
	m_hIcon = AfxGetApp()->LoadIcon(IDI_ICON1);
}

void C解析MP4Dlg::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
}

BEGIN_MESSAGE_MAP(C解析MP4Dlg, CDialogEx)
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_BN_CLICKED(IDOK, &C解析MP4Dlg::OnBnClickedOk)
	ON_WM_ERASEBKGND()
	ON_COMMAND(ID_32771, &C解析MP4Dlg::On32771)
	ON_WM_CREATE()
	ON_WM_MOUSEWHEEL()
	ON_WM_DESTROY()
	ON_COMMAND(ID_32772, &C解析MP4Dlg::On32772)
	ON_WM_SIZE()
	ON_COMMAND(ID_32773, &C解析MP4Dlg::On32773)
END_MESSAGE_MAP()


BOOL C解析MP4Dlg::OnInitDialog()
{
	CDialogEx::OnInitDialog();
	SetIcon(m_hIcon, TRUE);			// 设置大图标
	SetIcon(m_hIcon, FALSE);		// 设置小图标

	CRect rect(0, 0, 1550, 840);//设置客户区大小,宽,高
	DWORD style = GetExStyle();//获取对话框扩展样式
	if (style & WS_EX_CLIENTEDGE)//如果对话框包含WS_EX_CLIENTEDGE样式
	{
		CalcWindowRect(rect, CWnd::adjustOutside);//计算带边框的对话框窗口大小
	}
	else//如果对话框不包含WS_EX_CLIENTEDGE样式
	{
		CalcWindowRect(rect, CWnd::adjustBorder);//计算带边框的对话框窗口大小
	}
	MoveWindow(&rect);//设置对话框的大小
	CenterWindow();//居中对话框
	SetDlg2Size(0, 0);
	return TRUE;  
}

void C解析MP4Dlg::OnPaint()
{
	if (IsIconic())
	{
		CPaintDC dc(this); // 用于绘制的设备上下文
		SendMessage(WM_ICONERASEBKGND, reinterpret_cast<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
	{
		CDialogEx::OnPaint();
	}
}

HCURSOR C解析MP4Dlg::OnQueryDragIcon()
{
	return static_cast<HCURSOR>(m_hIcon);
}

void C解析MP4Dlg::OnBnClickedOk()
{
}


BOOL C解析MP4Dlg::OnEraseBkgnd(CDC* pDC)
{
	CRect rect;
	GetClientRect(rect);
	pDC->FillSolidRect(rect, RGB(212, 109, 44));
	return TRUE;
//	return CDialogEx::OnEraseBkgnd(pDC);
}


void C解析MP4Dlg::On32771()//打开MP4文件
{
	CFileDialog FD(TRUE, NULL, NULL, OFN_FILEMUSTEXIST | OFN_HIDEREADONLY, L"MP4文件|*.mp4|所有文件|*.*||");
	if (FD.DoModal() != IDOK)return;
	Path = FD.GetPathName();
	CFile F;
	if (!F.Open(Path, CFile::modeRead))
	{
		MessageBox(L"打开文件失败"); F.Close(); return;
	}
	SetWindowText(Path);
	Name = FD.GetFileTitle();
	AryDeleteAll();
	TrakIndex = 0;
	ULONGLONG LEN = F.GetLength();
	CPoint pt(36, 20);//表格左上角位置
	CString BoxName;
Agan:
	UINT BoxSize = FindBox(&F, BoxName);
	if (BoxName == L"ftyp")
	{
		pt = read_ftyp_box(&F, pt);
	}
	else if (BoxName == L"moov")
	{
		pt = read_moov_box(&F, pt); 
	}
	else if (BoxName == L"mdat")
	{
		pt = read_mdat_box(&F, pt); 
	}
	else
	{
		pt = read_X_box(&F, pt);
	}
	LONGLONG CC = F.GetPosition();
	if (F.GetPosition() < LEN)goto Agan;

	AddLine(pt, LEN);
	SetDlg2Size(LineRight + 120, pt.y + 30);
	dlg2.RedrawWindow();
	CMenu*p = GetMenu();
	CMenu* pMenu = p->GetSubMenu(0);
	pMenu->EnableMenuItem(1, MF_BYPOSITION | MF_ENABLED);
	pMenu->EnableMenuItem(2, MF_BYPOSITION | MF_ENABLED);
}


int C解析MP4Dlg::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CDialogEx::OnCreate(lpCreateStruct) == -1)
		return -1;
	dlg1.Create(IDD_DIALOG1, this);
	dlg2.Create(IDD_DIALOG2, &dlg1);
	return 0;
}

void C解析MP4Dlg::SetDlg2Size(int w, int h)
{
	CRect rect;
	dlg1.GetClientRect(rect);
	int WIDTH = rect.Width(); int HEIGHT = rect.Height();
	if (w < WIDTH)w = WIDTH;
	if (h < HEIGHT)h = HEIGHT;
	dlg2.MoveWindow(0, 0, w, h);
	dlg1.SetScrollRange(SB_VERT, 0, h - HEIGHT, TRUE);//设置垂直滚动条的滚动范围
	dlg1.SetScrollRange(SB_HORZ, 0, w - WIDTH, TRUE);//设置水平滚动条的滚动范围
	dlg1.SetScrollPos(SB_VERT, 0);//设置垂直滚动条的位置为0
	dlg1.SetScrollPos(SB_HORZ, 0);//设置水平滚动条的位置为0
}

BOOL C解析MP4Dlg::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
{
	int Min, Max;
	dlg1.GetScrollRange(SB_VERT, &Min, &Max);
	int pos = dlg1.GetScrollPos(SB_VERT);
	pos = pos - zDelta;
	if (pos < Min)pos = Min;
	if (pos > Max)pos = Max;
	dlg1.SetScrollPos(SB_VERT, pos);
	CRect rect; dlg2.GetWindowRect(rect); dlg1.ScreenToClient(rect);
	dlg2.MoveWindow(rect.left, -pos, rect.Width(), rect.Height());
	return CDialogEx::OnMouseWheel(nFlags, zDelta, pt);
}


void C解析MP4Dlg::AryDeleteAll()//删除信息数组中所有项
{
	int Count = ar.GetCount();
	for (int i = 0; i < Count; i++)
	{
		INFO* pInfo = (INFO*)ar.GetAt(i);
		delete pInfo;
	}
	ar.RemoveAll();
	int LineCount = arLine.GetCount();
	for (int i = 0; i < LineCount; i++)
	{
		LINE* pLine = (LINE*)arLine.GetAt(i);
		delete pLine;
	}
	arLine.RemoveAll();
}


void C解析MP4Dlg::OnDestroy()
{
	CDialogEx::OnDestroy();
	AryDeleteAll();
}


void C解析MP4Dlg::On32772()//保存到bmp图片
{
	if (Name.IsEmpty())return;
	CRect rc;
	dlg2.GetClientRect(rc);

	BITMAPFILEHEADER bfHeader;//位图文件头
	ZeroMemory(&bfHeader, sizeof(BITMAPFILEHEADER));
	bfHeader.bfType = (WORD)('B' | ('M' << 8));
	bfHeader.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER);
	BITMAPINFOHEADER biHeader;//位图信息头
	ZeroMemory(&biHeader, sizeof(BITMAPINFOHEADER));
	biHeader.biSize = sizeof(BITMAPINFOHEADER);
	biHeader.biBitCount = 24;
	biHeader.biCompression = BI_RGB;
	biHeader.biPlanes = 1;
	biHeader.biWidth = rc.Width();
	biHeader.biHeight = rc.Height();
	BITMAPINFO bInfo;//位图信息
	ZeroMemory(&bInfo, sizeof(BITMAPINFO));
	bInfo.bmiHeader = biHeader;
	CDC MemDC;
	MemDC.CreateCompatibleDC(NULL);//创建兼容DC
	BYTE* pB = NULL;
	HBITMAP hBitmap = CreateDIBSection(MemDC.m_hDC, &bInfo, DIB_RGB_COLORS, (VOID**)&pB, NULL, 0);
	MemDC.SelectObject(hBitmap);
	MemDC.SelectObject(&dlg2.font1);
	MemDC.FillSolidRect(rc, RGB(255, 193, 132));
	int Count = ar.GetCount();
	for (int i = 0; i < Count; i++)
	{
		INFO* pInfo = (INFO*)ar.GetAt(i);
		MemDC.FillSolidRect(pInfo->rect, pInfo->color);
		MemDC.DrawText(pInfo->item, pInfo->rect, DT_CENTER);
		MemDC.FrameRect(pInfo->rect, &CBrush(RGB(0, 0, 0)));
	}
	MemDC.SetBkMode(TRANSPARENT);
	int LineCount = arLine.GetCount();
	for (int i = 0; i < LineCount; i++)
	{
		LINE* pLine = (LINE*)arLine.GetAt(i);
		MemDC.MoveTo(pLine->star);
		CPoint end; end.x = LineRight; end.y = pLine->end.y;
		MemDC.LineTo(end);
		MemDC.TextOut(end.x + 2, end.y - 7, pLine->pos);
	}

	CFile F;
	F.Open(Name + L".bmp", CFile::modeCreate | CFile::modeWrite);
	F.Write(&bfHeader, sizeof(BITMAPFILEHEADER));//写位图文件头
	F.Write(&biHeader, sizeof(BITMAPINFOHEADER));//写位图信息
	UINT sizeN = ((rc.Width() * 3 + 3) / 4) * 4 * rc.Height();//计算数据的字节大小
	F.Write(pB, sizeN);//写图像数据
	F.Close();
}

void C解析MP4Dlg::OnSize(UINT nType, int cx, int cy)
{
	CDialogEx::OnSize(nType, cx, cy);
	CRect ClientRect;
	GetClientRect(ClientRect);
	ClientRect.DeflateRect(5, 5);
	dlg1.MoveWindow(ClientRect);
	CRect r2;
	dlg2.GetClientRect(r2);
	if (r2.Width() < ClientRect.Width())
	{
		dlg1.SetScrollRange(SB_HORZ, 0, 0, TRUE);
	}
	else
	{
		dlg1.SetScrollRange(SB_HORZ, 0, r2.Width() - ClientRect.Width(), TRUE);
	}
	if (r2.Height() < ClientRect.Height())
	{
		dlg1.SetScrollRange(SB_VERT, 0, 0, TRUE);
	}
	else
	{
		dlg1.SetScrollRange(SB_VERT, 0, r2.Height() - ClientRect.Height(), TRUE);
	}
	dlg2.MoveWindow(r2);
}


void C解析MP4Dlg::On32773()//获取指定帧数据
{
	if (dlg5.GetSafeHwnd() == NULL)
	{
		dlg5.Create(IDD_DIALOG5, NULL);
	}
	else
	{
		dlg5.ShowWindow(SW_RESTORE);
	}
	dlg5.GetFrames();
}

//COp.h
#pragma once

CPoint AudioEntry(CFile* pF, CPoint pt);
CPoint read_avcC_box(CFile* pF, CPoint pt);
CPoint read_btrt_box(CFile* pF, CPoint pt);
CPoint read_co64_box(CFile* pF, CPoint pt);
CPoint read_ctts_box(CFile* pF, CPoint pt);
CPoint read_dinf_box(CFile* pF, CPoint pt);
CPoint read_dref_box(CFile* pF, CPoint pt);
CPoint read_ftyp_box(CFile* pF, CPoint pt);
CPoint read_hdlr_box(CFile* pF, CPoint pt);
CPoint read_mdat_box(CFile* pF, CPoint pt);
CPoint read_mdhd_box(CFile* pF, CPoint pt);
CPoint read_mdia_box(CFile* pF, CPoint pt);
CPoint read_minf_box(CFile* pF, CPoint pt);
CPoint read_moov_box(CFile* pF, CPoint pt);
CPoint read_mvhd_box(CFile* pF, CPoint pt);
CPoint read_smhd_box(CFile* pF, CPoint pt);
CPoint ReadSpsPps(CFile* pF, char* pch, CPoint pt);
CPoint read_stbl_box(CFile* pF, CPoint pt);
CPoint read_stco_box(CFile* pF, CPoint pt);
CPoint read_stsc_box(CFile* pF, CPoint pt);
CPoint read_stsd_box(CFile* pF, CPoint pt);
CPoint read_stss_box(CFile* pF, CPoint pt);
CPoint read_stsz_box(CFile* pF, CPoint pt);
CPoint read_stz2_box(CFile* pF, CPoint pt);
CPoint read_stts_box(CFile* pF, CPoint pt);
CPoint read_tkhd_box(CFile* pF, CPoint pt);
CPoint read_trak_box(CFile* pF, CPoint pt);
CPoint read_udta_box(CFile* pF, CPoint pt);
CPoint read_vmhd_box(CFile* pF, CPoint pt);
CPoint read_X_box(CFile* pF, CPoint pt);
CPoint read_X2_box(CFile* pF, CPoint pt);
CPoint VideoEntry(CFile* pF, CPoint pt);
UINT FindBox(CFile* pF, CString& BoxName);//读取BOX大小和名称
CPoint AddInfo(ULONGLONG STAR, int& index, int Count, ULONGLONG* pUL, UINT* pLen, CString* pID, CString* pItem, COLORREF* pColor, BYTE* pV, CPoint pt);
CPoint AppendInfo(int Count, ULONGLONG* pUL, UINT* pLen, CString* pID, CString* pItem, COLORREF* pColor, CPoint pt);
CString FormatString(ULONGLONG ull);
BYTE ReadOne(CFile* pF);
WORD ReadTwo(CFile* pF);
UINT ReadThree(CFile* pF);
UINT ReadFour(CFile* pF);
CString ReadName(CFile* pF);
void AddLine(CPoint pt, ULONGLONG POS);


//COp.cpp
#include "stdafx.h"
#include "COp.h"
#include "解析MP4.h"
#include "解析MP4Dlg.h"

CObArray ar;//INFO数组
CObArray arLine;//LINE数组
int TrakIndex = 0;//轨道类型数组索引
CString TrakType[10];//轨道类型数组
int LineRight = 0;

UINT FindBox(CFile* pF, CString& BoxName)//读取BOX大小和名称
{
	BYTE mby1, mby2, mby3, mby4;
	pF->Read(&mby1, 1); pF->Read(&mby2, 1); pF->Read(&mby3, 1); pF->Read(&mby4, 1);
	UINT box_size = mby1 * 256 * 256 * 256 + mby2 * 256 * 256 + mby3 * 256 + mby4;
	char ch[5]; ch[4] = 0;
	pF->Read(ch, 4);
	pF->Seek(-8, CFile::current);
	BoxName = (CString)ch;
	return box_size;
}

CPoint read_ftyp_box(CFile* pF, CPoint pt)
{
	ULONGLONG STAR = pF->GetPosition();
	UINT box_size = ReadFour(pF);
	CString BoxName = ReadName(pF);
	CString major_brand= ReadName(pF);
	UINT minor_version = ReadFour(pF);
	int count = (box_size - 16) / 4;
	CString sub_str;
	for (int i = 0; i < count; i++)
	{
		CString s= ReadName(pF);
		if (i == 0)sub_str = s;
		else sub_str += L", " + s;
	}
	ULONGLONG UL[16] = { STAR ,0,STAR, 0,0,4,0,0,8,0,0,12,0,0,16 ,0 };
	UINT pLen[16] = { box_size ,0,4,0,0,4,0,0,4,0,0,4,0,0,(UINT)(count * 4) ,0 };
	CString pID[16] = { 0 };
	CString pItem[16] = { BoxName + L"\r\n" + FormatString(box_size) + L"字节" ,
		L"4字节" ,FormatString(box_size) ,L"box大小" ,
		L"4字节" , BoxName ,L"box标识" ,
		L"4字节" ,major_brand,L"文件规范",
		L"4字节",FormatString(minor_version), L"版本号",
		FormatString(box_size - 16) + L"字节",sub_str,L"兼容规范"
	};
	COLORREF BoxColor = RGB(255, 80, 40), c1 = RGB(255, 164, 131);
	COLORREF pC[16] = { BoxColor,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1 };
	BYTE pV[16] = { 0 };
	int index;
	pt = AddInfo(STAR, index, 16, UL, pLen, pID, pItem, pC, pV, pt);
	INFO* pBox = (INFO*)ar.GetAt(index);
	pBox->rect.bottom = pt.y;
	return pt;
}

CPoint read_moov_box(CFile* pF, CPoint pt)
{
	ULONGLONG STAR = pF->GetPosition();
	UINT box_size = ReadFour(pF);
	CString TBoxName = ReadName(pF);
	ULONGLONG MOOV_BOX_SIZE;
	int index;
	if (box_size == 1)//box为扩展box
	{
		ULONGLONG size1 = ReadFour(pF);UINT size2 = ReadFour(pF);
		MOOV_BOX_SIZE = (size1 << 32) + size2;
		ULONGLONG UL[10] = { STAR ,0,STAR,0,0,STAR + 4,0,0,STAR + 8,0 };
		UINT pLen[10] = { (UINT)MOOV_BOX_SIZE ,0,4,0,0,4,0,0, 8,0};
		CString pID[10] = { 0,0,0,0,0,0,0,0,0,0 };
		CString pItem[10] = { TBoxName + L"\r\n" + FormatString(box_size) + L"字节" ,
			L"4字节" ,FormatString(box_size) ,L"box大小" ,
			L"4字节" , TBoxName ,L"box标识",
			L"8字节",FormatString(MOOV_BOX_SIZE),L"扩展box大小"
		};
		COLORREF BoxColor = RGB(244, 139, 113), c1 = RGB(255, 182, 156);
		COLORREF pC[10] = { BoxColor,c1,c1,c1,c1,c1,c1,c1,c1,c1 };
		BYTE pV[10] = { 0,0,0,0,0,0,0,0,0,0 };
		pt = AddInfo(STAR, index, 10, UL, pLen, pID, pItem, pC, pV, pt);
	}
	else 
	{
		ULONGLONG UL[7] = { STAR ,0,STAR, 0,0,STAR + 4,0 };
		UINT pLen[7] = { box_size ,0,4,0,0,4,0 };
		CString pID[7] = { 0,0,0,0,0,0,0};
		CString pItem[7] = { TBoxName + L"\r\n" + FormatString(box_size) + L"字节" ,
			L"4字节" ,FormatString(box_size) ,L"box大小" ,
			L"4字节" , TBoxName ,L"box标识"
		};
		COLORREF BoxColor = RGB(244, 139, 113), c1 = RGB(255, 182, 156);
		COLORREF pC[7] = { BoxColor,c1,c1,c1,c1,c1,c1 };
		BYTE pV[16] = { 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0};
		pt = AddInfo(STAR, index, 7, UL, pLen, pID, pItem, pC, pV, pt);
		if (box_size == 0)box_size = (UINT)(pF->GetLength() - STAR);//box大小为0时,为最后一个box
		MOOV_BOX_SIZE = box_size;
	}
	pt.Offset(120, 0);//右移
Agan:
	CString BoxName;
	UINT X_box_size = FindBox(pF, BoxName);
	if (BoxName == L"mvhd")
	{
		pt = read_mvhd_box(pF, pt); 
	}
	else if (BoxName == L"trak")
	{
		pt = read_trak_box(pF, pt); 
	}
	else if (BoxName == L"udta")
	{
		pt = read_udta_box(pF, pt);
	}
	else
	{
		pt = read_X_box(pF, pt);
	}
	if (pF->GetPosition() < STAR + MOOV_BOX_SIZE)goto Agan;
	pt.Offset(-120, 0);//左移
	INFO* pBox = (INFO*)ar.GetAt(index);
	pBox->rect.bottom = pt.y;
	return pt;
}

CPoint read_mvhd_box(CFile* pF, CPoint pt)
{
	ULONGLONG STAR = pF->GetPosition();
	UINT box_size = ReadFour(pF);
	CString BoxName = ReadName(pF);
	BYTE mvhd_version = ReadOne(pF);//mvhd box的版本
	UINT flag = ReadThree(pF);//标志
	ULONGLONG creation_time;//创建时间
	ULONGLONG modification_time;//修改时间
	UINT time_scale;//时间刻度
	ULONGLONG duration_time;//时间长度
	if (mvhd_version == 1)
	{
		ULONGLONG u1 = ReadFour(pF);UINT u2 = ReadFour(pF);
		creation_time = (u1 << 32) + u2;//创建时间
		u1 = ReadFour(pF);u2 = ReadFour(pF);
		modification_time = (u1 << 32) + u2;//修改时间
		time_scale = ReadFour(pF);//时间刻度
		u1 = ReadFour(pF); u2 = ReadFour(pF);
		duration_time = (u1 << 32) + u2;//时间长度
	}
	else// mvhd_version==0 
	{
		creation_time = ReadFour(pF);//创建时间
		modification_time = ReadFour(pF);//修改时间
		time_scale = ReadFour(pF);//时间刻度
		duration_time = ReadFour(pF);//时间长度
	}
	UINT rate = ReadFour(pF);//推荐播放速度
	UINT volume = ReadTwo(pF);//音量
	BYTE reserved[10];
	pF->Read(reserved, 10);//保留位
	BYTE matrix[36];
	pF->Read(matrix, 36);//视频变换矩阵
	BYTE PreDefined[24];
	pF->Read(PreDefined, 24);//预定义
	UINT next_track_id = ReadFour(pF);//下一个track使用的id号
	
	CString text11, text12, text13;
	text11 = L"{";
	for (int i = 0; i < 10; i++)
	{
		CString str;
		if (i < 9)
			str.Format(L"%d,", reserved[i]);
		else
			str.Format(L"%d}", reserved[i]);
		text11 += str;
	}
	text12 = L"{";
	for (int i = 0; i < 36; i++)
	{
		CString str;
		if (i < 35)
			str.Format(L"%d,", matrix[i]);
		else
			str.Format(L"%d}", matrix[i]);
		text12 += str;
	}
	text13 = L"{";
	for (int i = 0; i < 24; i++)
	{
		CString str;
		if (i < 23)
			str.Format(L"%d,", PreDefined[i]);
		else
			str.Format(L"%d}", PreDefined[i]);
		text13 += str;
	}
	int index;
	if (mvhd_version == 1)
	{
		ULONGLONG UL[43] = { STAR ,0,STAR, 0,0,STAR + 4,0 ,0,STAR + 8,0,0,STAR + 9,0,0,STAR + 12,0,0,STAR + 20,0,0,STAR + 28,0,0,
			STAR + 32,0,0,STAR + 40,0,0,STAR + 44,0,0,STAR + 46,0,0,STAR + 56,0,0,STAR + 92,0,0,STAR + 116,0 };
		UINT pLen[43] = { box_size ,0,4,0,0,4,0,0,1,0,0, 3,0,0,8,0,0,8,0,0, 4,0,0, 8,0,0, 4,0,0, 2,0,0,10,0,0,36,0,0,24,0,0,4,0 };
		CString pID[43] = { 0 };
		CString pItem[43] = { BoxName + L"\r\n" + FormatString(box_size) + L"字节" ,
			L"4字节" ,FormatString(box_size) ,L"box大小" ,
			L"4字节" , BoxName ,L"box标识",
			L"1字节",FormatString(mvhd_version),L"版本",
			L"3字节",FormatString(flag),L"标志",
			L"8字节",FormatString(creation_time),L"创建时间",
			L"8字节",FormatString(modification_time),L"修改时间",
			L"4字节",FormatString(time_scale),L"分子为1的时间刻度分母,单位秒",
			L"8字节",FormatString(duration_time),L"时间长度,以时间刻度为单位",
			L"4字节",FormatString(rate),L"推荐播放速率",
			L"2字节",FormatString(volume),L"音量",
			L"10字节",text11,L"保留",
			L"36字节",text12,L"视频变换矩阵",
			L"24字节",text13,L"预定义",
			L"4字节",FormatString(next_track_id),L"下一个track使用的id号"
		};
		COLORREF BoxColor = RGB(227, 149, 192), c1 = RGB(255, 202, 245);
		COLORREF pC[43] = { BoxColor,c1,c1,c1,c1,c1,c1 ,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1 ,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1 ,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1 ,c1,c1,c1,c1,c1,c1 };
		BYTE pV[43] = { 0 };
		pt = AddInfo(STAR, index, 43, UL, pLen, pID, pItem, pC, pV, pt);
	}
	else//version == 0
	{
		ULONGLONG UL[43] = { STAR ,0,STAR, 0,0,STAR + 4,0 ,0,STAR + 8,0,0,STAR + 9,0,0,STAR + 12,0,0,STAR + 16,0,0,STAR + 20,0,0,
			STAR + 24,0,0,STAR + 28,0,0,STAR + 32,0,0,STAR + 34,0,0,STAR + 44,0,0,STAR + 80,0,0,STAR + 104,0 };
		UINT pLen[43] = { box_size ,0,4,0,0,4,0,0,1,0,0, 3,0,0,4,0,0,4,0,0, 4,0,0, 4,0,0, 4,0,0, 2,0,0,10,0,0,36,0,0,24,0,0,4,0 };
		CString pID[43] = { 0 };
		CString pItem[43] = { BoxName + L"\r\n" + FormatString(box_size) + L"字节" ,
			L"4字节" ,FormatString(box_size) ,L"box大小" ,
			L"4字节" , BoxName ,L"box标识",
			L"1字节",FormatString(mvhd_version),L"版本",
			L"3字节",FormatString(flag),L"标志",
			L"4字节",FormatString(creation_time),L"创建时间",
			L"4字节",FormatString(modification_time),L"修改时间",
			L"4字节",FormatString(time_scale),L"分子为1的时间刻度分母,单位秒",
			L"4字节",FormatString(duration_time),L"时间长度,以时间刻度为单位",
			L"4字节",FormatString(rate),L"推荐播放速率",
			L"2字节",FormatString(volume),L"音量",
			L"10字节",text11,L"保留",
			L"36字节",text12,L"视频变换矩阵",
			L"24字节",text13,L"预定义",
			L"4字节",FormatString(next_track_id),L"下一个track使用的id号"
		};
		COLORREF BoxColor = RGB(227, 149, 192), c1 = RGB(255, 202, 245);
		COLORREF pC[43] = { BoxColor,c1,c1,c1,c1,c1,c1 ,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1 ,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1 ,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1 ,c1,c1,c1,c1,c1,c1 };
		BYTE pV[43] = { 0 };
		pt = AddInfo(STAR, index, 43, UL, pLen, pID, pItem, pC, pV, pt);
	}
	INFO* pBox = (INFO*)ar.GetAt(index);
	pBox->rect.bottom = pt.y;
	return pt;
}

CPoint read_trak_box(CFile* pF, CPoint pt)
{
	ULONGLONG STAR = pF->GetPosition();
	UINT box_size = ReadFour(pF);
	CString TBoxName = ReadName(pF);
	ULONGLONG UL[7] = { STAR ,0,STAR, 0,0,STAR + 4,0 };
	UINT pLen[7] = { box_size ,0,4,0,0,4,0 };
	CString pID[7] = { 0,0,0,0,0,0,0 };
	CString pItem[7] = { TBoxName + L"\r\n" + FormatString(box_size) + L"字节" ,
		L"4字节" ,FormatString(box_size) ,L"box大小" ,
		L"4字节" , TBoxName ,L"box标识"
	};
	COLORREF BoxColor = RGB(225, 160, 129), c1 = RGB(255, 210, 179);
	COLORREF pC[7] = { BoxColor,c1,c1,c1,c1,c1,c1 };
	BYTE pV[7] = { 0,0,0,0,0,0,0 };
	int index;
	pt = AddInfo(STAR, index, 7, UL, pLen, pID, pItem, pC, pV, pt);
	pt.Offset(120, 0);//右移
Agan:
	CString BoxName;
	UINT BoxSize = FindBox(pF, BoxName);
	if (BoxName == L"tkhd")
	{
		pt = read_tkhd_box(pF, pt);
	}
	else if (BoxName == L"mdia")
	{
		pt = read_mdia_box(pF, pt); 
	}
	else
	{
		pt= read_X_box(pF, pt);
	}
	if (pF->GetPosition() - STAR < box_size)goto Agan;
	pt.Offset(-120, 0);//左移
	INFO* pBox = (INFO*)ar.GetAt(index);
	pBox->rect.bottom = pt.y;
	TrakIndex++;
	return pt;
}

CPoint read_mdia_box(CFile* pF, CPoint pt)
{
	ULONGLONG STAR = pF->GetPosition();
	UINT box_size = ReadFour(pF);
	CString TBoxName = ReadName(pF);
	ULONGLONG UL[7] = { STAR ,0,STAR, 0,0,STAR + 4,0 };
	UINT pLen[7] = { box_size ,0,4,0,0,4,0 };
	CString pID[7] = { 0,0,0,0,0,0,0 };
	CString pItem[7] = { TBoxName + L"\r\n" + FormatString(box_size) + L"字节" ,
		L"4字节" ,FormatString(box_size) ,L"box大小" ,
		L"4字节" , TBoxName ,L"box标识"
	};
	COLORREF BoxColor = RGB(219, 193, 136), c1 = RGB(255, 231, 174);
	COLORREF pC[7] = { BoxColor,c1,c1,c1,c1,c1,c1 };
	BYTE pV[7] = { 0,0,0,0,0,0,0 };
	int index;
	pt = AddInfo(STAR, index, 7, UL, pLen, pID, pItem, pC, pV, pt);
	pt.Offset(120, 0);//右移
Agan:
	CString BoxName;
	UINT BoxSize = FindBox(pF, BoxName);
	if (BoxName == L"mdhd")
	{
		pt = read_mdhd_box(pF, pt); 
	}
	else if (BoxName == L"hdlr")
	{
		pt = read_hdlr_box(pF, pt); 
	}
	else if (BoxName == L"minf")
	{
		pt = read_minf_box(pF, pt); 
	}
	else
	{
		pt = read_X_box(pF, pt);
	}
	if (pF->GetPosition() - STAR < box_size)goto Agan;
	pt.Offset(-120, 0);//左移
	INFO* pBox = (INFO*)ar.GetAt(index);
	pBox->rect.bottom = pt.y;
	return pt;
}

CPoint read_mdhd_box(CFile* pF, CPoint pt)
{
	ULONGLONG STAR = pF->GetPosition();
	UINT box_size = ReadFour(pF);
	CString BoxName = ReadName(pF);
	BYTE version = ReadOne(pF);//版本
	UINT flags = ReadThree(pF);//标志
	ULONGLONG creation_time;
	ULONGLONG modification_time;
	UINT timescale;
	ULONGLONG duration;
	if (version == 1)
	{
		UINT u1 = ReadFour(pF);UINT u2 = ReadFour(pF);
		creation_time = ((ULONGLONG)u1 << 32) + u2;//创建时间
		u1 = ReadFour(pF);u2 = ReadFour(pF);
		modification_time = ((ULONGLONG)u1 << 32) + u2;//修改时间
		timescale = ReadFour(pF);//时间刻度
		u1 = ReadFour(pF);u2 = ReadFour(pF);
		duration = ((ULONGLONG)u1 << 32) + u2;//持续时间
	}
	else // version==0 
	{
		creation_time = ReadFour(pF);//创建时间
		modification_time = ReadFour(pF);//修改时间
		timescale = ReadFour(pF);//时间刻度
		duration = ReadFour(pF);//持续时间
	}
	UINT language = ReadTwo(pF);//语言码
	UINT pre_defined = ReadTwo(pF);//预定义
	int index;
	if (version == 1)
	{
		ULONGLONG UL[31] = { STAR ,0,STAR, 0,0,STAR + 4,0,0,STAR + 8,0,0,STAR + 9,0,0, STAR + 12,0,0,STAR + 20,0,0,STAR + 28,0,0,STAR + 32,0,0,STAR + 40,0,0,STAR + 42,0 };
		UINT pLen[31] = { box_size ,0,4,0,0,4,0,0,1,0,0,3,0,0,8,0,0,8,0,0,4,0,0, 8,0,0, 2,0,0,2,0 };
		CString pID[31] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
		CString pItem[31] = { BoxName + L"\r\n" + FormatString(box_size) + L"字节" ,
			L"4字节" ,FormatString(box_size) ,L"box大小" ,
			L"4字节" , BoxName ,L"box标识",
			L"1字节",FormatString(version),L"版本",
			L"3字节",FormatString(flags),L"标志",
			L"8字节",FormatString(creation_time),L"创建时间",
			L"8字节",FormatString(modification_time),L"修改时间",
			L"4字节",FormatString(timescale),L"分子为1的时间刻度分母,单位秒",
			L"8字节",FormatString(duration),L"持续时间,以时间刻度为单位",
			L"2字节",FormatString(language),L"语言码",
			L"2字节",FormatString(pre_defined),L"预定义"
		};
		COLORREF BoxColor = RGB(140, 217, 107), c1 = RGB(190, 255, 157);
		COLORREF pC[31] = { BoxColor,c1,c1,c1,c1,c1,c1 ,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1 ,c1,c1,c1,c1, c1,c1,c1,c1,c1,c1 ,c1,c1,c1,c1 };
		BYTE pV[31] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
		pt = AddInfo(STAR, index, 31, UL, pLen, pID, pItem, pC, pV, pt);
	}
	else // version==0 
	{
		ULONGLONG UL[31] = { STAR ,0,STAR, 0,0,STAR + 4,0,0,STAR + 8,0,0,STAR + 9,0,0, STAR + 12,0,0,STAR + 16,0,0,STAR + 20,0,0,STAR + 24,0,0,STAR + 28,0,0,STAR + 30,0 };
		UINT pLen[31] = { box_size ,0,4,0,0,4,0,0,1,0,0,3,0,0,4,0,0,4,0,0,4,0,0, 4,0,0, 2,0,0,2,0 };
		CString pID[31] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
		CString pItem[31] = { BoxName + L"\r\n" + FormatString(box_size) + L"字节" ,
			L"4字节" ,FormatString(box_size) ,L"box大小" ,
			L"4字节" , BoxName ,L"box标识",
			L"1字节",FormatString(version),L"版本",
			L"3字节",FormatString(flags),L"标志",
			L"4字节",FormatString(creation_time),L"创建时间",
			L"4字节",FormatString(modification_time),L"修改时间",
			L"4字节",FormatString(timescale),L"分子为1的时间刻度分母,单位秒",
			L"4字节",FormatString(duration),L"持续时间,以时间刻度为单位",
			L"2字节",FormatString(language),L"语言码",
			L"2字节",FormatString(pre_defined),L"预定义"
		};
		COLORREF BoxColor = RGB(140, 217, 107), c1 = RGB(190, 255, 157);
		COLORREF pC[31] = { BoxColor,c1,c1,c1,c1,c1,c1 ,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1 ,c1,c1,c1,c1, c1,c1,c1,c1,c1,c1 ,c1,c1,c1,c1 };
		BYTE pV[31] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
		pt = AddInfo(STAR, index, 31, UL, pLen, pID, pItem, pC, pV, pt);
	}
	return pt;
}

CPoint read_hdlr_box(CFile* pF, CPoint pt)
{
	ULONGLONG STAR = pF->GetPosition();
	UINT box_size = ReadFour(pF);
	CString BoxName = ReadName(pF);
	BYTE version = ReadOne(pF);//版本
	UINT flags = ReadThree(pF);//标志
	UINT PreDefined = ReadFour(pF);//预定义
	CString handler_type = ReadName(pF);//轨道标识,"vide"或"soun"
	TrakType[TrakIndex] = handler_type;
	BYTE Reserve[12];
	pF->Read(Reserve, 12);//保留
	char* ch_str = new char[box_size - 31]; ch_str[box_size - 32] = 0;
	pF->Read(ch_str, box_size - 32);//ch_str=="VideoHandler"。视频处理

	CString s1; s1.Format(L"%u字节", box_size - 32);
	CString s2; s2.Format(L"{%d,%d,%d,%d,%d,%d,%d,%d,%d,%d.%d,%d}"
		, Reserve[0], Reserve[1], Reserve[2], Reserve[3], Reserve[4], Reserve[5], Reserve[6], Reserve[7], Reserve[8], Reserve[9], Reserve[10], Reserve[11]);
	CString s3; s3 = (CString)ch_str;
	delete[] ch_str;

	ULONGLONG UL[25] = { STAR ,0,STAR, 0,0,STAR + 4,0,0,STAR + 8,0,0,STAR + 9,0,0, STAR + 12,0,0,STAR + 16,0,0,STAR + 20,0,0,STAR + 32,0 };
	UINT pLen[25] = { box_size ,0,4,0,0,4,0,0,1,0,0,3,0,0,4,0,0,4,0,0,12,0,0, box_size - 32,0 };
	CString pID[25] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
	CString pItem[25] = { BoxName + L"\r\n" + FormatString(box_size) + L"字节" ,
		L"4字节" ,FormatString(box_size) ,L"box大小" ,
		L"4字节" , BoxName ,L"box标识",
		L"1字节",FormatString(version),L"版本",
		L"3字节",FormatString(flags),L"标志",
		L"4字节",FormatString(PreDefined),L"预定义",
		L"4字节",handler_type,L"轨道标识",
		L"12字节",s2,L"保留",
		s1,s3,L"处理类型"
	};
	COLORREF BoxColor = RGB(107, 172, 188), c1 = RGB(200, 230, 240);
	COLORREF pC[25] = { BoxColor,c1,c1,c1,c1,c1,c1 ,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1 ,c1,c1,c1,c1, c1,c1,c1,c1};
	BYTE pV[25] = { 0 };
	int index;
	pt = AddInfo(STAR, index, 25, UL, pLen, pID, pItem, pC, pV, pt);
	return pt;
}

CPoint read_minf_box(CFile* pF, CPoint pt)
{
	ULONGLONG STAR = pF->GetPosition();
	UINT box_size = ReadFour(pF);
	CString TBoxName = ReadName(pF);
	ULONGLONG UL[7] = { STAR ,0,STAR, 0,0,STAR + 4,0 };
	UINT pLen[7] = { box_size ,0,4,0,0,4,0 };
	CString pID[7] = { 0,0,0,0,0,0,0 };
	CString pItem[7] = { TBoxName + L"\r\n" + FormatString(box_size) + L"字节" ,
		L"4字节" ,FormatString(box_size) ,L"box大小" ,
		L"4字节" , TBoxName ,L"box标识"
	};
	COLORREF BoxColor = RGB(147, 162, 166), c1 = RGB(200, 210, 210);
	COLORREF pC[7] = { BoxColor,c1,c1,c1,c1,c1,c1 };
	BYTE pV[7] = { 0,0,0,0,0,0,0 };
	int index;
	pt = AddInfo(STAR, index, 7, UL, pLen, pID, pItem, pC, pV, pt);
	pt.Offset(120, 0);//右移
Agan:
	CString BoxName;
	UINT BoxSize = FindBox(pF, BoxName);
	if (BoxName == L"vmhd")
	{
		pt = read_vmhd_box(pF, pt);
	}
	else if (BoxName == L"smhd")
	{
		pt = read_smhd_box(pF, pt);
	}
	else if (BoxName == L"dinf")
	{
		pt = read_dinf_box(pF, pt); 
	}
	else if (BoxName == L"stbl")
	{
		pt = read_stbl_box(pF, pt); 
	}
	else
	{
		pt = read_X_box(pF, pt);
	}
	if (pF->GetPosition() < STAR + box_size)goto Agan;
	pt.Offset(-120, 0);//左移
	INFO* pBox = (INFO*)ar.GetAt(index);
	pBox->rect.bottom = pt.y;
	return pt;
}

CPoint read_stbl_box(CFile* pF, CPoint pt)
{
	ULONGLONG STAR = pF->GetPosition();
	UINT box_size = ReadFour(pF);
	CString TBoxName = ReadName(pF);
	ULONGLONG UL[7] = { STAR ,0,STAR, 0,0,STAR + 4,0 };
	UINT pLen[7] = { box_size ,0,4,0,0,4,0 };
	CString pID[7] = { 0,0,0,0,0,0,0 };
	CString pItem[7] = { TBoxName + L"\r\n" + FormatString(box_size) + L"字节" ,
		L"4字节" ,FormatString(box_size) ,L"box大小" ,
		L"4字节" , TBoxName ,L"box标识"
	};
	COLORREF BoxColor = RGB(143, 151, 140), c1 = RGB(166, 185, 160);
	COLORREF pC[7] = { BoxColor,c1,c1,c1,c1,c1,c1 };
	BYTE pV[7] = { 0,0,0,0,0,0,0 };
	int index;
	pt = AddInfo(STAR, index, 7, UL, pLen, pID, pItem, pC, pV, pt);
	pt.Offset(120, 0);//右移
Agan:
	CString BoxName;
	UINT BoxSize = FindBox(pF, BoxName);
	if (BoxName == L"stsd")
	{
		pt = read_stsd_box(pF, pt);
	}
	else if (BoxName == L"ctts")
	{
		pt = read_ctts_box(pF, pt); 
	}
	else if (BoxName == L"stco")
	{
		pt = read_stco_box(pF, pt); 
	}
	else if (BoxName == L"stsc")
	{
		pt = read_stsc_box(pF, pt); 
	}
	else if (BoxName == L"stss")
	{
		pt = read_stss_box(pF, pt);
	}
	else if (BoxName == L"stsz")
	{
		pt = read_stsz_box(pF, pt); 
	}
	else if (BoxName == L"stts")
	{
		pt = read_stts_box(pF, pt);
	}
	else if (BoxName == L"co64")
	{
		pt = read_co64_box(pF, pt);
	}
	else
	{
		pt = read_X_box(pF, pt);
	}
	if (pF->GetPosition() < STAR + box_size)goto Agan;
	INFO* pBox = (INFO*)ar.GetAt(index);
	pBox->rect.bottom = pt.y;
	pt.Offset(-120, 0);//左移
	return pt;
}

CPoint read_stsd_box(CFile* pF, CPoint pt)
{
	ULONGLONG STAR = pF->GetPosition();
	UINT box_size = ReadFour(pF);
	CString BoxName = ReadName(pF);
	BYTE version = ReadOne(pF);//版本
	UINT flags = ReadThree(pF);//标志
	UINT entry_count = ReadFour(pF);//条目数
	ULONGLONG UL[16] = { STAR ,0,STAR, 0,0,STAR + 4,0,0,STAR+8,0,0, STAR+9,0,0,STAR+12,0};
	UINT pLen[16] = { box_size ,0,4,0,0,4,0,0,1,0,0,3,0,0,4,0 };
	CString pID[16] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
	CString pItem[16] = { BoxName + L"\r\n" + FormatString(box_size) + L"字节" ,
		L"4字节" ,FormatString(box_size) ,L"box大小" ,
		L"4字节" , BoxName ,L"box标识",
		L"1字节",FormatString(version),L"版本",
		L"3字节",FormatString(flags),L"标志",
		L"4字节",FormatString(entry_count),L"条目数"
	};
	COLORREF BoxColor = RGB(174, 142, 162), c1 = RGB(217, 185, 205);
	COLORREF pC[16] = { BoxColor,c1,c1,c1,c1,c1,c1 ,c1,c1,c1,c1,c1,c1 ,c1,c1,c1 };
	BYTE pV[16] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
	int index;
	pt = AddInfo(STAR, index, 16, UL, pLen, pID, pItem, pC, pV, pt);
	pt.Offset(120, 0);//右移
	for (UINT i = 0; i < entry_count; i++)//可能的类型:avc1,mp4a,mp4v,mp4s
	{
		if (TrakType[TrakIndex] == L"vide")pt = VideoEntry(pF, pt);
		else if (TrakType[TrakIndex] == L"soun")pt = AudioEntry(pF, pt);
		else pt = read_X_box(pF, pt);
	}
	INFO* pBox = (INFO*)ar.GetAt(index);
	pBox->rect.bottom = pt.y;
	pt.Offset(-120, 0);//左移
	return pt;
}

CPoint VideoEntry(CFile* pF, CPoint pt)
{
	ULONGLONG STAR = pF->GetPosition();
	UINT box_size = ReadFour(pF);
	CString BoxName = ReadName(pF);
	BYTE Resever[6];
	pF->Read(Resever, 6);//保留
	WORD data_reference_index = ReadTwo(pF);//数据引用索引
	WORD pre_defined = ReadTwo(pF);//预定义
	WORD Resever2= ReadTwo(pF);//保留
	UINT pre_defined1[3];
	pF->Read(&pre_defined1[0], 4); pF->Read(&pre_defined1[1], 4); pF->Read(&pre_defined1[2], 4);//预定义
	UINT width = ReadTwo(pF);//宽
	UINT height = ReadTwo(pF);//高
	WORD horiz_res1 = ReadTwo(pF);//水平分辨率,小数点前
	WORD horiz_res2 = ReadTwo(pF);//水平分辨率,小数点后
	CString horiz_res_str; horiz_res_str.Format(L"%d.%d", horiz_res1, horiz_res2);
	WORD vert_res1 = ReadTwo(pF);//垂直分辨率,小数点前
	WORD vert_res2 = ReadTwo(pF);//垂直分辨率,小数点后
	CString vert_res_str; vert_res_str.Format(L"%d.%d", vert_res1, vert_res2);
	UINT Resever3;
	pF->Read(&Resever3, 4); //保留
	WORD frames_count = ReadTwo(pF);//帧数量
	char compressor_name[33]; compressor_name[32] = 0;//
	pF->Read(compressor_name, 32);//压缩器名称
	WORD bit_depth = ReadTwo(pF);//位深度
	WORD pre_defined2 = ReadTwo(pF);//预定义

	CString ReseverStr; ReseverStr.Format(L"{%d,%d,%d,%d,%d,%d}", Resever[0], Resever[1], Resever[2], Resever[3], Resever[4], Resever[5]);
	CString  pre_defined1_str; pre_defined1_str.Format(L"{%u,%u,%u}", pre_defined1[0], pre_defined1[1], pre_defined1[2]);

	ULONGLONG UL[49] = { STAR ,0,STAR, 0,0,STAR + 4,0,0,STAR + 8,0,0, STAR + 14,0,0,STAR + 16,0,0, STAR + 18,0,0, STAR + 20,0,0, STAR + 32,0,0, STAR + 34,0,0,
		STAR + 36,0,0, STAR + 40,0,0, STAR + 44,0,0,STAR + 48,0,0,STAR + 50,0,0, STAR + 82,0,0, STAR + 84,0 };
	UINT pLen[49] = { box_size ,0,4,0,0,4,0,0,6,0,0,2,0,0,2,0,0, 2,0,0,12,0,0,2,0,0,2,0,0,4,0,0,4,0,0,4,0,0,2,0,0, 32,0,0, 2,0,0, 2,0};
	CString pID[49] = { 0 };
	CString pItem[49] = { BoxName + L"\r\n" + FormatString(box_size) + L"字节" ,
		L"4字节" ,FormatString(box_size) ,L"box大小" ,
		L"4字节" , BoxName ,L"box标识",
		L"6字节",ReseverStr,L"保留",
		L"2字节",FormatString(data_reference_index),L"数据引用索引",
		L"2字节",FormatString(pre_defined),L"预定义",
		L"2字节",FormatString(Resever2),L"保留",
		L"12字节",pre_defined1_str,L"预定义",
		L"2字节",FormatString(width),L"宽",
		L"2字节",FormatString(height),L"高",
		L"4字节",horiz_res_str,L"水平分辨率(像素/英寸)",
		L"4字节",vert_res_str,L"垂直分辨率(像素/英寸)",
		L"4字节",FormatString(Resever3),L"保留",
		L"2字节",FormatString(frames_count),L"单个样本中的帧数量",
		L"32字节",(CString)compressor_name,L"压缩器名称",
		L"2字节",FormatString(bit_depth),L"位深度",
		L"2字节",FormatString(pre_defined2),L"预定义"
	};
	COLORREF BoxColor = RGB(217, 125, 107), c1 = RGB(255, 177, 159);
	COLORREF pC[49] = { BoxColor,c1,c1,c1,c1,c1,c1 ,c1,c1,c1,c1,c1,c1 ,c1,c1,c1,c1,c1,c1,c1,c1,c1 ,c1,c1,c1,c1,c1,c1 ,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1 ,c1,c1,c1,c1,c1,c1 ,c1,c1,c1,c1};
	BYTE pV[49] = { 0 };
	int index;
	pt = AddInfo(STAR, index, 49, UL, pLen, pID, pItem, pC, pV, pt);
	pt.Offset(120, 0);//右移
Agan:
	{//读子box
		CString BoxName;
		UINT BoxSize = FindBox(pF, BoxName);
		if (BoxName == L"avcC")//编码名称
		{
			pt = read_avcC_box(pF, pt);
		}
		else if (BoxName == L"btrt")
		{
			pt = read_btrt_box(pF, pt);
		}
		else
		{
			pt = read_X2_box(pF, pt);
		}
	}
	if (pF->GetPosition() < STAR + box_size)goto Agan;
	INFO* pBox = (INFO*)ar.GetAt(index);
	pBox->rect.bottom = pt.y;
	pt.Offset(-120, 0);//左移
	return pt;
}

CPoint read_avcC_box(CFile* pF, CPoint pt)
{
	ULONGLONG STAR = pF->GetPosition();
	UINT box_size = ReadFour(pF);
	CString BoxName = ReadName(pF);
	BYTE Version = ReadOne(pF);//版本
	BYTE AVCProfileIndication = ReadOne(pF);//配置文件
	BYTE profile_compatibility = ReadOne(pF);//兼容文件
	BYTE AVCLevelIndication = ReadOne(pF);//编码级别
	BYTE mby= ReadOne(pF);
	BYTE lengthSizeMinusOne = 0x3 & mby;
	mby = ReadOne(pF);
	BYTE numOfSequenceParameterSet = 0x1F & mby;//sps数量

	ULONGLONG UL[25] = { STAR ,0,STAR, 0,0,STAR + 4,0,0,STAR + 8,0,0, STAR + 9,0,0,STAR + 10,0,0, STAR + 11,0,0, STAR + 12,0,0, STAR + 13,0};
	UINT pLen[25] = { box_size ,0,4,0,0,4,0,0,1,0,0,1,0,0,1,0,0, 1,0,0,1,0,0,1,0};
	CString pID[25] = { 0 };
	CString pItem[25] = { BoxName + L"\r\n" + FormatString(box_size) + L"字节" ,
		L"4字节" ,FormatString(box_size) ,L"box大小" ,
		L"4字节" , BoxName ,L"box标识",
		L"1字节",FormatString(Version),L"版本",
		L"1字节",FormatString(AVCProfileIndication),L"配置文件",
		L"1字节",FormatString(profile_compatibility),L"兼容文件",
		L"1字节",FormatString(AVCLevelIndication),L"编码级别",
		L"1字节",FormatString(lengthSizeMinusOne),L"lengthSizeMinusOne",
		L"1字节",FormatString(numOfSequenceParameterSet),L"sps数量"
	};
	COLORREF BoxColor = RGB(140, 217, 107), c1 = RGB(190, 255, 157);
	COLORREF pC[25] = { BoxColor,c1,c1,c1,c1,c1,c1 ,c1,c1,c1,c1,c1,c1 ,c1,c1,c1,c1,c1,c1,c1,c1,c1 ,c1,c1,c1};
	BYTE pV[25] = { 0 };
	int index;
	pt = AddInfo(STAR, index, 25, UL, pLen, pID, pItem, pC, pV, pt);
	
	for (int i = 0; i < numOfSequenceParameterSet; ++i)
	{
		pt = ReadSpsPps(pF, "sps", pt);
	}

	ULONGLONG STAR2 = pF->GetPosition();
	BYTE numOfPictureParameterSets = ReadOne(pF);
	ULONGLONG UL2[3] = { 0,STAR2,0 };
	UINT pLen2[3] = {0,1,0 };
	CString pID2[3] = { 0 };
	CString pItem2[3] = { L"1字节" ,FormatString(numOfPictureParameterSets) ,L"pps数量"};
	COLORREF c2 = RGB(190, 255, 157);
	COLORREF pC2[3] = { c2,c2,c2};
	pt = AppendInfo(3, UL2, pLen2, pID2, pItem2, pC2, pt);

	for (int i = 0; i < numOfPictureParameterSets; ++i)
	{
		pt = ReadSpsPps(pF, "pps", pt);
	}
	INFO* pBox = (INFO*)ar.GetAt(index);
	pBox->rect.bottom = pt.y;
	return pt;
}

CPoint ReadSpsPps(CFile* pF, char* pch, CPoint pt)
{
	ULONGLONG STAR = pF->GetPosition();
	WORD pictureParameterSetLength = ReadTwo(pF);
	BYTE* p = new BYTE[pictureParameterSetLength];
	pF->Read(p, pictureParameterSetLength);
	CString PictureParameter;
	for (int j = 0; j < pictureParameterSetLength; j++)
	{
		CString s; s.Format(L"%0*X ", 2, p[j]); PictureParameter += s;
	}
	delete[] p;
	ULONGLONG UL[7] = { STAR ,0,STAR, 0,0,STAR + 2,0};
	UINT pLen[7] = { (UINT)(2 + pictureParameterSetLength) ,0,2,0,0,(UINT)(pictureParameterSetLength),0};
	CString pID[7] = { 0 };
	CString pItem[7] = { (CString)pch+L"\r\n" + FormatString(2+ pictureParameterSetLength) + L"字节" ,
		L"2字节" ,FormatString(pictureParameterSetLength) ,(CString)pch + L"长度" ,
		FormatString(pictureParameterSetLength)+L"字节" , PictureParameter ,(CString)pch + L"内容"
	};
	COLORREF BoxColor = RGB(152, 108, 102), c1 = RGB(193, 166, 163);
	COLORREF pC[7] = { BoxColor,c1,c1,c1,c1,c1,c1};
	BYTE pV[7] = { 0 };
	pt.Offset(120, 0);//右移
	int index;
	pt = AddInfo(STAR, index, 7, UL, pLen, pID, pItem, pC, pV, pt);
	pt.Offset(-120, 0);//左移
	INFO* pBox = (INFO*)ar.GetAt(index);
	pBox->rect.bottom = pt.y;
	return pt;
}

CPoint read_btrt_box(CFile* pF, CPoint pt)
{
	ULONGLONG STAR = pF->GetPosition();
	UINT box_size = ReadFour(pF);
	CString BoxName = ReadName(pF);
	UINT bufferSizeDB = ReadFour(pF);//缓冲区大小
	UINT maxBitrate = ReadFour(pF);//最大比特率
	UINT avgBitrate = ReadFour(pF);//平均比特率
	ULONGLONG UL[16] = { STAR ,0,STAR,0,0,STAR + 4,0,0,STAR + 8,0,0,STAR + 12,0,0,STAR + 16, 0 };
	UINT pLen[16] = { box_size ,0,4,0,0,4,0,0,4,0,0,4,0,0,4,0 };
	CString pID[16] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
	CString pItem[16] = { BoxName + L"\r\n" + FormatString(box_size) + L"字节" ,
		L"4字节" ,FormatString(box_size) ,L"box大小" ,
		L"4字节" , BoxName ,L"box标识",
		L"4字节",FormatString(bufferSizeDB),L"缓冲区大小",
		L"4字节",FormatString(maxBitrate),L"最大比特率",
		L"4字节",FormatString(avgBitrate),L"平均比特率"
	};
	COLORREF BoxColor = RGB(222, 152, 118), c1 = RGB(255, 201, 167);
	COLORREF pC[16] = { BoxColor,c1,c1,c1,c1,c1,c1, c1,c1,c1,c1,c1,c1,c1,c1,c1 };
	BYTE pV[16] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
	int index;
	pt = AddInfo(STAR, index, 16, UL, pLen, pID, pItem, pC, pV, pt);
	INFO* pBox = (INFO*)ar.GetAt(index);
	pBox->rect.bottom = pt.y;
	return pt;
}

CPoint AudioEntry(CFile* pF, CPoint pt)
{
	ULONGLONG STAR = pF->GetPosition();
	UINT box_size = ReadFour(pF);
	CString BoxName = ReadName(pF);
	BYTE Resever[6];
	pF->Read(Resever, 6);//保留
	WORD data_reference_index = ReadTwo(pF);//数据引用索引
	BYTE Reserved1[8];
	pF->Read(Reserved1, 8); //保留
	WORD nChannel = ReadTwo(pF);//声道数
	WORD nBit = ReadTwo(pF);//样本位数
	WORD pre_defined = ReadTwo(pF);//预定义
	WORD reserved = ReadTwo(pF);//保留
	UINT nSample = ReadFour(pF);//采样率
	WORD h = HIWORD(nSample);
	WORD l = LOWORD(nSample);
	CString SampleStr; SampleStr.Format(L"采样率:%d.%d", h,l);

	CString ReseverStr; ReseverStr.Format(L"{%d,%d,%d,%d,%d,%d}", Resever[0], Resever[1], Resever[2], Resever[3], Resever[4], Resever[5]);
	CString Reserved1Str; Reserved1Str.Format(L"{%u,%u,%u,%u,%u,%u,%u,%u}", Reserved1[0], Reserved1[1], Reserved1[2], Reserved1[3], Reserved1[4], Reserved1[5], Reserved1[6], Reserved1[7]);

	ULONGLONG UL[31] = { STAR ,0,STAR,0,0,STAR + 4,0,0,STAR + 8,0,0,STAR + 14,0,0,STAR + 16,0,0,STAR + 24,0,0,STAR + 26,0,0, STAR + 28,0,0,STAR + 30,0,0,STAR + 32,0 };
	UINT pLen[31] = { box_size ,0,4,0,0,4,0,0,6,0,0,2,0,0,8,0,0,2,0,0,2,0,0,2,0,0,2,0,0,4,0};
	CString pID[31] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0,0,0};
	CString pItem[31] = { BoxName + L"\r\n" + FormatString(box_size) + L"字节" ,
		L"4字节" ,FormatString(box_size) ,L"box大小" ,
		L"4字节" , BoxName ,L"box标识",
		L"6字节",ReseverStr,L"保留",
		L"2字节",FormatString(data_reference_index),L"数据引用索引",
		L"8字节",Reserved1Str,L"保留",
		L"2字节",FormatString(nChannel),L"声道数",
		L"2字节",FormatString(nBit),L"样本位数",
		L"2字节",FormatString(pre_defined),L"预定义",
		L"2字节",FormatString(reserved),L"保留",
		L"4字节",FormatString(nSample),SampleStr
	};
	COLORREF BoxColor = RGB(140, 217, 107), c1 = RGB(190, 255, 157);
	COLORREF pC[31] = { BoxColor,c1,c1,c1,c1,c1,c1, c1,c1,c1,c1,c1,c1,c1,c1,c1,c1, c1,c1,c1,c1,c1,c1,c1,c1,c1,c1, c1,c1,c1,c1 };
	BYTE pV[31] = { 0 };
	int index;
	pt = AddInfo(STAR, index, 31, UL, pLen, pID, pItem, pC, pV, pt);
	pt.Offset(120, 0);//右移
	while (pF->GetPosition() < STAR + box_size)
		pt = read_X_box(pF, pt);//读子box
	INFO* pBox = (INFO*)ar.GetAt(index);
	pBox->rect.bottom = pt.y;
	pt.Offset(-120, 0);//左移
	return pt;
}

CPoint read_ctts_box(CFile* pF, CPoint pt)
{
	ULONGLONG STAR = pF->GetPosition();
	UINT box_size = ReadFour(pF);
	CString BoxName = ReadName(pF);
	BYTE version = ReadOne(pF);//版本
	UINT flags = ReadThree(pF);//标志
	UINT entry_count = ReadFour(pF);//条目数
	pF->Seek(entry_count * 8, CFile::current);
	ULONGLONG UL[19] = { STAR ,0,STAR,0,0,STAR + 4,0,0,STAR + 8,0,0,STAR + 9,0,0,STAR + 12,0,0,STAR + 16,STAR + 16};
	UINT pLen[19] = { box_size ,0,4,0,0,4,0,0,1,0,0,3,0,0,4,0,0,entry_count * 8,entry_count * 8};
	CString pID[19] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,TrakType[TrakIndex] + L"ctts"};
	CString pItem[19] = { BoxName + L"\r\n" + FormatString(box_size) + L"字节" ,
		L"4字节" ,FormatString(box_size) ,L"box大小" ,
		L"4字节" , BoxName ,L"box标识",
		L"1字节",FormatString(version),L"版本",
		L"3字节",FormatString(flags),L"标志",
		L"4字节",FormatString(entry_count),L"条目数",
		FormatString(entry_count * 8) + L"字节",L"",L""
	};
	COLORREF BoxColor = RGB(217, 140, 107), c1 = RGB(255, 188, 155), c2 = RGB(220, 80, 80);
	COLORREF pC[19] = { BoxColor,c1,c1,c1,c1,c1,c1, c1,c1,c1,c1,c1,c1,c1,c1,c1,c1, c1,c2};
	BYTE pV[19] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,version };
	int index;
	pt = AddInfo(STAR, index, 19, UL, pLen, pID, pItem, pC, pV, pt);
	return pt;
}

CPoint read_stco_box(CFile* pF, CPoint pt)
{
	ULONGLONG STAR = pF->GetPosition();
	UINT box_size = ReadFour(pF);
	CString BoxName = ReadName(pF);
	BYTE version = ReadOne(pF);//版本
	UINT flags = ReadThree(pF);//标志
	UINT entry_count = ReadFour(pF);//条目数
	pF->Seek(entry_count * 4, CFile::current);
	ULONGLONG UL[19] = { STAR ,0,STAR,0,0,STAR + 4,0,0,STAR + 8,0,0,STAR + 9,0,0,STAR + 12,0,0,STAR + 16,STAR + 16 };
	UINT pLen[19] = { box_size ,0,4,0,0,4,0,0,1,0,0,3,0,0,4,0,0,entry_count * 4,entry_count * 4 };
	CString pID[19] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,TrakType[TrakIndex] + L"stco" };
	CString pItem[19] = { BoxName + L"\r\n" + FormatString(box_size) + L"字节" ,
		L"4字节" ,FormatString(box_size) ,L"box大小" ,
		L"4字节" , BoxName ,L"box标识",
		L"1字节",FormatString(version),L"版本",
		L"3字节",FormatString(flags),L"标志",
		L"4字节",FormatString(entry_count),L"条目数",
		FormatString(entry_count * 4) + L"字节",L"",L""
	};
	COLORREF BoxColor = RGB(107, 199, 217), c1 = RGB(147, 239, 255), c2 = RGB(220, 80, 80);
	COLORREF pC[19] = { BoxColor,c1,c1,c1,c1,c1,c1, c1,c1,c1,c1,c1,c1,c1,c1,c1,c1, c1,c2 };
	BYTE pV[19] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,version };
	int index;
	pt = AddInfo(STAR, index, 19, UL, pLen, pID, pItem, pC, pV, pt);
	return pt;
}

CPoint read_stsc_box(CFile* pF, CPoint pt)
{
	ULONGLONG STAR = pF->GetPosition();
	UINT box_size = ReadFour(pF);
	CString BoxName = ReadName(pF);
	BYTE version = ReadOne(pF);//版本
	UINT flags = ReadThree(pF);//标志
	UINT entry_count = ReadFour(pF);//条目数
	pF->Seek(entry_count * 12, CFile::current);
	ULONGLONG UL[19] = { STAR ,0,STAR,0,0,STAR + 4,0,0,STAR + 8,0,0,STAR + 9,0,0,STAR + 12,0,0,STAR + 16,STAR + 16 };
	UINT pLen[19] = { box_size ,0,4,0,0,4,0,0,1,0,0,3,0,0,4,0,0,entry_count * 12,entry_count * 12 };
	CString pID[19] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,TrakType[TrakIndex] + L"stsc" };
	CString pItem[19] = { BoxName + L"\r\n" + FormatString(box_size) + L"字节" ,
		L"4字节" ,FormatString(box_size) ,L"box大小" ,
		L"4字节" , BoxName ,L"box标识",
		L"1字节",FormatString(version),L"版本",
		L"3字节",FormatString(flags),L"标志",
		L"4字节",FormatString(entry_count),L"条目数",
		FormatString(entry_count * 12) + L"字节",L"",L""
	};
	COLORREF BoxColor = RGB(162, 162, 162), c1 = RGB(194, 194, 194), c2 = RGB(220, 80, 80);
	COLORREF pC[19] = { BoxColor,c1,c1,c1,c1,c1,c1, c1,c1,c1,c1,c1,c1,c1,c1,c1,c1, c1,c2 };
	BYTE pV[19] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,version };
	int index;
	pt = AddInfo(STAR, index, 19, UL, pLen, pID, pItem, pC, pV, pt);
	return pt;
}

CPoint read_stss_box(CFile* pF, CPoint pt)
{
	ULONGLONG STAR = pF->GetPosition();
	UINT box_size = ReadFour(pF);
	CString BoxName = ReadName(pF);
	BYTE version = ReadOne(pF);//版本
	UINT flags = ReadThree(pF);//标志
	UINT entry_count = ReadFour(pF);//条目数
	pF->Seek(entry_count * 4, CFile::current);
	ULONGLONG UL[19] = { STAR ,0,STAR,0,0,STAR + 4,0,0,STAR + 8,0,0,STAR + 9,0,0,STAR + 12, 0,0,STAR + 16, STAR + 16 };
	UINT pLen[19] = { box_size ,0,4,0,0,4,0,0,1,0,0,3,0,0,4,0,0,entry_count * 4,entry_count * 4 };
	CString pID[19] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,TrakType[TrakIndex] + L"stss" };
	CString pItem[19] = { BoxName + L"\r\n" + FormatString(box_size) + L"字节" ,
		L"4字节" ,FormatString(box_size) ,L"box大小" ,
		L"4字节" , BoxName ,L"box标识",
		L"1字节",FormatString(version),L"版本",
		L"3字节",FormatString(flags),L"标志",
		L"4字节",FormatString(entry_count),L"条目数",
		FormatString(entry_count * 4) + L"字节",L"",L""
	};
	COLORREF BoxColor = RGB(186, 160, 114), c1 = RGB(228, 202, 156), c2 = RGB(220, 80, 80);
	COLORREF pC[19] = { BoxColor,c1,c1,c1,c1,c1,c1, c1,c1,c1,c1,c1,c1,c1,c1,c1,c1, c1,c2 };
	BYTE pV[19] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,version };
	int index;
	pt = AddInfo(STAR, index, 19, UL, pLen, pID, pItem, pC, pV, pt);
	return pt;
}

CPoint read_stsz_box(CFile* pF, CPoint pt)
{
	ULONGLONG STAR = pF->GetPosition();
	UINT box_size = ReadFour(pF);
	CString BoxName = ReadName(pF);
	BYTE version = ReadOne(pF);//版本
	UINT flags = ReadThree(pF);//标志
	UINT sample_size = ReadFour(pF);//默认样本大小
	UINT sample_count = ReadFour(pF);//条目数。sample_size == 0时,为样本数量
	int index;
	if (sample_size == 0)
	{
		pF->Seek(sample_count * 4, CFile::current);
		ULONGLONG UL[22] = { STAR ,0,STAR,0,0,STAR + 4,0,0,STAR + 8,0,0,STAR + 9,0,0,STAR + 12, 0,0,STAR + 16, 0,0,STAR + 20, STAR + 20 };
		UINT pLen[22] = { box_size ,0,4,0,0,4,0,0,1,0,0,3,0,0,4,0,0,4,0,0,sample_count * 4,sample_count * 4 };
		CString pID[22] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,TrakType[TrakIndex] + L"stsz" };
		CString pItem[22] = { BoxName + L"\r\n" + FormatString(box_size) + L"字节" ,
			L"4字节" ,FormatString(box_size) ,L"box大小" ,
			L"4字节" , BoxName ,L"box标识",
			L"1字节",FormatString(version),L"版本",
			L"3字节",FormatString(flags),L"标志",
			L"4字节",FormatString(sample_size),L"默认样本大小",
			L"4字节",FormatString(sample_count),L"条目数",
			FormatString(sample_count * 4) + L"字节",L"",L""
		};
		COLORREF BoxColor = RGB(136, 107, 217), c1 = RGB(192, 163, 255), c2 = RGB(220, 80, 80);
		COLORREF pC[22] = { BoxColor,c1,c1,c1,c1,c1,c1, c1,c1,c1,c1,c1,c1,c1,c1,c1,c1, c1,c1,c1,c1,c2 };
		BYTE pV[22] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,version };
		pt = AddInfo(STAR, index, 22, UL, pLen, pID, pItem, pC, pV, pt);
	}
	else
	{
		ULONGLONG UL[19] = { STAR ,0,STAR,0,0,STAR + 4,0,0,STAR + 8,0,0,STAR + 9,0,0,STAR + 12, 0,0,STAR + 16, 0 };
		UINT pLen[19] = { box_size ,0,4,0,0,4,0,0,1,0,0,3,0,0,4,0,0,4,0 };
		CString pID[19] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
		CString pItem[19] = { BoxName + L"\r\n" + FormatString(box_size) + L"字节" ,
			L"4字节" ,FormatString(box_size) ,L"box大小" ,
			L"4字节" , BoxName ,L"box标识",
			L"1字节",FormatString(version),L"版本",
			L"3字节",FormatString(flags),L"标志",
			L"4字节",FormatString(sample_size),L"默认样本大小",
			L"4字节",FormatString(sample_count),L"样本数量",
		};
		COLORREF BoxColor = RGB(136, 107, 217), c1 = RGB(192, 163, 255), c2 = RGB(220, 80, 80);
		COLORREF pC[19] = { BoxColor,c1,c1,c1,c1,c1,c1, c1,c1,c1,c1,c1,c1,c1,c1,c1,c1, c1,c1 };
		BYTE pV[19] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
		pt = AddInfo(STAR, index, 19, UL, pLen, pID, pItem, pC, pV, pt);
	}
	return pt;
}

CPoint read_stz2_box(CFile* pF, CPoint pt)
{
	ULONGLONG STAR = pF->GetPosition();
	UINT box_size = ReadFour(pF);
	CString BoxName = ReadName(pF);
	BYTE version = ReadOne(pF);//版本
	UINT flags = ReadThree(pF);//标志
	UINT reserved = ReadThree(pF);//保留
	BYTE field_size = ReadOne(pF);//每个条目的位数
	UINT enter_count = ReadFour(pF);//条目数
	pF->Seek(box_size - 20, CFile::current);
	ULONGLONG UL[25] = { STAR ,0,STAR,0,0,STAR + 4,0,0,STAR + 8,0,0,STAR + 9,0,0,STAR + 12, 0,0,STAR + 15, 0,0,STAR+16,0,0,STAR+20, STAR + 20};
	UINT pLen[25] = { box_size ,0,4,0,0,4,0,0,1,0,0,3,0,0,3,0,0,1,0,0,4,0,0, box_size - 20 ,box_size - 20 };
	CString pID[25] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
	CString pItem[25] = { BoxName + L"\r\n" + FormatString(box_size) + L"字节" ,
		L"4字节" ,FormatString(box_size) ,L"box大小" ,
		L"4字节" , BoxName ,L"box标识",
		L"1字节",FormatString(version),L"版本",
		L"3字节",FormatString(flags),L"标志",
		L"3字节",FormatString(reserved),L"保留",
		L"1字节",FormatString(field_size),L"每个条目的位数",
		L"4字节",FormatString(enter_count),L"条目数",
		FormatString(box_size-20)+L"字节",L"",L""	
	};
	COLORREF BoxColor = RGB(217, 125, 107), c1 = RGB(255, 183, 165), c2 = RGB(220, 80, 80);
	COLORREF pC[25] = { BoxColor,c1,c1,c1,c1,c1,c1, c1,c1,c1,c1,c1,c1,c1,c1,c1,c1, c1,c1 ,c1,c1, c1,c1 ,c1,c2 };
	BYTE pV[25] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,version};
	int index;
	pt = AddInfo(STAR, index, 25, UL, pLen, pID, pItem, pC, pV, pt);
	return pt;
}

CPoint read_stts_box(CFile* pF, CPoint pt)
{
	ULONGLONG STAR = pF->GetPosition();
	UINT box_size = ReadFour(pF);
	CString BoxName = ReadName(pF);
	BYTE version = ReadOne(pF);//版本
	UINT flags = ReadThree(pF);//标志
	UINT entry_count = ReadFour(pF);//条目数
	pF->Seek(entry_count * 8, CFile::current);
	ULONGLONG UL[19] = { STAR ,0,STAR,0,0,STAR + 4,0,0,STAR + 8,0,0,STAR + 9,0,0,STAR + 12, 0,0,STAR + 16, STAR + 16 };
	UINT pLen[19] = { box_size ,0,4,0,0,4,0,0,1,0,0,3,0,0,4,0,0,entry_count * 8,entry_count * 8 };
	CString pID[19] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,TrakType[TrakIndex] + L"stts" };
	CString pItem[19] = { BoxName + L"\r\n" + FormatString(box_size) + L"字节" ,
		L"4字节" ,FormatString(box_size) ,L"box大小" ,
		L"4字节" , BoxName ,L"box标识",
		L"1字节",FormatString(version),L"版本",
		L"3字节",FormatString(flags),L"标志",
		L"4字节",FormatString(entry_count),L"条目数",
		FormatString(entry_count * 8) + L"字节",L"",L""
	};
	COLORREF BoxColor = RGB(135, 135, 103), c1 = RGB(195, 195, 123), c2 = RGB(220, 80, 80);
	COLORREF pC[19] = { BoxColor,c1,c1,c1,c1,c1,c1, c1,c1,c1,c1,c1,c1,c1,c1,c1,c1, c1,c2 };
	BYTE pV[19] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,version };
	int index;
	pt = AddInfo(STAR, index, 19, UL, pLen, pID, pItem, pC, pV, pt);
	return pt;
}

CPoint read_co64_box(CFile* pF, CPoint pt)
{
	ULONGLONG STAR = pF->GetPosition();
	UINT box_size = ReadFour(pF);
	CString BoxName = ReadName(pF);
	BYTE version = ReadOne(pF);//版本
	UINT flags = ReadThree(pF);//标志
	UINT entry_count = ReadFour(pF);//条目数
	pF->Seek(entry_count * 8, CFile::current);
	ULONGLONG UL[19] = { STAR ,0,STAR,0,0,STAR + 4,0,0,STAR + 8,0,0,STAR + 9,0,0,STAR + 12, 0,0,STAR + 16, STAR + 16 };
	UINT pLen[19] = { box_size ,0,4,0,0,4,0,0,1,0,0,3,0,0,4,0,0,entry_count * 8,entry_count * 8 };
	CString pID[19] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,TrakType[TrakIndex] + L"co64" };
	CString pItem[19] = { BoxName + L"\r\n" + FormatString(box_size) + L"字节" ,
		L"4字节" ,FormatString(box_size) ,L"box大小" ,
		L"4字节" , BoxName ,L"box标识",
		L"1字节",FormatString(version),L"版本",
		L"3字节",FormatString(flags),L"标志",
		L"4字节",FormatString(entry_count),L"条目数",
		FormatString(entry_count * 8) + L"字节",L"",L""
	};
	COLORREF BoxColor = RGB(107, 199, 217), c1 = RGB(147, 239, 255), c2 = RGB(220, 80, 80);
	COLORREF pC[19] = { BoxColor,c1,c1,c1,c1,c1,c1, c1,c1,c1,c1,c1,c1,c1,c1,c1,c1, c1,c2 };
	BYTE pV[19] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,version };
	int index;
	pt = AddInfo(STAR, index, 19, UL, pLen, pID, pItem, pC, pV, pt);
	return pt;
}

CPoint read_vmhd_box(CFile* pF, CPoint pt)
{
	ULONGLONG STAR = pF->GetPosition();
	UINT box_size = ReadFour(pF);
	CString BoxName = ReadName(pF);
	BYTE version = ReadOne(pF);//版本
	UINT flags = ReadThree(pF);//标志
	UINT graphics_mode = ReadTwo(pF);//视频合成模式
	UINT R = ReadTwo(pF);//R
	UINT G = ReadTwo(pF);//G
	UINT B = ReadTwo(pF);//B
	CString RGB;
	RGB.Format(L"R=%u G=%u B=%u", R, G, B);
	ULONGLONG UL[19] = { STAR ,0,STAR,0,0,STAR + 4,0,0,STAR + 8,0,0,STAR + 9,0,0,STAR + 12, 0,0,STAR + 14, 0 };
	UINT pLen[19] = { box_size ,0,4,0,0,4,0,0,1,0,0,3,0,0,2,0,0,6,0 };
	CString pID[19] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
	CString pItem[19] = { BoxName + L"\r\n" + FormatString(box_size) + L"字节" ,
		L"4字节" ,FormatString(box_size) ,L"box大小" ,
		L"4字节" , BoxName ,L"box标识",
		L"1字节",FormatString(version),L"版本",
		L"3字节",FormatString(flags),L"标志",
		L"2字节",FormatString(graphics_mode),L"视频合成模式",
		L"6字节",RGB,L"合成使用的颜色"
	};
	COLORREF BoxColor = RGB(142, 168, 174), c1 = RGB(200, 210, 220);
	COLORREF pC[19] = { BoxColor,c1,c1,c1,c1,c1,c1, c1,c1,c1,c1,c1,c1,c1,c1,c1,c1, c1,c1 };
	BYTE pV[19] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
	int index;
	pt = AddInfo(STAR, index, 19, UL, pLen, pID, pItem, pC, pV, pt);
	return pt;
}

CPoint  read_smhd_box(CFile* pF, CPoint pt)
{
	ULONGLONG STAR = pF->GetPosition();
	UINT box_size = ReadFour(pF);
	CString BoxName = ReadName(pF);
	BYTE version = ReadOne(pF);//版本
	UINT flags = ReadThree(pF);//标志
	WORD balance = ReadTwo(pF);//立体声平衡
	WORD Reserve= ReadTwo(pF);//保留
	ULONGLONG UL[19] = { STAR ,0,STAR,0,0,STAR + 4,0,0,STAR + 8,0,0,STAR + 9,0,0,STAR + 12, 0,0,STAR + 14, 0 };
	UINT pLen[19] = { box_size ,0,4,0,0,4,0,0,1,0,0,3,0,0,2,0,0,2,0 };
	CString pID[19] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
	CString pItem[19] = { BoxName + L"\r\n" + FormatString(box_size) + L"字节" ,
		L"4字节" ,FormatString(box_size) ,L"box大小" ,
		L"4字节" , BoxName ,L"box标识",
		L"1字节",FormatString(version),L"版本",
		L"3字节",FormatString(flags),L"标志",
		L"2字节",FormatString(balance),L"立体声平衡",
		L"2字节",FormatString(Reserve),L"保留"
	};
	COLORREF BoxColor = RGB(217, 125, 107), c1 = RGB(255, 183, 165);
	COLORREF pC[19] = { BoxColor,c1,c1,c1,c1,c1,c1, c1,c1,c1,c1,c1,c1,c1,c1,c1,c1, c1,c1 };
	BYTE pV[19] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
	int index;
	pt = AddInfo(STAR, index, 19, UL, pLen, pID, pItem, pC, pV, pt);
	return pt;
}

CPoint read_dinf_box(CFile* pF, CPoint pt)
{
	ULONGLONG STAR = pF->GetPosition();
	UINT box_size = ReadFour(pF);
	CString BoxName = ReadName(pF);
	ULONGLONG UL[7] = { STAR ,0,STAR,0,0,STAR + 4,0 };
	UINT pLen[7] = { box_size ,0,4,0,0,4,0 };
	CString pID[7] = { 0,0,0,0,0,0,0 };
	CString pItem[7] = { BoxName + L"\r\n" + FormatString(box_size) + L"字节" ,
		L"4字节" ,FormatString(box_size) ,L"box大小" ,
		L"4字节" , BoxName ,L"box标识"
	};
	COLORREF BoxColor = RGB(174, 156, 142), c1 = RGB(216, 198, 184);
	COLORREF pC[7] = { BoxColor,c1,c1,c1,c1,c1,c1 };
	BYTE pV[7] = { 0,0,0,0,0,0,0 };
	int index;
	pt = AddInfo(STAR, index, 7, UL, pLen, pID, pItem, pC, pV, pt);
	pt.Offset(120, 0);
	pt = read_dref_box(pF, pt);
	INFO* pBox = (INFO*)ar.GetAt(index);
	pBox->rect.bottom = pt.y;
	pt.Offset(-120, 0);
	return pt;
}

CPoint read_dref_box(CFile* pF, CPoint pt)
{
	ULONGLONG STAR = pF->GetPosition();
	UINT box_size = ReadFour(pF);
	CString BoxName = ReadName(pF);
	BYTE version = ReadOne(pF);//版本
	UINT flags = ReadThree(pF);//标志
	UINT entry_count = ReadFour(pF);//条目数
	ULONGLONG UL[16] = { STAR ,0,STAR,0,0,STAR + 4,0,0,STAR + 8,0,0,STAR + 9,0,0,STAR + 12, 0 };
	UINT pLen[16] = { box_size ,0,4,0,0,4,0,0,1,0,0,3,0,0,4,0 };
	CString pID[16] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
	CString pItem[16] = { BoxName + L"\r\n" + FormatString(box_size) + L"字节" ,
		L"4字节" ,FormatString(box_size) ,L"box大小" ,
		L"4字节" , BoxName ,L"box标识",
		L"1字节",FormatString(version),L"版本",
		L"3字节",FormatString(flags),L"标志",
		L"4字节",FormatString(entry_count),L"条目数"
	};
	COLORREF BoxColor = RGB(174, 142, 164), c1 = RGB(216, 184, 206);
	COLORREF pC[16] = { BoxColor,c1,c1,c1,c1,c1,c1, c1,c1,c1,c1,c1,c1,c1,c1,c1 };
	BYTE pV[16] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
	int index;
	pt = AddInfo(STAR, index, 16, UL, pLen, pID, pItem, pC, pV, pt);
	pt.Offset(120, 0);//右移
	for (UINT i = 0; i < entry_count; i++)
	{
		pt = read_X2_box(pF, pt);
	}
	pt.Offset(-120, 0);//左移
	INFO* pBox = (INFO*)ar.GetAt(index);
	pBox->rect.bottom = pt.y;
	return pt;
}

CPoint read_tkhd_box(CFile* pF, CPoint pt)
{
	ULONGLONG STAR = pF->GetPosition();
	UINT box_size = ReadFour(pF);
	CString BoxName = ReadName(pF);
	BYTE version = ReadOne(pF);//版本
	UINT flags = ReadThree(pF);//标志
	ULONGLONG creation_time;
	ULONGLONG modification_time;
	UINT track_id;
	UINT reserve;
	ULONGLONG duration;
	if (version == 1)
	{
		UINT u1 = ReadFour(pF);UINT u2 = ReadFour(pF);
		creation_time = ((ULONGLONG)u1 << 32) + u2;//创建时间
		u1 = ReadFour(pF);u2 = ReadFour(pF);
		modification_time = ((ULONGLONG)u1 << 32) + u2;//修改时间
		track_id = ReadFour(pF);//轨道标识
		reserve = ReadFour(pF);//保留
		u1 = ReadFour(pF);u2 = ReadFour(pF);
		duration = ((ULONGLONG)u1 << 32) + u2;//轨道的时间长度
	}
	else//version==0 
	{
		creation_time = ReadFour(pF);//创建时间
		modification_time = ReadFour(pF);//修改时间
		track_id = ReadFour(pF);//轨道标识
		reserve = ReadFour(pF);//保留
		duration = ReadFour(pF);//轨道的时间长度
	}
	BYTE Reserve[8];
	pF->Read(Reserve, 8);//保留
	WORD layer = ReadTwo(pF);//视频层,0为顶层
	WORD alternate_group = ReadTwo(pF);//分组信息
	WORD volume = ReadTwo(pF);//音量
	BYTE Reserve2[2];
	pF->Read(Reserve2, 2);//保留
	BYTE matrix[36];
	pF->Read(matrix, 36);//视频变换矩阵
	CString width_str, height_str;
	WORD hi = ReadTwo(pF);WORD lo = ReadTwo(pF);//视频宽度
	width_str.Format(L"%d.%d", hi, lo);
	hi = ReadTwo(pF);lo = ReadTwo(pF);//视频高度
	height_str.Format(L"%d.%d", hi, lo);

	CString text10, text14, text15;
	text10.Format(L"{%d,%d,%d,%d,%d,%d,%d,%d}", Reserve[0], Reserve[1], Reserve[2], Reserve[3], Reserve[4], Reserve[5], Reserve[6], Reserve[7]);
	text14.Format(L"{%d,%d}", Reserve2[0], Reserve2[1]);
	text15 = L"{";
	for (int i = 0; i < 36; i++)
	{
		CString str;
		if (i < 35)
			str.Format(L"%d,", matrix[i]);
		else
			str.Format(L"%d}", matrix[i]);
		text15 += str;
	}
	int index;
	if (version == 0)
	{
		ULONGLONG UL[52] = { STAR ,0,STAR,0,0,STAR + 4,0,0,STAR + 8,0,0,STAR + 9,0,0,STAR + 12, 0,0,STAR + 16, 0,0, STAR+20,0,0,STAR+24,0,0,STAR+28,0,0,STAR+32,0,0,
			STAR+40,0,0,STAR+42,0,0,STAR+44,0,0,STAR+46,0,0,STAR+48,0,0,STAR+84,0,0,STAR+88,0};
		UINT pLen[52] = { box_size ,0,4,0,0,4,0,0,1,0,0,3,0,0,4,0,0,4,0,0,4,0,0,4,0,0,4,0,0, 8,0,0,2,0,0,2,0,0,2,0,0,2,0,0,36,0,0,4,0,0,4,0};
		CString pID[52] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
		CString pItem[52] = { BoxName + L"\r\n" + FormatString(box_size) + L"字节" ,
			L"4字节" ,FormatString(box_size) ,L"box大小" ,
			L"4字节" , BoxName ,L"box标识",
			L"1字节",FormatString(version),L"版本",
			L"3字节",FormatString(flags),L"标志",
			L"4字节",FormatString(creation_time),L"创建时间",
			L"4字节",FormatString(modification_time),L"修改时间",
			L"4字节",FormatString(track_id),L"轨道标识",
			L"4字节",FormatString(reserve),L"保留",
			L"4字节",FormatString(duration),L"轨道的时间长度",
			L"8字节",text10,L"保留",
			L"2字节",FormatString(layer),L"视频层",
			L"2字节",FormatString(alternate_group),L"分组信息",
			L"2字节",FormatString(volume),L"音量",
			L"2字节",text14,L"保留",
			L"36字节",text15,L"视频变换矩阵",
			L"4字节",width_str,L"视频宽度",
			L"4字节",height_str,L"视频高度"
		};
		COLORREF BoxColor = RGB(110, 201, 244), c1 = RGB(147, 238, 255);
		COLORREF pC[52] = { BoxColor,c1,c1,c1,c1,c1,c1, c1,c1,c1,c1,c1,c1,c1,c1,c1,c1, c1,c1,c1,c1, c1,c1,c1,c1,c1,c1,c1,c1,c1,c1, c1,c1 ,c1,c1, c1,c1,c1,c1,c1,c1,c1,c1,c1,c1, c1,c1 ,c1,c1, c1,c1,c1};
		BYTE pV[52] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
		pt = AddInfo(STAR, index, 52, UL, pLen, pID, pItem, pC, pV, pt);
	}
	else
	{
		ULONGLONG UL[52] = { STAR ,0,STAR,0,0,STAR + 4,0,0,STAR + 8,0,0,STAR + 9,0,0,STAR + 12, 0,0,STAR + 20, 0,0, STAR + 28,0,0,STAR + 32,0,0,STAR + 36,0,0,STAR + 44,0,0,
			STAR + 52,0,0,STAR + 54,0,0,STAR + 56,0,0,STAR + 58,0,0,STAR + 60,0,0,STAR + 96,0,0,STAR + 100,0 };
		UINT pLen[52] = { box_size ,0,4,0,0,4,0,0,1,0,0,3,0,0,8,0,0,8,0,0,4,0,0,4,0,0,8,0,0, 8,0,0,2,0,0,2,0,0,2,0,0,2,0,0,36,0,0,4,0,0,4,0 };
		CString pID[52] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
		CString pItem[52] = { BoxName + L"\r\n" + FormatString(box_size) + L"字节" ,
			L"4字节" ,FormatString(box_size) ,L"box大小" ,
			L"4字节" , BoxName ,L"box标识",
			L"1字节",FormatString(version),L"版本",
			L"3字节",FormatString(flags),L"标志",
			L"8字节",FormatString(creation_time),L"创建时间",
			L"8字节",FormatString(modification_time),L"修改时间",
			L"4字节",FormatString(track_id),L"轨道标识",
			L"4字节",FormatString(reserve),L"保留",
			L"8字节",FormatString(duration),L"轨道的时间长度",
			L"8字节",text10,L"保留",
			L"2字节",FormatString(layer),L"视频层",
			L"2字节",FormatString(alternate_group),L"分组信息",
			L"2字节",FormatString(volume),L"音量",
			L"2字节",text14,L"保留",
			L"36字节",text15,L"视频变换矩阵",
			L"4字节",width_str,L"视频宽度",
			L"4字节",height_str,L"视频高度"
		};
		COLORREF BoxColor = RGB(110, 201, 244), c1 = RGB(147, 238, 255);
		COLORREF pC[52] = { BoxColor,c1,c1,c1,c1,c1,c1, c1,c1,c1,c1,c1,c1,c1,c1,c1,c1, c1,c1,c1,c1, c1,c1,c1,c1,c1,c1,c1,c1,c1,c1, c1,c1 ,c1,c1, c1,c1,c1,c1,c1,c1,c1,c1,c1,c1, c1,c1 ,c1,c1, c1,c1,c1 };
		BYTE pV[52] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
		pt = AddInfo(STAR, index, 52, UL, pLen, pID, pItem, pC, pV, pt);
	}
	INFO* pBox = (INFO*)ar.GetAt(index);
	pBox->rect.bottom = pt.y;
	return pt;
}

CPoint read_udta_box(CFile* pF, CPoint pt)
{
	pt = read_X_box(pF, pt);
	return pt;
}

CPoint read_mdat_box(CFile* pF, CPoint pt)
{
	ULONGLONG STAR = pF->GetPosition();
	UINT box_size = ReadFour(pF);
	CString BoxName = ReadName(pF);
	ULONGLONG BOX_SIZE;
	if (box_size == 1)
	{
		ULONGLONG size1 = ReadFour(pF);UINT size2 = ReadFour(pF);
		BOX_SIZE = (size1 << 32) + size2;
		pF->Seek(BOX_SIZE - 16, CFile::current);
	}
	else if (box_size==0)
	{
		BOX_SIZE = pF->GetLength() - STAR;
		pF->Seek(BOX_SIZE - 8, CFile::current);
	}
	else
	{
		BOX_SIZE = box_size;
		pF->Seek(BOX_SIZE - 8, CFile::current);
	}
	int index;
	if (box_size == 1)
	{
		ULONGLONG UL[13] = { STAR ,0,STAR,0,0,STAR + 4,0,0,STAR + 8,0,0,STAR+16,0 };
		UINT pLen[13] = { 0 ,0,4,0,0,4,0,0, 8,0,0,0 ,0 };
		CString pID[13] = { 0,0,0,0,0,0,0,0,0,0,0,0,0 };
		CString pItem[13] = { BoxName + L"\r\n" + FormatString(BOX_SIZE) + L"字节" ,
			L"4字节" ,L"1" ,L"box大小" ,
			L"4字节" , BoxName ,L"box标识",
			L"8字节",FormatString(BOX_SIZE),L"扩展box大小",
			FormatString(BOX_SIZE - 16) + L"字节",L"",L""
		};
		COLORREF BoxColor = RGB(243, 203, 118), c1 = RGB(244, 233, 209);
		COLORREF pC[13] = { BoxColor,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1 };
		BYTE pV[13] = { 0,0,0,0,0,0,0,0,0,0,0,0,0 };
		pt = AddInfo(STAR, index, 13, UL, pLen, pID, pItem, pC, pV, pt);
	}
	else
	{
		ULONGLONG UL[10] = { STAR ,0,STAR,0,0,STAR + 4,0,0,STAR+8,0 };
		UINT pLen[10] = { 0 ,0,4,0,0,4,0,0, 0 ,0};
		CString pID[10] = { 0,0,0,0,0,0,0,0,0,0 };
		CString pItem[10] = { BoxName + L"\r\n" + FormatString(BOX_SIZE) + L"字节" ,
			L"4字节" ,FormatString(box_size) ,L"box大小" ,
			L"4字节" , BoxName ,L"box标识",
			FormatString(BOX_SIZE - 8) + L"字节",L"",L""
		};
		COLORREF BoxColor = RGB(243, 203, 118), c1 = RGB(244, 233, 209);
		COLORREF pC[10] = { BoxColor,c1,c1,c1,c1,c1,c1,c1,c1,c1};
		BYTE pV[10] = { 0,0,0,0,0,0,0,0,0,0 };
		pt = AddInfo(STAR, index, 10, UL, pLen, pID, pItem, pC, pV, pt);
	}
	INFO* pBox = (INFO*)ar.GetAt(index);
	pBox->rect.bottom = pt.y;
	return pt;
}

CPoint read_X_box(CFile* pF, CPoint pt)
{
	ULONGLONG STAR = pF->GetPosition();
	UINT box_size = ReadFour(pF);
	CString BoxName = ReadName(pF);
	ULONGLONG BOX_SIZE;
	if (box_size == 1)
	{
		ULONGLONG size1 = ReadFour(pF); UINT size2 = ReadFour(pF);
		BOX_SIZE = (size1 << 32) + size2;
		pF->Seek(BOX_SIZE - 16, CFile::current);
	}
	else if (box_size == 0)
	{
		BOX_SIZE = (UINT)(pF->GetLength() - STAR);//box大小为0时,为最后一个box
		pF->Seek(BOX_SIZE - 8, CFile::current);
	}
	else
	{
		BOX_SIZE = box_size;
		pF->Seek(BOX_SIZE - 8, CFile::current);
	}
	int index;
	if (box_size == 8)
	{
		ULONGLONG UL[7] = { STAR ,0,STAR,0,0,STAR + 4,0 };
		UINT pLen[7] = { box_size ,0,4,0,0,4,0 };
		CString pID[7] = { 0,0,0,0,0,0,0 };
		CString pItem[7] = { BoxName + L"\r\n" + FormatString(box_size) + L"字节" ,
			L"4字节" ,FormatString(box_size) ,L"box大小" ,
			L"4字节" , BoxName ,L"box标识"
		};
		COLORREF BoxColor = RGB(222, 152, 118), c1 = RGB(255, 201, 167);
		COLORREF pC[7] = { BoxColor,c1,c1,c1,c1,c1,c1 };
		BYTE pV[7] = { 0,0,0,0,0,0,0 };
		pt = AddInfo(STAR, index, 7, UL, pLen, pID, pItem, pC, pV, pt);
	}
	else
	{
		if (box_size == 1)
		{
			ULONGLONG UL[13] = { STAR ,0,STAR,0,0,STAR + 4,0,0,STAR + 8,0,0,STAR+16,0 };
			UINT pLen[13] = { 0 ,0,4,0,0,4,0,0, 8,0,0,0,0 };
			CString pID[13] = { 0,0,0,0,0,0,0,0,0,0,0,0,0};
			CString pItem[13] = { BoxName + L"\r\n" + FormatString(BOX_SIZE) + L"字节" ,
				L"4字节" ,FormatString(box_size) ,L"box大小" ,
				L"4字节" , BoxName ,L"box标识",
				L"8字节",FormatString(BOX_SIZE),L"扩展box大小",
				FormatString(BOX_SIZE - 16) + L"字节",FormatString(BOX_SIZE - 16),L""
			};
			COLORREF BoxColor = RGB(222, 152, 118), c1 = RGB(255, 201, 167);
			COLORREF pC[13] = { BoxColor,c1,c1,c1,c1,c1,c1,c1,c1,c1 ,c1,c1,c1};
			BYTE pV[13] = { 0,0,0,0,0,0,0,0,0,0,0,0,0 };
			pt = AddInfo(STAR, index, 13, UL, pLen, pID, pItem, pC, pV, pt);
		}
		else
		{
			ULONGLONG UL[10] = { STAR ,0,STAR,0,0,STAR + 4,0,0,STAR + 8,0 };
			UINT pLen[10] = { (UINT)BOX_SIZE ,0,4,0,0,4,0,0, (UINT)BOX_SIZE - 8 ,0 };
			CString pID[10] = { 0,0,0,0,0,0,0,0,0,0 };
			CString pItem[10] = { BoxName + L"\r\n" + FormatString(box_size) + L"字节" ,
				L"4字节" ,FormatString(box_size) ,L"box大小" ,
				L"4字节" , BoxName ,L"box标识",
				FormatString(BOX_SIZE - 8) + L"字节",L"",L""
			};
			COLORREF BoxColor = RGB(222, 152, 118), c1 = RGB(255, 201, 167);
			COLORREF pC[10] = { BoxColor,c1,c1,c1,c1,c1,c1,c1,c1,c1 };
			BYTE pV[10] = { 0,0,0,0,0,0,0,0,0,0 };
			pt = AddInfo(STAR, index, 10, UL, pLen, pID, pItem, pC, pV, pt);
		}
	}
	INFO* pBox = (INFO*)ar.GetAt(index);
	pBox->rect.bottom = pt.y;
	return pt;
}

CPoint read_X2_box(CFile* pF, CPoint pt)
{
	ULONGLONG STAR = pF->GetPosition();
	UINT Xbox_size = ReadFour(pF);
	CString XBoxName = ReadName(pF);
	BYTE* p = new BYTE[Xbox_size - 8];
	pF->Read(p, Xbox_size - 8);
	CString str;
	for (UINT i = 0; i < Xbox_size - 8; i++)
	{
		CString s; s.Format(L"%0*X ", 2, p[i]); str += s;
	}
	delete[] p;
	ULONGLONG UL[10] = { STAR ,0,STAR,0,0,STAR + 4,0,0,STAR + 8,0 };
	UINT pLen[10] = { Xbox_size ,0,4,0,0,4,0,0, Xbox_size - 8 ,0 };
	CString pID[10] = { 0,0,0,0,0,0,0,0,0,0 };
	CString pItem[10] = { XBoxName + L"\r\n" + FormatString(Xbox_size) + L"字节" ,
		L"4字节" ,FormatString(Xbox_size) ,L"box大小" ,
		L"4字节" , XBoxName ,L"box标识",
		FormatString(Xbox_size - 8) + L"字节",str,L""
	};
	COLORREF BoxColor = RGB(222, 152, 118), c1 = RGB(255, 201, 167);
	COLORREF pC[10] = { BoxColor,c1,c1,c1,c1,c1,c1,c1,c1,c1 };
	BYTE pV[10] = { 0,0,0,0,0,0,0,0,0,0 };
	int index;
	pt = AddInfo(STAR, index, 10, UL, pLen, pID, pItem, pC, pV, pt);
	INFO* pBox = (INFO*)ar.GetAt(index);
	pBox->rect.bottom = pt.y;
	return pt;
}

CPoint AddInfo(ULONGLONG STAR, int& index, int Count, ULONGLONG* pUL, UINT* pLen, CString* pID, CString* pItem, COLORREF* pColor, BYTE* pV, CPoint pt)
{
	C解析MP4Dlg* pDlg = (C解析MP4Dlg*)theApp.m_pMainWnd;
	CObArray OAry; OAry.SetSize(Count);
	for (int i = 0; i < Count; i++)
	{
		INFO* info = new INFO();
		info->uPos = pUL[i]; info->len = pLen[i]; info->ID = pID[i]; info->item = pItem[i]; info->color = pColor[i]; info->version = pV[i];
		OAry.SetAt(i, (CObject*)info);
	}
	CRect S(0, 0, 121, 14);
	CPoint point = pt;
	INFO* pBox = (INFO*)OAry.GetAt(0);
	pBox->rect.CopyRect(S); pBox->rect.MoveToXY(pt.x - 1, pt.y - 1);
	int CountN = (OAry.GetCount() - 1) / 3;
	for (int i = 0; i < CountN; i++)
	{
		INFO* pS = (INFO*)OAry.GetAt(i * 3 + 1);
		pS->rect.CopyRect(S); pS->rect.MoveToXY(pt.x - 1 + S.Width() - 1, pt.y - 1);
		INFO* pD = (INFO*)OAry.GetAt(i * 3 + 2);
		INFO* pE = (INFO*)OAry.GetAt(i * 3 + 3);
		CDC* pDC = pDlg->dlg2.GetDC();
		pDC->SelectObject(&pDlg->dlg2.font1);
		CSize Dsz = pDC->GetTextExtent(pD->item);
		int D_item_width = Dsz.cx + 10;
		CSize Esz = pDC->GetTextExtent(pE->item);
		int E_item_width = Esz.cx + 10;
		pDlg->dlg2.ReleaseDC(pDC);
		pD->rect.CopyRect(S); pE->rect.CopyRect(S);
		if (D_item_width <= 121)
		{
			pD->rect.MoveToXY(pt.x - 1 + (S.Width() - 1) * 2, pt.y - 1);
			pE->rect.MoveToXY(pD->rect.right - 1, pD->rect.top);
			if (E_item_width > 121)
			{
				pE->rect.right = pE->rect.left + E_item_width;
			}
		}
		else
		{
			pD->rect.MoveToXY(pt.x - 1 + (S.Width() - 1) * 2, pt.y - 1); pD->rect.right = pD->rect.left + D_item_width;
			pE->rect.MoveToXY(pD->rect.right - 1, pD->rect.top);
			if (E_item_width > 121)
			{
				pE->rect.right = pE->rect.left + E_item_width;
			}
		}
		ar.Add((CObArray*)pS); ar.Add((CObArray*)pD); ar.Add((CObArray*)pE);
		LineRight = max(LineRight, pE->rect.right);
		pt.Offset(0, S.Height() - 1);//下移
	}
	pBox->rect.bottom = pt.y;
	index = ar.Add((CObArray*)pBox);
	AddLine(point, STAR);
	return pt;
}

CPoint AppendInfo(int Count, ULONGLONG* pUL, UINT* pLen, CString* pID, CString* pItem, COLORREF* pColor, CPoint pt)
{
	C解析MP4Dlg* pDlg = (C解析MP4Dlg*)theApp.m_pMainWnd;
	CObArray OAry; OAry.SetSize(Count);
	for (int i = 0; i < Count; i++)
	{
		INFO* info = new INFO();
		info->uPos = pUL[i]; info->len = pLen[i]; info->ID = pID[i]; info->item = pItem[i]; info->color = pColor[i];
		OAry.SetAt(i, (CObject*)info);
	}
	CRect S(0, 0, 121, 14);
	int MaxRight = 0;
	CPoint point = pt;
	int CountN = OAry.GetCount() / 3;
	for (int i = 0; i < CountN; i++)
	{
		INFO* pS = (INFO*)OAry.GetAt(i * 3);
		pS->rect.CopyRect(S); pS->rect.MoveToXY(pt.x - 1 + S.Width() - 1, pt.y - 1);
		INFO* pD = (INFO*)OAry.GetAt(i * 3 + 1);
		INFO* pE = (INFO*)OAry.GetAt(i * 3 + 2);
		CDC* pDC = pDlg->dlg2.GetDC();
		pDC->SelectObject(&pDlg->dlg2.font1);
		CSize Dsz = pDC->GetTextExtent(pD->item);
		int D_item_width = Dsz.cx + 10;
		CSize Esz = pDC->GetTextExtent(pE->item);
		int E_item_width = Esz.cx + 10;
		pDlg->dlg2.ReleaseDC(pDC);
		pD->rect.CopyRect(S); pE->rect.CopyRect(S);
		if (D_item_width <= 121)
		{
			pD->rect.MoveToXY(pt.x - 1 + (S.Width() - 1) * 2, pt.y - 1);
			pE->rect.MoveToXY(pD->rect.right - 1, pD->rect.top);
			if (E_item_width > 121)
			{
				pE->rect.right = pE->rect.left + E_item_width;
			}
		}
		else
		{
			pD->rect.MoveToXY(pt.x - 1 + (S.Width() - 1) * 2, pt.y - 1); pD->rect.right = pD->rect.left + D_item_width;
			pE->rect.MoveToXY(pD->rect.right - 1, pD->rect.top);
			if (E_item_width > 121)
			{
				pE->rect.right = pE->rect.left + E_item_width;
			}
		}
		ar.Add((CObArray*)pS); ar.Add((CObArray*)pD); ar.Add((CObArray*)pE);
		MaxRight = max(MaxRight, pE->rect.right);
		pt.Offset(0, S.Height() - 1);//下移
	}
	return pt;
}

CString FormatString(ULONGLONG ull)//加入分隔符","
{
	CString out;
	out.Format(L"%I64u", ull);
	int len = out.GetLength();
	int nu = (len - 1) / 3;
	for (int i = 0; i < nu; i++)
	{
		out.Insert(len - (i + 1) * 3, L',');
	}
	return out;
}

BYTE ReadOne(CFile* pF)
{
	BYTE mby1;
	pF->Read(&mby1, 1);
	return mby1;
}

WORD ReadTwo(CFile* pF)
{
	BYTE mby1, mby2;
	pF->Read(&mby1, 1); pF->Read(&mby2, 1);
	WORD size = mby1 * 256 + mby2;
	return size;
}

UINT ReadThree(CFile* pF)
{
	BYTE mby1, mby2, mby3;
	pF->Read(&mby1, 1); pF->Read(&mby2, 1); pF->Read(&mby3, 1);
	UINT size = mby1 * 256 * 256 + mby2 * 256 + mby3;
	return size;
}

UINT ReadFour(CFile* pF)
{
	BYTE mby1, mby2, mby3, mby4;
	pF->Read(&mby1, 1); pF->Read(&mby2, 1); pF->Read(&mby3, 1); pF->Read(&mby4, 1);
	UINT size= mby1 * 256 * 256 * 256 + mby2 * 256 * 256 + mby3 * 256 + mby4;
	return size;
}

CString ReadName(CFile* pF)
{
	char ch[5]; ch[4] = 0;
	pF->Read(ch, 4);
	return (CString)ch;
}

void AddLine(CPoint pt, ULONGLONG POS)
{
	LINE* pLine = new LINE();
	pLine->star = CPoint(pt.x, pt.y-1);
	pLine->end = CPoint(0, pt.y-1);
	pLine->pos = FormatString(POS) + L"字节";
	arLine.Add((CObArray*)pLine);
}


#pragma once


// CDlg1 对话框

class CDlg1 : public CDialogEx
{
	DECLARE_DYNAMIC(CDlg1)

public:
	CDlg1(CWnd* pParent = NULL);   // 标准构造函数
	virtual ~CDlg1();

// 对话框数据
#ifdef AFX_DESIGN_TIME
	enum { IDD = IDD_DIALOG1 };
#endif

protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV 支持

	DECLARE_MESSAGE_MAP()
public:
	afx_msg void OnBnClickedOk();
	afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
	afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
	virtual BOOL OnInitDialog();
};

// Dlg1.cpp : 实现文件
//

#include "stdafx.h"
#include "解析MP4.h"
#include "Dlg1.h"
#include "afxdialogex.h"
#include "解析MP4Dlg.h"

// CDlg1 对话框

IMPLEMENT_DYNAMIC(CDlg1, CDialogEx)

CDlg1::CDlg1(CWnd* pParent /*=NULL*/)
	: CDialogEx(IDD_DIALOG1, pParent)
{

}

CDlg1::~CDlg1()
{
}

void CDlg1::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
}


BEGIN_MESSAGE_MAP(CDlg1, CDialogEx)
	ON_BN_CLICKED(IDOK, &CDlg1::OnBnClickedOk)
	ON_WM_HSCROLL()
	ON_WM_VSCROLL()
END_MESSAGE_MAP()

void CDlg1::OnBnClickedOk()
{
}


void CDlg1::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
	C解析MP4Dlg* pDlg = (C解析MP4Dlg*)theApp.m_pMainWnd;
	int Min, Max;
	GetScrollRange(SB_HORZ, &Min, &Max);
	int pos;
	CRect rect; pDlg->dlg2.GetWindowRect(rect); ScreenToClient(rect);
	switch (nSBCode)
	{
	case SB_LINELEFT:    	//向左滚动行
		pos = GetScrollPos(SB_HORZ) - 20;
		if (pos < Min)pos = Min;
		SetScrollPos(SB_HORZ, pos);
		pDlg->dlg2.MoveWindow(pos, rect.top, rect.Width(), rect.Height());
		break;
	case SB_LINERIGHT:    	//向右滚动行
		pos = GetScrollPos(SB_HORZ) + 20;
		if (pos > Max)pos = Max;
		SetScrollPos(SB_HORZ, pos);
		pDlg->dlg2.MoveWindow(-pos, rect.top, rect.Width(), rect.Height());
		break;
	case SB_PAGELEFT:    	//向左滚动页
		pos = GetScrollPos(SB_HORZ) - 100;
		if (pos < Min)pos = Min;
		SetScrollPos(SB_HORZ, pos);
		pDlg->dlg2.MoveWindow(pos, rect.top, rect.Width(), rect.Height());
		break;
	case SB_PAGERIGHT:     	//向右滚动页
		pos = GetScrollPos(SB_HORZ) + 100;
		if (pos > Min)pos = Min;
		SetScrollPos(SB_HORZ, pos);
		pDlg->dlg2.MoveWindow(-pos, rect.top, rect.Width(), rect.Height());
		break;
	case SB_THUMBTRACK:          	//拖动滑块
		SetScrollPos(SB_HORZ, nPos);
		pos = nPos;
		pDlg->dlg2.MoveWindow(-pos, rect.top, rect.Width(), rect.Height());
		break;
	}
	CDialogEx::OnHScroll(nSBCode, nPos, pScrollBar);
}


void CDlg1::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
	C解析MP4Dlg* pDlg = (C解析MP4Dlg*)theApp.m_pMainWnd;
	int Min, Max;
	GetScrollRange(SB_VERT, &Min, &Max);
	int pos;
	CRect rect; pDlg->dlg2.GetWindowRect(rect); ScreenToClient(rect);
	switch (nSBCode)
	{
	case SB_LINEDOWN:        	//向下滚动行
		pos = GetScrollPos(SB_VERT) + 20;
		if (pos > Max)pos = Max;
		SetScrollPos(SB_VERT, pos);
		pDlg->dlg2.MoveWindow(rect.left, -pos, rect.Width(), rect.Height());
		break;
	case SB_LINEUP:           		//向上滚动行
		pos = GetScrollPos(SB_VERT) - 20;
		if (pos < Min)pos = Min;
		SetScrollPos(SB_VERT, pos);
		pDlg->dlg2.MoveWindow(rect.left, -pos, rect.Width(), rect.Height());
		break;
	case  SB_PAGEDOWN:      	 //向下滚动页
		pos = GetScrollPos(SB_VERT) + 100;
		if (pos > Max)pos = Max;
		SetScrollPos(SB_VERT, pos);
		pDlg->dlg2.MoveWindow(rect.left, -pos, rect.Width(), rect.Height());
		break;
	case SB_PAGEUP:          		//向上滚动页
		pos = GetScrollPos(SB_VERT) - 100;
		if (pos < Min)pos = Min;
		SetScrollPos(SB_VERT, pos);
		pDlg->dlg2.MoveWindow(rect.left, -pos, rect.Width(), rect.Height());
		break;
	case SB_THUMBTRACK:   //拖动滑块
		SetScrollPos(SB_VERT, nPos);
		pos = nPos;
		pDlg->dlg2.MoveWindow(rect.left, -pos, rect.Width(), rect.Height());
		break;
	}
	CDialogEx::OnVScroll(nSBCode, nPos, pScrollBar);
}


BOOL CDlg1::OnInitDialog()
{
	CDialogEx::OnInitDialog();
	SetBackgroundColor(RGB(255, 193, 132));
	return TRUE; 
}

#pragma once
#include "Dlg3.h"
#include "Dlg4.h"
// CDlg2 对话框

class CDlg2 : public CDialogEx
{
	DECLARE_DYNAMIC(CDlg2)

public:
	CDlg2(CWnd* pParent = NULL);   // 标准构造函数
	virtual ~CDlg2();

// 对话框数据
#ifdef AFX_DESIGN_TIME
	enum { IDD = IDD_DIALOG2 };
#endif

protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV 支持

	DECLARE_MESSAGE_MAP()
public:
	afx_msg void OnBnClickedOk();
	CDlg3 dlg3;
	CDlg4 dlg4;
	CFont font1;
	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
	virtual BOOL PreTranslateMessage(MSG* pMsg);
	virtual BOOL OnInitDialog();
	afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
	void DeleteAllColumn();
};

// Dlg2.cpp : 实现文件
//

#include "stdafx.h"
#include "解析MP4.h"
#include "Dlg2.h"
#include "afxdialogex.h"
#include "解析MP4Dlg.h"

extern CObArray ar;
extern CObArray arLine;
extern int LineRight;

IMPLEMENT_DYNAMIC(CDlg2, CDialogEx)

CDlg2::CDlg2(CWnd* pParent /*=NULL*/)
	: CDialogEx(IDD_DIALOG2, pParent)
{
	font1.CreatePointFont(80, L"微软雅黑");
}

CDlg2::~CDlg2()
{
}

void CDlg2::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
}


BEGIN_MESSAGE_MAP(CDlg2, CDialogEx)
	ON_BN_CLICKED(IDOK, &CDlg2::OnBnClickedOk)
	ON_WM_ERASEBKGND()
	ON_WM_CREATE()
	ON_WM_LBUTTONDBLCLK()
END_MESSAGE_MAP()

void CDlg2::OnBnClickedOk()
{
}


BOOL CDlg2::OnEraseBkgnd(CDC* pDC)
{
	C解析MP4Dlg* pDlg = (C解析MP4Dlg*)theApp.m_pMainWnd;
	CRect rect;
	GetClientRect(rect);
	pDC->FillSolidRect(rect, RGB(255, 193, 132));
	pDC->SelectObject(&font1);
	int Count = ar.GetCount();
	for (int i = 0; i < Count; i++)
	{
		INFO* pInfo = (INFO*)ar.GetAt(i);
		pDC->FillSolidRect(pInfo->rect, pInfo->color);
		pDC->DrawText(pInfo->item, pInfo->rect, DT_CENTER);
		pDC->FrameRect(pInfo->rect, &CBrush(RGB(0, 0, 0)));
	}
	pDC->SetBkMode(TRANSPARENT);
	int LineCount = arLine.GetCount();
	for (int i = 0; i < LineCount; i++)
	{
		LINE* pLine = (LINE*)arLine.GetAt(i);
		pDC->MoveTo(pLine->star);
		CPoint end; end.x = LineRight; end.y = pLine->end.y;
		pDC->LineTo(end);
		pDC->TextOut(end.x + 2, end.y - 7, pLine->pos);
	}
	return TRUE;
	//	return CDialogEx::OnEraseBkgnd(pDC);
}

int CDlg2::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CDialogEx::OnCreate(lpCreateStruct) == -1)
		return -1;
	dlg3.Create(IDD_DIALOG3, NULL);
	return 0;
}


BOOL CDlg2::PreTranslateMessage(MSG* pMsg)
{
	return CDialogEx::PreTranslateMessage(pMsg);
}


BOOL CDlg2::OnInitDialog()
{
	CDialogEx::OnInitDialog();
	return TRUE;
}

UINT ThreadStts(LPVOID pParam);
UINT ThreadStss(LPVOID pParam);
UINT ThreadStsc(LPVOID pParam);
UINT ThreadStsz(LPVOID pParam);
UINT ThreadStco(LPVOID pParam);
UINT ThreadCo64(LPVOID pParam);
UINT ThreadCtts(LPVOID pParam);

void CDlg2::OnLButtonDblClk(UINT nFlags, CPoint point)
{
	C解析MP4Dlg* pDlg = (C解析MP4Dlg*)theApp.m_pMainWnd;
	if (pDlg->dlg2.dlg3.IsWindowVisible())return CDialogEx::OnLButtonDblClk(nFlags, point);
	int Count = ar.GetCount();
	for (int i = 0; i < Count; i++)
	{
		INFO* pInfo = (INFO*)ar.GetAt(i);
		if (pInfo->rect.PtInRect(point) && pInfo->len)
		{
			CString type = pInfo->ID.Left(4);
			CString id = pInfo->ID.Right(pInfo->ID.GetLength() - 4);
			if (id == L"ctts")
			{
				pDlg->dlg2.dlg3.Stop = FALSE;
				AfxBeginThread(ThreadCtts, pInfo, 0, 0, 0);
				return CDialogEx::OnLButtonDblClk(nFlags, point);
			}
			if (id == L"stco")
			{
				pDlg->dlg2.dlg3.Stop = FALSE;
				AfxBeginThread(ThreadStco, pInfo, 0, 0, 0);
				return CDialogEx::OnLButtonDblClk(nFlags, point);
			}
			if (id == L"stsc")
			{
				pDlg->dlg2.dlg3.Stop = FALSE;
				AfxBeginThread(ThreadStsc, pInfo, 0, 0, 0);
				return CDialogEx::OnLButtonDblClk(nFlags, point);
			}
			if (id == L"stss")
			{
				pDlg->dlg2.dlg3.Stop = FALSE;
				AfxBeginThread(ThreadStss, pInfo, 0, 0, 0);
				return CDialogEx::OnLButtonDblClk(nFlags, point);
			}
			if (id == L"stsz")
			{
				pDlg->dlg2.dlg3.Stop = FALSE;
				AfxBeginThread(ThreadStsz, pInfo, 0, 0, 0);
				return CDialogEx::OnLButtonDblClk(nFlags, point);
			}
			if (id == L"stts")
			{
				pDlg->dlg2.dlg3.Stop = FALSE;
				AfxBeginThread(ThreadStts, pInfo, 0, 0, 0);
				return CDialogEx::OnLButtonDblClk(nFlags, point);
			}
			if (id == L"co64")
			{
				pDlg->dlg2.dlg3.Stop = FALSE;
				AfxBeginThread(ThreadCo64, pInfo, 0, 0, 0);
				return CDialogEx::OnLButtonDblClk(nFlags, point);
			}
			if (dlg4.GetSafeHwnd() == NULL)
			{
				dlg4.Create(IDD_DIALOG4, NULL);
			}
			else
			{
				dlg4.ShowWindow(SW_RESTORE);
			}
			CFile F;
			if (F.Open(pDlg->Path, CFile::modeRead))
			{
				BYTE* pB = new BYTE[pInfo->len];
				if (pB)
				{
					F.Seek(pInfo->uPos, CFile::begin);
					F.Read(pB, pInfo->len);
					CString item, s;
					for (UINT j = 0; j < pInfo->len; j++)
					{
						s.Format(L"%0*X ", 2, pB[j]);
						item += s;
					}
					dlg4.edit.SetWindowText(item);
					delete[] pB;
				}
				F.Close();
				dlg4.SetWindowText(pInfo->item);
			}
		}
	}
	CDialogEx::OnLButtonDblClk(nFlags, point);
}


void CDlg2::DeleteAllColumn()//删除所有列
{
	int nColumnCount = dlg3.list.GetHeaderCtrl()->GetItemCount();
	for (int i = 0; i < nColumnCount; i++)
	{
		dlg3.list.DeleteColumn(0);
	}
}

UINT ThreadStts(LPVOID pParam)
{
	C解析MP4Dlg* pDlg = (C解析MP4Dlg*)theApp.m_pMainWnd;
	INFO* pInfo = (INFO*)pParam;
	pDlg->dlg2.dlg3.ShowWindow(SW_SHOW);
	pDlg->dlg2.dlg3.SetWindowText(pInfo->ID);
	BYTE mby1, mby2, mby3, mby4;
	CFile F;
	if (!F.Open(pDlg->Path, CFile::modeRead))
	{
		AfxMessageBox(L"打开“" + pDlg->Path + L"”失败");
		return 0;
	}
	pDlg->dlg2.dlg3.list.DeleteAllItems(); //删除所有项
	pDlg->dlg2.DeleteAllColumn();//删除所有列
	pDlg->dlg2.dlg3.list.InsertColumn(0, L"条目序号", LVCFMT_LEFT, 80, -1);
	pDlg->dlg2.dlg3.list.InsertColumn(1, L"样本数量", LVCFMT_LEFT, 150, -1); pDlg->dlg2.dlg3.list.InsertColumn(2, L"单个样本的时长", LVCFMT_LEFT, 150, -1);
	F.Seek(pInfo->uPos, CFile::begin);
	for (UINT i = 0; i < pInfo->len / 8; i++)
	{
		if (pDlg->dlg2.dlg3.Stop) { pDlg->dlg2.dlg3.Stop = FALSE; F.Close(); return 0; }
		F.Read(&mby1, 1); F.Read(&mby2, 1); F.Read(&mby3, 1); F.Read(&mby4, 1);
		UINT sample_count = mby1 * 256 * 256 * 256 + mby2 * 256 * 256 + mby3 * 256 + mby4;
		F.Read(&mby1, 1); F.Read(&mby2, 1); F.Read(&mby3, 1); F.Read(&mby4, 1);
		UINT sample_delta = mby1 * 256 * 256 * 256 + mby2 * 256 * 256 + mby3 * 256 + mby4;
		int index = pDlg->dlg2.dlg3.list.InsertItem(pDlg->dlg2.dlg3.list.GetItemCount(), FormatString(i + 1));
		pDlg->dlg2.dlg3.list.SetItemText(index, 1, FormatString(sample_count)); pDlg->dlg2.dlg3.list.SetItemText(index, 2, FormatString(sample_delta));
	}
	F.Close(); pDlg->dlg2.dlg3.Stop = FALSE;
	return 1;
}

UINT ThreadStss(LPVOID pParam)
{
	C解析MP4Dlg* pDlg = (C解析MP4Dlg*)theApp.m_pMainWnd;
	INFO* pInfo = (INFO*)pParam;
	pDlg->dlg2.dlg3.ShowWindow(SW_SHOW);
	pDlg->dlg2.dlg3.SetWindowText(pInfo->ID);
	BYTE mby1, mby2, mby3, mby4;
	CFile F;
	if (!F.Open(pDlg->Path, CFile::modeRead))
	{
		AfxMessageBox(L"打开“" + pDlg->Path + L"”失败");
		return 0;
	}
	pDlg->dlg2.dlg3.list.DeleteAllItems(); //删除所有项
	pDlg->dlg2.DeleteAllColumn();//删除所有列
	pDlg->dlg2.dlg3.list.InsertColumn(0, L"条目序号", LVCFMT_LEFT, 80, -1);
	pDlg->dlg2.dlg3.list.InsertColumn(1, L"关键帧序号", LVCFMT_LEFT, 200, -1);
	F.Seek(pInfo->uPos, CFile::begin);
	for (UINT i = 0; i < pInfo->len / 4; i++)
	{
		if (pDlg->dlg2.dlg3.Stop) { pDlg->dlg2.dlg3.Stop = FALSE; F.Close(); return 0; }
		F.Read(&mby1, 1); F.Read(&mby2, 1); F.Read(&mby3, 1); F.Read(&mby4, 1);
		UINT KeFrame = mby1 * 256 * 256 * 256 + mby2 * 256 * 256 + mby3 * 256 + mby4;
		int index = pDlg->dlg2.dlg3.list.InsertItem(pDlg->dlg2.dlg3.list.GetItemCount(), FormatString(i + 1));
		pDlg->dlg2.dlg3.list.SetItemText(index, 1, FormatString(KeFrame));
	}
	F.Close(); pDlg->dlg2.dlg3.Stop = FALSE;
	return 1;
}

UINT ThreadStsc(LPVOID pParam)
{
	C解析MP4Dlg* pDlg = (C解析MP4Dlg*)theApp.m_pMainWnd;
	INFO* pInfo = (INFO*)pParam;
	pDlg->dlg2.dlg3.ShowWindow(SW_SHOW);
	pDlg->dlg2.dlg3.SetWindowText(pInfo->ID);
	BYTE mby1, mby2, mby3, mby4;
	CFile F;
	if (!F.Open(pDlg->Path, CFile::modeRead))
	{
		AfxMessageBox(L"打开“" + pDlg->Path + L"”失败");
		return 0;
	}
	pDlg->dlg2.dlg3.list.DeleteAllItems(); //删除所有项
	pDlg->dlg2.DeleteAllColumn();//删除所有列
	pDlg->dlg2.dlg3.list.InsertColumn(0, L"条目序号", LVCFMT_LEFT, 80, -1);
	pDlg->dlg2.dlg3.list.InsertColumn(1, L"范围中第1个块的序号", LVCFMT_LEFT, 150, -1); //范围的末尾序号为下一个条目的第1个块的序号-1
	pDlg->dlg2.dlg3.list.InsertColumn(2, L"每个块包含的样本数", LVCFMT_LEFT, 150, -1);
	pDlg->dlg2.dlg3.list.InsertColumn(3, L"块使用的stsd的序号", LVCFMT_LEFT, 150, -1);
	F.Seek(pInfo->uPos, CFile::begin);
	for (UINT i = 0; i < pInfo->len / 12; i++)
	{
		if (pDlg->dlg2.dlg3.Stop) { pDlg->dlg2.dlg3.Stop = FALSE; F.Close(); return 0; }
		F.Read(&mby1, 1); F.Read(&mby2, 1); F.Read(&mby3, 1); F.Read(&mby4, 1);
		UINT first_chunk = mby1 * 256 * 256 * 256 + mby2 * 256 * 256 + mby3 * 256 + mby4;
		F.Read(&mby1, 1); F.Read(&mby2, 1); F.Read(&mby3, 1); F.Read(&mby4, 1);
		UINT samples_per_chunk = mby1 * 256 * 256 * 256 + mby2 * 256 * 256 + mby3 * 256 + mby4;
		F.Read(&mby1, 1); F.Read(&mby2, 1); F.Read(&mby3, 1); F.Read(&mby4, 1);
		UINT sample_description_index = mby1 * 256 * 256 * 256 + mby2 * 256 * 256 + mby3 * 256 + mby4;
		int index = pDlg->dlg2.dlg3.list.InsertItem(pDlg->dlg2.dlg3.list.GetItemCount(), FormatString(i + 1));
		pDlg->dlg2.dlg3.list.SetItemText(index, 1, FormatString(first_chunk));
		pDlg->dlg2.dlg3.list.SetItemText(index, 2, FormatString(samples_per_chunk)); 
		pDlg->dlg2.dlg3.list.SetItemText(index, 3, FormatString(sample_description_index));
	}
	F.Close(); pDlg->dlg2.dlg3.Stop = FALSE;
	return 1;
}

UINT ThreadStsz(LPVOID pParam)
{
	C解析MP4Dlg* pDlg = (C解析MP4Dlg*)theApp.m_pMainWnd;
	INFO* pInfo = (INFO*)pParam;
	pDlg->dlg2.dlg3.ShowWindow(SW_SHOW);
	pDlg->dlg2.dlg3.SetWindowText(pInfo->ID);
	BYTE mby1, mby2, mby3, mby4;
	CFile F;
	if (!F.Open(pDlg->Path, CFile::modeRead))
	{
		AfxMessageBox(L"打开“" + pDlg->Path + L"”失败");
		return 0;
	}
	pDlg->dlg2.dlg3.list.DeleteAllItems(); //删除所有项
	pDlg->dlg2.DeleteAllColumn();//删除所有列
	pDlg->dlg2.dlg3.list.InsertColumn(0, L"条目序号", LVCFMT_LEFT, 80, -1);
	pDlg->dlg2.dlg3.list.InsertColumn(1, L"样本大小", LVCFMT_LEFT, 200, -1);
	F.Seek(pInfo->uPos, CFile::begin);
	for (UINT i = 0; i < pInfo->len / 4; i++)
	{
		if (pDlg->dlg2.dlg3.Stop) { pDlg->dlg2.dlg3.Stop = FALSE; F.Close(); return 0; }
		F.Read(&mby1, 1); F.Read(&mby2, 1); F.Read(&mby3, 1); F.Read(&mby4, 1);
		UINT sample_size_entry = mby1 * 256 * 256 * 256 + mby2 * 256 * 256 + mby3 * 256 + mby4;
		int index=pDlg->dlg2.dlg3.list.InsertItem(pDlg->dlg2.dlg3.list.GetItemCount(), FormatString(i+1));
		pDlg->dlg2.dlg3.list.SetItemText(index, 1, FormatString(sample_size_entry));
	}
	F.Close(); pDlg->dlg2.dlg3.Stop = FALSE;
	return 1;
}

UINT ThreadStco(LPVOID pParam)
{
	C解析MP4Dlg* pDlg = (C解析MP4Dlg*)theApp.m_pMainWnd;
	INFO* pInfo = (INFO*)pParam;
	pDlg->dlg2.dlg3.ShowWindow(SW_SHOW);
	pDlg->dlg2.dlg3.SetWindowText(pInfo->ID);
	BYTE mby1, mby2, mby3, mby4;
	CFile F;
	if (!F.Open(pDlg->Path, CFile::modeRead))
	{
		AfxMessageBox(L"打开“" + pDlg->Path + L"”失败");
		return 0;
	}
	pDlg->dlg2.dlg3.list.DeleteAllItems(); //删除所有项
	pDlg->dlg2.DeleteAllColumn();//删除所有列
	pDlg->dlg2.dlg3.list.InsertColumn(0, L"条目序号", LVCFMT_LEFT, 80, -1);
	pDlg->dlg2.dlg3.list.InsertColumn(1, L"块偏移量", LVCFMT_LEFT, 200, -1);
	F.Seek(pInfo->uPos, CFile::begin);
	for (UINT i = 0; i < pInfo->len / 4; i++)
	{
		if (pDlg->dlg2.dlg3.Stop) { pDlg->dlg2.dlg3.Stop = FALSE; F.Close(); return 0; }
		F.Read(&mby1, 1); F.Read(&mby2, 1); F.Read(&mby3, 1); F.Read(&mby4, 1);
		UINT offset = mby1 * 256 * 256 * 256 + mby2 * 256 * 256 + mby3 * 256 + mby4;
		int index = pDlg->dlg2.dlg3.list.InsertItem(pDlg->dlg2.dlg3.list.GetItemCount(), FormatString(i + 1));
		pDlg->dlg2.dlg3.list.SetItemText(index, 1, FormatString(offset));
	}
	F.Close(); pDlg->dlg2.dlg3.Stop = FALSE;
	return 1;
}

UINT ThreadCo64(LPVOID pParam)
{
	C解析MP4Dlg* pDlg = (C解析MP4Dlg*)theApp.m_pMainWnd;
	INFO* pInfo = (INFO*)pParam;
	pDlg->dlg2.dlg3.ShowWindow(SW_SHOW);
	pDlg->dlg2.dlg3.SetWindowText(pInfo->ID);
	BYTE mby1, mby2, mby3, mby4;
	CFile F;
	if (!F.Open(pDlg->Path, CFile::modeRead))
	{
		AfxMessageBox(L"打开“" + pDlg->Path + L"”失败");
		return 0;
	}
	pDlg->dlg2.dlg3.list.DeleteAllItems(); //删除所有项
	pDlg->dlg2.DeleteAllColumn();//删除所有列
	pDlg->dlg2.dlg3.list.InsertColumn(0, L"条目序号", LVCFMT_LEFT, 80, -1);
	pDlg->dlg2.dlg3.list.InsertColumn(1, L"样本偏移量", LVCFMT_LEFT, 200, -1);
	F.Seek(pInfo->uPos, CFile::begin);
	for (UINT i = 0; i < pInfo->len / 8; i++)
	{
		if (pDlg->dlg2.dlg3.Stop) { pDlg->dlg2.dlg3.Stop = FALSE; F.Close(); return 0; }
		UINT offset1, offset2;
		F.Read(&mby1, 1); F.Read(&mby2, 1); F.Read(&mby3, 1); F.Read(&mby4, 1);
		offset1 = mby1 * 256 * 256 * 256 + mby2 * 256 * 256 + mby3 * 256 + mby4;
		F.Read(&mby1, 1); F.Read(&mby2, 1); F.Read(&mby3, 1); F.Read(&mby4, 1);
		offset2= mby1 * 256 * 256 * 256 + mby2 * 256 * 256 + mby3 * 256 + mby4;
		int index = pDlg->dlg2.dlg3.list.InsertItem(pDlg->dlg2.dlg3.list.GetItemCount(), FormatString(i + 1));
		pDlg->dlg2.dlg3.list.SetItemText(index, 1, FormatString(((ULONGLONG)offset1 << 32) + offset2));
	}
	F.Close(); pDlg->dlg2.dlg3.Stop = FALSE;
	return 1;
}

UINT ThreadCtts(LPVOID pParam)
{
	C解析MP4Dlg* pDlg = (C解析MP4Dlg*)theApp.m_pMainWnd;
	INFO* pInfo = (INFO*)pParam;
	pDlg->dlg2.dlg3.ShowWindow(SW_SHOW);
	pDlg->dlg2.dlg3.SetWindowText(pInfo->ID);
	BYTE mby1, mby2, mby3, mby4;
	CFile F;
	if (!F.Open(pDlg->Path, CFile::modeRead))
	{
		AfxMessageBox(L"打开“" + pDlg->Path + L"”失败");
		return 0;
	}
	pDlg->dlg2.dlg3.list.DeleteAllItems(); //删除所有项
	pDlg->dlg2.DeleteAllColumn();//删除所有列
	pDlg->dlg2.dlg3.list.InsertColumn(0, L"条目序号", LVCFMT_LEFT, 80, -1);
	pDlg->dlg2.dlg3.list.InsertColumn(1, L"样本数量", LVCFMT_LEFT, 150, -1); 
	pDlg->dlg2.dlg3.list.InsertColumn(2, L"从解码到渲染之间的差值", LVCFMT_LEFT, 220, -1);
	F.Seek(pInfo->uPos, CFile::begin);
	CString s1, s2;
	if (pInfo->version == 0)
	{
		for (UINT i = 0; i < pInfo->len / 8; i++)
		{
			if (pDlg->dlg2.dlg3.Stop) { pDlg->dlg2.dlg3.Stop = FALSE; F.Close(); return 0; }
			F.Read(&mby1, 1); F.Read(&mby2, 1); F.Read(&mby3, 1); F.Read(&mby4, 1);
			UINT sample_count = mby1 * 256 * 256 * 256 + mby2 * 256 * 256 + mby3 * 256 + mby4;
			F.Read(&mby1, 1); F.Read(&mby2, 1); F.Read(&mby3, 1); F.Read(&mby4, 1);
			UINT sample_offset = mby1 * 256 * 256 * 256 + mby2 * 256 * 256 + mby3 * 256 + mby4;
			int index = pDlg->dlg2.dlg3.list.InsertItem(pDlg->dlg2.dlg3.list.GetItemCount(), FormatString(i + 1));
			pDlg->dlg2.dlg3.list.SetItemText(index, 1, FormatString(sample_count));
			pDlg->dlg2.dlg3.list.SetItemText(index, 2, FormatString(sample_offset));
		}
	}
	else if (pInfo->version == 1)
	{
		for (UINT i = 0; i < pInfo->len / 8; i++)
		{
			if (pDlg->dlg2.dlg3.Stop) { pDlg->dlg2.dlg3.Stop = FALSE; F.Close(); return 0; }
			F.Read(&mby1, 1); F.Read(&mby2, 1); F.Read(&mby3, 1); F.Read(&mby4, 1);
			UINT sample_count = mby1 * 256 * 256 * 256 + mby2 * 256 * 256 + mby3 * 256 + mby4;
			F.Read(&mby1, 1); F.Read(&mby2, 1); F.Read(&mby3, 1); F.Read(&mby4, 1);
			int sample_offset1 = mby1 * 256 * 256 * 256 + mby2 * 256 * 256 + mby3 * 256 + mby4;//CT 和 DT 之间的偏移量
			s1.Format(L"%u", sample_count); s2.Format(L"%d", sample_offset1);
			int index = pDlg->dlg2.dlg3.list.InsertItem(pDlg->dlg2.dlg3.list.GetItemCount(), FormatString(i + 1));
			pDlg->dlg2.dlg3.list.SetItemText(index, 1, FormatString(sample_count));
			pDlg->dlg2.dlg3.list.SetItemText(index, 2, FormatString((UINT)sample_offset1));
		}
	}
	F.Close(); pDlg->dlg2.dlg3.Stop = FALSE;
	return 1;
}
#pragma once
#include "afxwin.h"
#include "afxcmn.h"


// CDlg3 对话框

class CDlg3 : public CDialogEx
{
	DECLARE_DYNAMIC(CDlg3)

public:
	CDlg3(CWnd* pParent = NULL);   // 标准构造函数
	virtual ~CDlg3();

// 对话框数据
#ifdef AFX_DESIGN_TIME
	enum { IDD = IDD_DIALOG3 };
#endif

protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV 支持

	DECLARE_MESSAGE_MAP()
public:
	virtual BOOL OnInitDialog();
	CFont font;
	CBrush brush;
	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
	afx_msg void OnSize(UINT nType, int cx, int cy);
	CListCtrl list;
	BOOL Stop = FALSE;
	afx_msg void OnClose();
};

// Dlg3.cpp : 实现文件
//

#include "stdafx.h"
#include "解析MP4.h"
#include "Dlg3.h"
#include "afxdialogex.h"


// CDlg3 对话框

IMPLEMENT_DYNAMIC(CDlg3, CDialogEx)

CDlg3::CDlg3(CWnd* pParent /*=NULL*/)
	: CDialogEx(IDD_DIALOG3, pParent)
{
	font.CreatePointFont(100, L"微软雅黑");
	brush.CreateSolidBrush(RGB(150, 150, 150));
}

CDlg3::~CDlg3()
{
}

void CDlg3::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_LIST1, list);
}


BEGIN_MESSAGE_MAP(CDlg3, CDialogEx)
	ON_WM_ERASEBKGND()
	ON_WM_SIZE()
	ON_WM_CLOSE()
END_MESSAGE_MAP()

BOOL CDlg3::OnInitDialog()
{
	CDialogEx::OnInitDialog();
	CenterWindow();
	CRect rect;
	GetClientRect(rect);
	rect.DeflateRect(4, 4);
	list.MoveWindow(rect);
	list.SetFont(&font);
	list.SetBkColor(RGB(4, 118, 135));
	list.SetTextBkColor(RGB(4, 118, 135));
	list.SetTextColor(RGB(255, 255, 255));
	list.SetExtendedStyle(LVS_EX_FULLROWSELECT);
	return TRUE;  
}

BOOL CDlg3::OnEraseBkgnd(CDC* pDC)
{
	CRect rect;
	GetClientRect(rect);
	pDC->FillSolidRect(rect,RGB(1,46,53));
	return TRUE;
//	return CDialogEx::OnEraseBkgnd(pDC);
}

void CDlg3::OnSize(UINT nType, int cx, int cy)
{
	CDialogEx::OnSize(nType, cx, cy);
	if (list.GetSafeHwnd() != NULL)
	{
		CRect rect;
		GetClientRect(rect);
		rect.DeflateRect(4, 4);
		list.MoveWindow(rect);
	}
}

void CDlg3::OnClose()
{
	Stop = TRUE;//用于终止线程
	CDialogEx::OnClose();
}

#pragma once
#include "afxwin.h"


// CDlg4 对话框

class CDlg4 : public CDialogEx
{
	DECLARE_DYNAMIC(CDlg4)

public:
	CDlg4(CWnd* pParent = NULL);   // 标准构造函数
	virtual ~CDlg4();

// 对话框数据
#ifdef AFX_DESIGN_TIME
	enum { IDD = IDD_DIALOG4 };
#endif

protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV 支持

	DECLARE_MESSAGE_MAP()
public:
	afx_msg void OnBnClickedOk();
	CFont font;
	CBrush brush;
	void SetPos();
	CEdit edit;
	virtual BOOL OnInitDialog();
	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
};

// Dlg4.cpp : 实现文件
//

#include "stdafx.h"
#include "解析MP4.h"
#include "Dlg4.h"
#include "afxdialogex.h"


// CDlg4 对话框

IMPLEMENT_DYNAMIC(CDlg4, CDialogEx)

CDlg4::CDlg4(CWnd* pParent /*=NULL*/)
	: CDialogEx(IDD_DIALOG4, pParent)
{
	font.CreatePointFont(120, L"仿宋");
	brush.CreateSolidBrush(RGB(40, 40, 40));
}

CDlg4::~CDlg4()
{
}

void CDlg4::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_EDIT41, edit);
}


BEGIN_MESSAGE_MAP(CDlg4, CDialogEx)
	ON_BN_CLICKED(IDOK, &CDlg4::OnBnClickedOk)
	ON_WM_SIZE()
	ON_WM_CTLCOLOR()
END_MESSAGE_MAP()

void CDlg4::OnBnClickedOk()
{
}


void CDlg4::SetPos()
{
	CRect rect;
	GetClientRect(rect);
	rect.DeflateRect(5, 5);
	edit.MoveWindow(rect);
}


BOOL CDlg4::OnInitDialog()
{
	CDialogEx::OnInitDialog();
	SetPos();
	SetBackgroundColor(RGB(92, 25, 8));
	edit.SetFont(&font);
	edit.LimitText(UINT_MAX);
	return TRUE; 
}


void CDlg4::OnSize(UINT nType, int cx, int cy)
{
	CDialogEx::OnSize(nType, cx, cy);
	if (edit.GetSafeHwnd() != NULL)
		SetPos();
}


HBRUSH CDlg4::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
	HBRUSH hbr = CDialogEx::OnCtlColor(pDC, pWnd, nCtlColor);
	if (pWnd->GetDlgCtrlID() == IDC_EDIT41)
	{
		pDC->SetBkColor(RGB(40, 40, 40)); pDC->SetTextColor(RGB(90, 255, 255));
		return brush;
	}
	return hbr;
}

未完。后面代码转到(第2部分)
下载本应用

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

h3974

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值