本Windows应用解析AVI视频文件,以表格的方式显示AVI文件结构。并可以将结果保存到bmp图片。下面是,使用该应用解析一部AVI电影获得的图片。
应用开发信息
定义一个INFO结构,包含两个字符串对象,一个ULONGLONG变量,和一个UINT变量,一个CRect对象,一个颜色值变量。根据解析结果,创建一系列矩形,由CRect对象指定矩形的大小和位置,颜色值变量指定矩形的背景色,其中一个字符串对象用于指定矩形的文本,当另一个字符串对象包含“可读取”字符串时,ULONGLONG变量记录文件要读取的起始位置,UINT变量记录读取的长度。为每个矩形创建一个INFO结构对象,并加入指针数组。在绘制时,使用for循环绘制每个矩形。
程序为MFC对话框应用程序。
应用的全部代码
// 解析AVIDlg.h : 头文件
//
#pragma once
#include "Dlg1.h"
#include "Dlg2.h"
#include "Dlg3.h"
#include "afxwin.h"
#include "COp.h"
#include "afxcmn.h"
#include "MyEdit.h"
struct INFO
{
CString ID;
CString item;
ULONGLONG STAR;
UINT LEN;
CRect* pRect = NULL;
COLORREF color;
};
struct LINE
{
CPoint star;
CPoint end;
CString pos;
};
typedef struct _avimainheader {
DWORD dwMicroSecPerFrame;
DWORD dwMaxBytesPerSec;
DWORD dwPaddingGranularity;
DWORD dwFlags;
DWORD dwTotalFrames;
DWORD dwInitialFrames;
DWORD dwStreams;
DWORD dwSuggestedBufferSize;
DWORD dwWidth;
DWORD dwHeight;
DWORD dwReserved[4];
} AVIMAINHEADER;
struct strh_struct {
char fccType[4];
char fccHandler[4];
DWORD dwFlags;
WORD wPriority;
WORD wLanguage;
DWORD dwInitialFrames;
DWORD dwScale;
DWORD dwRate;
DWORD dwStart;
DWORD dwLength;
DWORD dwSuggestedBufferSize;
DWORD dwQuality;
DWORD dwSampleSize;
struct {
short int left;
short int top;
short int right;
short int bottom;
} rcFrame;
};
class C解析AVIDlg : public CDialogEx
{
// 构造
public:
C解析AVIDlg(CWnd* pParent = NULL); // 标准构造函数
// 对话框数据
#ifdef AFX_DESIGN_TIME
enum { IDD = IDD_AVI_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:
CDlg1 dlg1;
CDlg2 dlg2;
CDlg3 dlg3;
CBrush brush1;
CFont font1;
CStatic sta1;
CStatic sta2;
CStatic sta3;
CMyEdit richedit1;
CMyEdit richedit2;
afx_msg void OnBnClickedOk();
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
int HEIGHT, WIDTH;
void MySetPos();//定位控件
CObArray ar;
CObArray arLine;
CFile F;
CString Path;//打开的AVI文件路径
CString Name;
COLORREF BkColor = RGB(255, 193, 132);//背景色
void SetDlg2Size(int w, int h);
CString FormatString(ULONGLONG ull);
void AryDeleteAll();
afx_msg void On32771();//打开AVI文件
afx_msg void On32772();//退出程序
afx_msg void On32773();//最小化窗口
afx_msg void On32774();//保存到bmp图片
afx_msg void On32776();//黄色背景
afx_msg void On32777();//白色背景
afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
afx_msg void OnDestroy();
BOOL ParsingIx(ULONGLONG star, UINT len);
BOOL ParsingIdx1(ULONGLONG star, UINT len);
BOOL ParsingX(ULONGLONG star, UINT len);
afx_msg void On32778();
afx_msg void On32783();
afx_msg void On32784();
afx_msg void On32785();
afx_msg void On32786();
};
// 解析AVIDlg.cpp : 实现文件
//
#include "stdafx.h"
#include "解析AVI.h"
#include "解析AVIDlg.h"
#include "afxdialogex.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
C解析AVIDlg::C解析AVIDlg(CWnd* pParent /*=NULL*/)
: CDialogEx(IDD_AVI_DIALOG, pParent)
{
m_hIcon = AfxGetApp()->LoadIcon(IDI_ICON1);
brush1.CreateSolidBrush(RGB(49, 49, 49));
font1.CreatePointFont(100, L"微软雅黑");
}
void C解析AVIDlg::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Control(pDX, IDC_STA1, sta1);
DDX_Control(pDX, IDC_STA2, sta2);
DDX_Control(pDX, IDC_STA3, sta3);
DDX_Control(pDX, IDC_RICHEDIT21, richedit1);
DDX_Control(pDX, IDC_RICHEDIT22, richedit2);
}
BEGIN_MESSAGE_MAP(C解析AVIDlg, CDialogEx)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDOK, &C解析AVIDlg::OnBnClickedOk)
ON_WM_ERASEBKGND()
ON_WM_CREATE()
ON_COMMAND(ID_32771, &C解析AVIDlg::On32771)
ON_COMMAND(ID_32772, &C解析AVIDlg::On32772)
ON_COMMAND(ID_32773, &C解析AVIDlg::On32773)
ON_WM_CTLCOLOR()
ON_WM_MOUSEWHEEL()
ON_COMMAND(ID_32774, &C解析AVIDlg::On32774)
ON_WM_DESTROY()
ON_COMMAND(ID_32776, &C解析AVIDlg::On32776)
ON_COMMAND(ID_32777, &C解析AVIDlg::On32777)
ON_COMMAND(ID_32778, &C解析AVIDlg::On32778)
ON_COMMAND(ID_32783, &C解析AVIDlg::On32783)
ON_COMMAND(ID_32784, &C解析AVIDlg::On32784)
ON_COMMAND(ID_32785, &C解析AVIDlg::On32785)
ON_COMMAND(ID_32786, &C解析AVIDlg::On32786)
END_MESSAGE_MAP()
BOOL C解析AVIDlg::OnInitDialog()
{
CDialogEx::OnInitDialog();
SetIcon(m_hIcon, TRUE);
SetIcon(m_hIcon, FALSE);
CRect rect;
SystemParametersInfo(SPI_GETWORKAREA, 0, (PVOID)&rect, 0);//获取工作区大小
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);//设置对话框的大小
SetWindowText(L"解析AVI");
MySetPos();//定位控件
sta1.SetFont(&font1); sta2.SetFont(&font1); sta3.SetFont(&font1); sta1.SetWindowText(L"AVI文件名");
CRect RichRect;
richedit1.GetRect(RichRect); RichRect.DeflateRect(10, 2, 2, 2); richedit1.SetRect(RichRect);
richedit2.GetRect(RichRect); RichRect.DeflateRect(10, 2, 2, 2); richedit2.SetRect(RichRect);
richedit1.SetBackgroundColor(FALSE, RGB(100, 100, 100));
richedit2.SetBackgroundColor(FALSE, RGB(100, 100, 100));
CHARFORMAT2 cf;
cf.cbSize = sizeof(CHARFORMAT2);
cf.dwMask = CFM_FACE | CFM_SIZE | CFM_COLOR | CFM_WEIGHT | CFM_CHARSET;
wcsncpy_s(cf.szFaceName, LF_FACESIZE, _T("微软雅黑"), LF_FACESIZE);//设置字体名称为微软雅黑
cf.yHeight = 9 * 20;//设置字体大小
cf.crTextColor = RGB(240, 240, 240);//设置字体颜色
cf.bCharSet = GB2312_CHARSET;//设置中文字符集
cf.wWeight = 400;//设置字体粗细为正常
cf.dwEffects = 0;
richedit1.SetDefaultCharFormat(cf);//设置RichEdit编辑控件默认字符格式
CHARFORMAT2 cf2;
cf2.cbSize = sizeof(CHARFORMAT2);
cf2.dwMask = CFM_FACE | CFM_SIZE | CFM_COLOR | CFM_WEIGHT | CFM_CHARSET;
wcsncpy_s(cf2.szFaceName, LF_FACESIZE, _T("宋体"), LF_FACESIZE);//设置字体名称
cf2.yHeight = 9 * 20;//设置字体大小
cf2.crTextColor = RGB(240, 240, 240);//设置字体颜色
cf2.bCharSet = GB2312_CHARSET;//设置中文字符集
cf2.wWeight = 400;//设置字体粗细为正常
cf2.dwEffects = 0;
richedit2.SetDefaultCharFormat(cf2);
return TRUE;
}
void C解析AVIDlg::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解析AVIDlg::OnQueryDragIcon()
{
return static_cast<HCURSOR>(m_hIcon);
}
void C解析AVIDlg::OnBnClickedOk()
{
}
BOOL C解析AVIDlg::OnEraseBkgnd(CDC* pDC)
{
CRect rect;
GetClientRect(rect);
pDC->FillSolidRect(rect, RGB(49,49,49));
CRect r1, r2, r3;
dlg1.GetWindowRect(r1); ScreenToClient(r1); r1.InflateRect(1, 1);
richedit1.GetWindowRect(r2); ScreenToClient(r2); r2.InflateRect(1, 1);
richedit2.GetWindowRect(r3); ScreenToClient(r3); r3.InflateRect(1, 1);
pDC->FrameRect(r1, &CBrush(RGB(130, 130, 130)));
pDC->FrameRect(r2, &CBrush(RGB(130, 130, 130)));
pDC->FrameRect(r3, &CBrush(RGB(130, 130, 130)));
return TRUE;
// return CDialogEx::OnEraseBkgnd(pDC);
}
int C解析AVIDlg::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CDialogEx::OnCreate(lpCreateStruct) == -1)
return -1;
dlg1.Create(IDD_DIALOG1);
dlg2.Create(IDD_DIALOG2, &dlg1);
return 0;
}
void C解析AVIDlg::MySetPos()//定位控件
{
CRect client;
GetClientRect(client);
dlg1.MoveWindow(10, 10, client.Width() * 6 / 10, client.Height()-20);
CRect dlg1_rect;
dlg1.GetWindowRect(dlg1_rect); ScreenToClient(dlg1_rect);
HEIGHT = dlg1_rect.Height(); WIDTH = dlg1_rect.Width();
sta1.MoveWindow(dlg1_rect.right + 10, 10, client.Width() - dlg1_rect.right - 20, 20);
sta2.MoveWindow(dlg1_rect.right + 10, 40, client.Width() - dlg1_rect.right - 20, 20);
int h = client.Height() / 2;
richedit1.MoveWindow(dlg1_rect.right + 10, 70, client.Width() - dlg1_rect.right - 20, h-70);
sta3.MoveWindow(dlg1_rect.right + 10, h+10, client.Width() - dlg1_rect.right - 20, 20);
richedit2.MoveWindow(dlg1_rect.right + 10, h+40, client.Width() - dlg1_rect.right - 20, h - 50);
CRect rect;
dlg1.GetClientRect(rect);
dlg2.MoveWindow(rect);
dlg2.GetClientRect(dlg2.dlg2_rect);
dlg1.SetScrollRange(SB_VERT, 0, 0, TRUE);//设置垂直滚动条的滚动范围0
dlg1.SetScrollRange(SB_HORZ, 0, 0, TRUE);//设置水平滚动条的滚动范围0
}
void C解析AVIDlg::On32771()//打开AVI文件
{
AryDeleteAll();//删除信息数组中所有项
CFileDialog FD(TRUE, NULL, NULL, OFN_FILEMUSTEXIST | OFN_HIDEREADONLY, L"AVI文件|*.avi|所有文件|*.*||");
if (FD.DoModal() != IDOK)return;
Path = FD.GetPathName();
Name = FD.GetFileTitle();
SetWindowText(Path); sta1.SetWindowText(Path);
if (!F.Open(Path, CFile::modeRead))
{
MessageBox(L"打开文件失败"); F.Close(); return;
}
ULONGLONG LEN = F.GetLength();//文件的大小
CPoint point = Read_RIFF_Chunk(CPoint(36,10));
Agan:
char ch[5]; ch[4] = 0; DWORD mSize;
F.Read(ch, 4);
F.Read(&mSize, 4);
if ((CString)ch == L"LIST")
{
F.Read(ch, 4);
if ((CString)ch == L"hdrl")
{
point = Read_hdrl_LIST(point);
}
else
{
point = Read_X_LIST(point);
}
}
else
{
if ((CString)ch == L"RIFF")
{
point = Read_RIFF_AVIX(point);
}
else
{
point = Read_X(point);
}
}
if (F.GetPosition() < LEN)goto Agan;
LINE* pLine = new LINE();
pLine->star = CPoint(point.x, point.y-1);
pLine->end = CPoint(970, point.y - 1);
pLine->pos = FormatString(LEN) + L"字节";
arLine.Add((CObArray*)pLine);
SetDlg2Size(1070, point.y + 40);
dlg2.RedrawWindow();
F.Close();
}
CString C解析AVIDlg::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;
}
void C解析AVIDlg::AryDeleteAll()//删除信息数组中所有项
{
int Count = ar.GetCount();
for (int i = 0; i < Count; i++)
{
INFO* pInfo = (INFO*)ar.GetAt(i);
delete pInfo->pRect;
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解析AVIDlg::On32772()//退出程序
{
EndDialog(1);
}
void C解析AVIDlg::On32773()//最小化窗口
{
ShowWindow(SW_MINIMIZE);
}
HBRUSH C解析AVIDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialogEx::OnCtlColor(pDC, pWnd, nCtlColor);
if (pWnd->GetDlgCtrlID() == IDC_STA1 || pWnd->GetDlgCtrlID() == IDC_STA2 || pWnd->GetDlgCtrlID() == IDC_STA3)
{
pDC->SetBkColor(RGB(49, 49, 49)); pDC->SetTextColor(RGB(190, 190, 190));
return brush1;
}
return hbr;
}
BOOL C解析AVIDlg::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);
dlg2.MoveWindow(0, - pos, dlg2.dlg2_rect.Width(), dlg2.dlg2_rect.Height());
return CDialogEx::OnMouseWheel(nFlags, zDelta, pt);
}
void C解析AVIDlg::SetDlg2Size(int w, int h)
{
CRect rect;
dlg1.GetClientRect(rect);
HEIGHT = rect.Height(); WIDTH = rect.Width();
if (w > WIDTH)WIDTH = w;
if (h > HEIGHT)HEIGHT = h;
dlg2.MoveWindow(0, 0, WIDTH, HEIGHT);
int wdlg1 = rect.Width(); int hdlg1 = rect.Height();
dlg1.SetScrollRange(SB_VERT, 0, HEIGHT - hdlg1, TRUE);//设置垂直滚动条的滚动范围
dlg1.SetScrollRange(SB_HORZ, 0, WIDTH - wdlg1, TRUE);//设置水平滚动条的滚动范围
dlg2.GetClientRect(dlg2.dlg2_rect);
}
void C解析AVIDlg::On32774()//保存到bmp图片
{
if (Name.IsEmpty())return;
CRect rc;
dlg2.GetClientRect(rc);
CDC MemDC;
MemDC.CreateCompatibleDC(NULL);
CBitmap bmp;
bmp.CreateBitmap(rc.Width(), rc.Height(), 1, 32, NULL);
MemDC.SelectObject(&bmp);
MemDC.SelectObject(&dlg2.font1);
MemDC.FillSolidRect(rc, BkColor);
int Count = ar.GetCount();
for (int i = 0; i < Count; i++)
{
INFO* pInfo = (INFO*)ar.GetAt(i);
MemDC.FillSolidRect(pInfo->pRect, pInfo->color);
MemDC.DrawText(pInfo->item, pInfo->pRect, DT_CENTER);
MemDC.FrameRect(pInfo->pRect, &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);
MemDC.LineTo(pLine->end);
MemDC.TextOut(pLine->end.x + 2, pLine->end.y - 7, pLine->pos);
}
BITMAPINFOHEADER Hdr;
Hdr.biSize = sizeof(BITMAPINFOHEADER);
Hdr.biWidth = rc.Width();
Hdr.biHeight = rc.Height();
Hdr.biPlanes = 1;
Hdr.biBitCount = 32;
Hdr.biCompression = BI_RGB;
Hdr.biSizeImage = rc.Width() * rc.Height() * 4;
Hdr.biXPelsPerMeter = 0;
Hdr.biYPelsPerMeter = 0;
Hdr.biClrUsed = 0;
Hdr.biClrImportant = 0;
BYTE* lpData = (BYTE*)(LPVOID)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, rc.Width() * rc.Height() * 4);
GetDIBits(MemDC.m_hDC, (HBITMAP)bmp, 0, rc.Height(), lpData, (BITMAPINFO*)&Hdr, DIB_RGB_COLORS);
BITMAPFILEHEADER Fhdr;
Fhdr.bfType = ((WORD)('M' << 8) | 'B');
Fhdr.bfSize = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + rc.Width() * rc.Height() * 4;//整个文件的大小
Fhdr.bfReserved1 = 0;
Fhdr.bfReserved2 = 0;
Fhdr.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER);//从文件开头到图像数据的偏移量
CFile F;
F.Open(Name+L".bmp", CFile::modeCreate | CFile::modeWrite);
F.Write(&Fhdr, sizeof(Fhdr));//写位图文件头
F.Write(&Hdr, sizeof(Hdr));//写位图信息
F.Write(lpData, rc.Width() * rc.Height() * 4);//写图像数据
F.Close();
GlobalFree(lpData);
}
void C解析AVIDlg::OnDestroy()
{
CDialogEx::OnDestroy();
AryDeleteAll();
}
void C解析AVIDlg::On32776()//黄色背景
{
BkColor = RGB(255, 193, 132); dlg2.RedrawWindow();
}
void C解析AVIDlg::On32777()//白色背景
{
BkColor = RGB(255, 255, 255); dlg2.RedrawWindow();
}
BOOL C解析AVIDlg::ParsingIx(ULONGLONG star, UINT len)
{
F.Open(Path, CFile::modeRead);
F.Seek(star, CFile::begin);
CString item;
char fcc[5]; fcc[4] = 0;
F.Read(fcc, 4);
DWORD cb;
F.Read(&cb, 4);
WORD wLongsPerEntry;
F.Read(&wLongsPerEntry, 2);
BYTE bIndexSubType;
F.Read(&bIndexSubType, 1);
BYTE bIndexType;
F.Read(&bIndexType, 1);
DWORD nEntriesInUse;
F.Read(&nEntriesInUse, 4);
char dwChunkId[5]; dwChunkId[4] = 0;
F.Read(&dwChunkId, 4);
LONGLONG qwBaseOffset;
F.Read(&qwBaseOffset, 8);
DWORD dwReserved;
F.Read(&dwReserved, 4);
if (bIndexSubType != 0)
{
F.Close(); return FALSE;
}
item.Format(L"标准索引块\r\nFOURCC \t%s//块标识\r\nDWORD \t%u//块大小\r\nWORD \t\t%d//条目的DWORD大小\r\nBYTE \t\t%d//必须为0\r\nBYTE \t\t%d//必须为AVI_INDEX_OF_CHUNKS\r\nDWORD \t%u//条目数\r\nDWORD \t%s//流标识\r\nLONGLONG \t%I64d//基本偏移量\r\nDWORD \t%u//保留\r\n共%u条目\r\n序号\t\t偏移量\t\t大小\r\n",
(CString)fcc, cb, wLongsPerEntry, bIndexSubType, bIndexType, nEntriesInUse,
(CString)dwChunkId, qwBaseOffset, dwReserved, nEntriesInUse);
for (DWORD i = 0; i < nEntriesInUse; i++)
{
DWORD dwOffset; DWORD dwSize;
F.Read(&dwOffset, 4); F.Read(&dwSize, 4);
dwSize &= 0x7fffffff;
CString Nu, Offset_str, Size_str;
Nu.Format(L"%u\t\t", i + 1); Offset_str.Format(L"%u", dwOffset); Size_str.Format(L"\t\t%u", dwSize);
item += Nu + Offset_str + Size_str + L"\r\n";
}
richedit1.SetWindowText(item);
F.Seek(star, CFile::begin);
CString ss, item2;
BYTE pB[32];
UINT L = len; int i = 0;
while (L >= 32)
{
F.Read(pB, 32);
ss.Format(L"%0*d %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X\r\n", 8, i * 32, 2, pB[0], 2, pB[1], 2, pB[2], 2, pB[3], 2, pB[4], 2, pB[5], 2, pB[6], 2, pB[7], 2, pB[8], 2, pB[9], 2, pB[10], 2, pB[11], 2, pB[12], 2, pB[13], 2, pB[14], 2, pB[15],
2, pB[16], 2, pB[17], 2, pB[18], 2, pB[19], 2, pB[20], 2, pB[21], 2, pB[22], 2, pB[23], 2, pB[24], 2, pB[25], 2, pB[26], 2, pB[27], 2, pB[28], 2, pB[29], 2, pB[30], 2, pB[31]);
item2 += ss;
L -= 32; i++;
}
F.Read(pB, L);
ss.Format(L"%0*d ", 8, i * 32);
item2 += ss;
for (UINT i = 0; i < L; i++)
{
if ((i + 1) % 8)
{
ss.Format(L"%0*X ", 2, pB[i]);
}
else
{
ss.Format(L"%0*X ", 2, pB[i]);
}
item2 += ss;
}
richedit2.SetWindowText(item2);
F.Close();
return TRUE;
}
BOOL C解析AVIDlg::ParsingIdx1(ULONGLONG star, UINT len)
{
F.Open(Path, CFile::modeRead);
F.Seek(star, CFile::begin);
CString item;
char fcc[5]; fcc[4] = 0; DWORD flags, offset, size;
for (UINT i = 0; i < len / 16; i++)
{
F.Read(fcc, 4); F.Read(&flags, 4); F.Read(&offset, 4); F.Read(&size, 4);
CString ss;
ss.Format(L"%s flags=%u offset=%u size=%u\r\n",(CString)fcc,flags,offset,size);
item += ss;
}
richedit1.SetWindowText(item);
F.Seek(star, CFile::begin);
CString item2;
BYTE pB[32];
UINT L = len; int i = 0;
while (L >= 32)
{
F.Read(pB, 32);
CString ss;
ss.Format(L"%0*d %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X\r\n",
8, i * 32, 2, pB[0], 2, pB[1], 2, pB[2], 2, pB[3], 2, pB[4], 2, pB[5], 2, pB[6], 2, pB[7], 2, pB[8], 2, pB[9], 2, pB[10], 2, pB[11], 2, pB[12], 2, pB[13], 2, pB[14], 2, pB[15], 2, pB[16], 2, pB[17], 2,
pB[18], 2, pB[19], 2, pB[20], 2, pB[21], 2, pB[22], 2, pB[23], 2, pB[24], 2, pB[25], 2, pB[26], 2, pB[27], 2, pB[28], 2, pB[29], 2, pB[30], 2, pB[31]);
item2 += ss;
L -= 32; i++;
}
F.Read(pB, L);
for (UINT i = 0; i < L; i++)
{
CString ss;
if ((i + 1) % 8)
{
ss.Format(L"%0*X ", 2, pB[i]);
}
else
{
ss.Format(L"%0*X ", 2, pB[i]);
}
item2 += ss;
}
richedit2.SetWindowText(item2);
F.Close();
return TRUE;
}
BOOL C解析AVIDlg::ParsingX(ULONGLONG star, UINT len)
{
F.Open(Path, CFile::modeRead);
CString ss, item2;
BYTE pB[32];
UINT L = len; int i = 0;
while (L >= 32)
{
F.Read(pB, 32);
ss.Format(L"%0*d %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X %0*X\r\n", 8, i * 32, 2, pB[0], 2, pB[1], 2, pB[2], 2, pB[3], 2, pB[4], 2, pB[5], 2, pB[6], 2, pB[7], 2, pB[8], 2, pB[9], 2, pB[10], 2, pB[11], 2, pB[12], 2, pB[13], 2, pB[14],
2, pB[15], 2, pB[16], 2, pB[17], 2, pB[18], 2, pB[19], 2, pB[20], 2, pB[21], 2, pB[22], 2, pB[23], 2, pB[24], 2, pB[25], 2, pB[26], 2, pB[27], 2, pB[28], 2, pB[29], 2, pB[30], 2, pB[31]);
item2 += ss;
L -= 32; i++;
}
F.Read(pB, L);
ss.Format(L"%0*d ", 8, i * 32);
item2 += ss;
for (UINT i = 0; i < L; i++)
{
if ((i + 1) % 8)
{
ss.Format(L"%0*X ", 2, pB[i]);
}
else
{
ss.Format(L"%0*X ", 2, pB[i]);
}
item2 += ss;
}
richedit2.SetWindowText(item2);
F.Close();
return TRUE;
}
void C解析AVIDlg::On32778()//帮助
{
if (dlg3.GetSafeHwnd() == NULL)
{
dlg3.Create(IDD_DIALOG3);
}
else
{
dlg3.ShowWindow(SW_SHOWNORMAL);
}
}
void C解析AVIDlg::On32783()//解析结果编辑框右键菜单-复制
{
richedit1.Copy();
}
void C解析AVIDlg::On32784()//解析结果编辑框右键菜单-全选
{
richedit1.SetSel(0, -1);
}
void C解析AVIDlg::On32785()//原始数据编辑框右键菜单-复制
{
richedit2.Copy();
}
void C解析AVIDlg::On32786()//原始数据编辑框右键菜单-全选
{
richedit2.SetSel(0, -1);
}
#pragma once
CPoint Read_RIFF_Chunk(CPoint pt);
CPoint Read_indx(CPoint pt);
CPoint Read_hdrl_LIST(CPoint pt);
CPoint Read_avih(CPoint pt);
CPoint Read_strl_LIST(CPoint pt);
CPoint Read_strh(CPoint pt, CString& Format);
CPoint Read_strf(CPoint pt, CString Format);
CPoint Read_X(CPoint pt);
CPoint Read_X_LIST(CPoint pt);
CPoint Read_RIFF_AVIX(CPoint pt);
#include "stdafx.h"
#include "COp.h"
#include "解析AVI.h"
#include "解析AVIDlg.h"
CPoint Read_RIFF_Chunk(CPoint pt)
{
C解析AVIDlg* pDlg = (C解析AVIDlg*)theApp.m_pMainWnd;
COLORREF ChunkColor= RGB(255, 146, 101), Color= RGB(220, 180, 180);
LINE* pLine = new LINE();
pLine->star = CPoint(pt.x, pt.y);
pLine->end = CPoint(970, pt.y);
pLine->pos = L"0字节";
pDlg->arLine.Add((CObArray*)pLine);
char chRIFF[5]; chRIFF[4] = 0;
pDlg->F.Read(chRIFF, 4);//读取文件规范标识
DWORD mSize;
pDlg->F.Read(&mSize, 4);//读取文件大小
char chAVI[5]; chAVI[4] = 0;
pDlg->F.Read(chAVI, 4);//读取文件类型
CRect rect(pt.x, pt.y, pt.x+121, pt.y+14);
INFO* pChunk = new INFO();
pChunk->item = L"RIFF\r\n12字节";
pChunk->pRect = new CRect(); pChunk->pRect->CopyRect(rect);
pChunk->color = ChunkColor;
pDlg->ar.Add((CObArray*)pChunk);
INFO* pSize1 = new INFO();
pSize1->item = L"4字节";
pSize1->pRect = new CRect(); pSize1->pRect->CopyRect(rect); pSize1->pRect->OffsetRect(rect.Width() - 1, 0);
pSize1->color = Color;
pDlg->ar.Add((CObArray*)pSize1);
INFO* pSize2 = new INFO();
pSize2->item = L"4字节";
pSize2->pRect = new CRect(); pSize2->pRect->CopyRect(pSize1->pRect); pSize2->pRect->OffsetRect(0, rect.Height()-1);
pSize2->color = Color;
pDlg->ar.Add((CObArray*)pSize2);
INFO* pSize3 = new INFO();
pSize3->item = L"4字节";
pSize3->pRect = new CRect(); pSize3->pRect->CopyRect(pSize2->pRect); pSize3->pRect->OffsetRect(0, rect.Height() - 1);
pSize3->color = Color;
pDlg->ar.Add((CObArray*)pSize3);
INFO* pD1 = new INFO();
pD1->item = (CString)chRIFF;
pD1->pRect = new CRect(); pD1->pRect->CopyRect(pSize1->pRect); pD1->pRect->OffsetRect(rect.Width() - 1, 0);
pD1->color = Color;
pDlg->ar.Add((CObArray*)pD1);
INFO* pD2 = new INFO();
pD2->item = pDlg->FormatString(mSize);
pD2->pRect = new CRect(); pD2->pRect->CopyRect(pD1->pRect); pD2->pRect->OffsetRect(0, rect.Height() - 1);
pD2->color = Color;
pDlg->ar.Add((CObArray*)pD2);
INFO* pD3 = new INFO();
pD3->item = (CString)chAVI;
pD3->pRect = new CRect(); pD3->pRect->CopyRect(pD2->pRect); pD3->pRect->OffsetRect(0, rect.Height() - 1);
pD3->color = Color;
pDlg->ar.Add((CObArray*)pD3);
pChunk->pRect->bottom = pD3->pRect->bottom;
return CPoint(pt.x, pChunk->pRect->bottom);
}
CPoint Read_indx(CPoint pt)
{
C解析AVIDlg* pDlg = (C解析AVIDlg*)theApp.m_pMainWnd;
COLORREF ChunkColor = RGB(114, 141, 203), Color = RGB(171, 184, 214);
pDlg->F.Seek(-8, CFile::current);
ULONGLONG uPos = pDlg->F.GetPosition();
LINE* pLine = new LINE();
pLine->star = CPoint(pt.x, pt.y - 1);
pLine->end = CPoint(970, pt.y - 1);
pLine->pos = pDlg->FormatString(uPos) + L"字节";
pDlg->arLine.Add((CObArray*)pLine);
char ch[5]; ch[4] = 0; DWORD mSize;
pDlg->F.Read(ch, 4); pDlg->F.Read(&mSize, 4);
ULONGLONG End = pDlg->F.GetPosition() + mSize;
WORD wLongsPerEntry;//每个条目所占DWORD个数
pDlg->F.Read(&wLongsPerEntry, 2);
BYTE bIndexSubType;//索引类型,0指向索引块,1指向数据块,8条目是真实数据
pDlg->F.Read(&bIndexSubType, 1);
BYTE bIndexType;//索引类型,0标准索引,1场索引
pDlg->F.Read(&bIndexType, 1);
DWORD nEntriesInUse;//条目数量
pDlg->F.Read(&nEntriesInUse, 4);
char dwChunkId[5];//流的FOURCC
dwChunkId[4] = 0;
pDlg->F.Read(&dwChunkId, 4);
DWORD Reserved[3];//保留
pDlg->F.Read(&Reserved, 12);
CRect rect(pt.x, pt.y-1, pt.x + 121, pt.y + 14), rect2(pt.x + 120*3, pt.y-1, pt.x + 120*3 + 201, pt.y + 14);
INFO* pChunk = new INFO();
pChunk->item = (CString)ch + L"\r\n" + pDlg->FormatString(8 + mSize) + L"字节";
pChunk->pRect = new CRect(); pChunk->pRect->CopyRect(rect);
pChunk->color = ChunkColor;
pDlg->ar.Add((CObArray*)pChunk);
INFO* pXSize1 = new INFO();
pXSize1->item = L"4字节";
pXSize1->pRect = new CRect(); pXSize1->pRect->CopyRect(rect); pXSize1->pRect->OffsetRect(rect.Width() - 1, 0);
pXSize1->color = Color;
pDlg->ar.Add((CObArray*)pXSize1);
INFO* pXSize2 = new INFO();
pXSize2->item = L"4字节";
pXSize2->pRect = new CRect(); pXSize2->pRect->CopyRect(pXSize1->pRect); pXSize2->pRect->OffsetRect(0, rect.Height()-1);
pXSize2->color = Color;
pDlg->ar.Add((CObArray*)pXSize2);
INFO* pXSize3 = new INFO();
pXSize3->item = L"2字节";
pXSize3->pRect = new CRect(); pXSize3->pRect->CopyRect(pXSize2->pRect); pXSize3->pRect->OffsetRect(0, rect.Height() - 1);
pXSize3->color = Color;
pDlg->ar.Add((CObArray*)pXSize3);
INFO* pXSize4 = new INFO();
pXSize4->item = L"1字节";
pXSize4->pRect = new CRect(); pXSize4->pRect->CopyRect(pXSize3->pRect); pXSize4->pRect->OffsetRect(0, rect.Height() - 1);
pXSize4->color = Color;
pDlg->ar.Add((CObArray*)pXSize4);
INFO* pXSize5 = new INFO();
pXSize5->item = L"1字节";
pXSize5->pRect = new CRect(); pXSize5->pRect->CopyRect(pXSize4->pRect); pXSize5->pRect->OffsetRect(0, rect.Height() - 1);
pXSize5->color = Color;
pDlg->ar.Add((CObArray*)pXSize5);
INFO* pXSize6 = new INFO();
pXSize6->item = L"4字节";
pXSize6->pRect = new CRect(); pXSize6->pRect->CopyRect(pXSize5->pRect); pXSize6->pRect->OffsetRect(0, rect.Height() - 1);
pXSize6->color = Color;
pDlg->ar.Add((CObArray*)pXSize6);
INFO* pXSize7 = new INFO();
pXSize7->item = L"4字节";
pXSize7->pRect = new CRect(); pXSize7->pRect->CopyRect(pXSize6->pRect); pXSize7->pRect->OffsetRect(0, rect.Height() - 1);
pXSize7->color = Color;
pDlg->ar.Add((CObArray*)pXSize7);
INFO* pXSize8 = new INFO();
pXSize8->item = L"12字节";
pXSize8->pRect = new CRect(); pXSize8->pRect->CopyRect(pXSize7->pRect); pXSize8->pRect->OffsetRect(0, rect.Height() - 1);
pXSize8->color = Color;
pDlg->ar.Add((CObArray*)pXSize8);
INFO* pXDS1 = new INFO();
pXDS1->item = (CString)ch;
pXDS1->pRect = new CRect(); pXDS1->pRect->CopyRect(pXSize1->pRect); pXDS1->pRect->OffsetRect(pXSize1->pRect->Width() - 1, 0);
pXDS1->color = Color;
pDlg->ar.Add((CObArray*)pXDS1);
INFO* pXDS2 = new INFO();
pXDS2->item = pDlg->FormatString(mSize);
pXDS2->pRect = new CRect(); pXDS2->pRect->CopyRect(pXDS1->pRect); pXDS2->pRect->OffsetRect(0, rect.Height()-1);
pXDS2->color = Color;
pDlg->ar.Add((CObArray*)pXDS2);
INFO* pXDS3 = new INFO();
pXDS3->item = pDlg->FormatString(wLongsPerEntry);
pXDS3->pRect = new CRect(); pXDS3->pRect->CopyRect(pXDS2->pRect); pXDS3->pRect->OffsetRect(0, rect.Height() - 1);
pXDS3->color = Color;
pDlg->ar.Add((CObArray*)pXDS3);
INFO* pXDS4 = new INFO();
pXDS4->item = pDlg->FormatString(bIndexSubType);
pXDS4->pRect = new CRect(); pXDS4->pRect->CopyRect(pXDS3->pRect); pXDS4->pRect->OffsetRect(0, rect.Height() - 1);
pXDS4->color = Color;
pDlg->ar.Add((CObArray*)pXDS4);
INFO* pXDS5 = new INFO();
pXDS5->item = pDlg->FormatString(bIndexType);
pXDS5->pRect = new CRect(); pXDS5->pRect->CopyRect(pXDS4->pRect); pXDS5->pRect->OffsetRect(0, rect.Height() - 1);
pXDS5->color = Color;
pDlg->ar.Add((CObArray*)pXDS5);
INFO* pXDS6 = new INFO();
pXDS6->item = pDlg->FormatString(nEntriesInUse);
pXDS6->pRect = new CRect(); pXDS6->pRect->CopyRect(pXDS5->pRect); pXDS6->pRect->OffsetRect(0, rect.Height() - 1);
pXDS6->color = Color;
pDlg->ar.Add((CObArray*)pXDS6);
INFO* pXDS7 = new INFO();
pXDS7->item = (CString)dwChunkId;
pXDS7->pRect = new CRect(); pXDS7->pRect->CopyRect(pXDS6->pRect); pXDS7->pRect->OffsetRect(0, rect.Height() - 1);
pXDS7->color = Color;
pDlg->ar.Add((CObArray*)pXDS7);
INFO* pXDS8 = new INFO();
CString ss; ss.Format(L"{%u,%u,%u}", Reserved[0], Reserved[1], Reserved[2]);
pXDS8->item = ss;
pXDS8->pRect = new CRect(); pXDS8->pRect->CopyRect(pXDS7->pRect); pXDS8->pRect->OffsetRect(0, rect.Height() - 1);
pXDS8->color = Color;
pDlg->ar.Add((CObArray*)pXDS8);
INFO* pXM1 = new INFO();
pXM1->item = L"每个条目DWORD个数";
pXM1->pRect = new CRect(); pXM1->pRect->CopyRect(rect2); pXM1->pRect->OffsetRect(0, (rect2.Height() - 1) * 2);
pXM1->color = Color;
pDlg->ar.Add((CObArray*)pXM1);
INFO* pXM2 = new INFO();
if (bIndexSubType == 0)pXM2->item = L"索引子类型:指向索引块";
if (bIndexSubType == 1)pXM2->item = L"索引子类型:指向数据块";
if (bIndexSubType == 8)pXM2->item = L"索引子类型:条目是真实数据";
pXM2->pRect = new CRect(); pXM2->pRect->CopyRect(pXM1->pRect); pXM2->pRect->OffsetRect(0, rect2.Height() - 1);
pXM2->color = Color;
pDlg->ar.Add((CObArray*)pXM2);
INFO* pXM3 = new INFO();
if (bIndexType == 0)pXM3->item = L"索引类型:标准索引";
if (bIndexType == 1)pXM3->item = L"索引类型:场索引类型";
pXM3->pRect = new CRect(); pXM3->pRect->CopyRect(pXM2->pRect); pXM3->pRect->OffsetRect(0, rect2.Height() - 1);
pXM3->color = Color;
pDlg->ar.Add((CObArray*)pXM3);
INFO* pXM4 = new INFO();
pXM4->item = L"条目数量";
pXM4->pRect = new CRect(); pXM4->pRect->CopyRect(pXM3->pRect); pXM4->pRect->OffsetRect(0, rect2.Height() - 1);
pXM4->color = Color;
pDlg->ar.Add((CObArray*)pXM4);
INFO* pXM5 = new INFO();
pXM5->item = L"流的FOURCC";
pXM5->pRect = new CRect(); pXM5->pRect->CopyRect(pXM4->pRect); pXM5->pRect->OffsetRect(0, rect2.Height() - 1);
pXM5->color = Color;
pDlg->ar.Add((CObArray*)pXM5);
INFO* pXM6 = new INFO();
pXM6->item = L"DWORD[3],保留";
pXM6->pRect = new CRect(); pXM6->pRect->CopyRect(pXM5->pRect); pXM6->pRect->OffsetRect(0, rect2.Height() - 1);
pXM6->color = Color;
pDlg->ar.Add((CObArray*)pXM6);
pChunk->pRect->bottom = pXSize8->pRect->bottom;
for (DWORD i = 0; i < nEntriesInUse; i++)
{
LONGLONG offset; DWORD size, dur;
pDlg->F.Read(&offset, 8); pDlg->F.Read(&size, 4); pDlg->F.Read(&dur, 4);
CString item, offset_str, size_str, dur_str;
offset_str = pDlg->FormatString((ULONGLONG)offset); size_str = pDlg->FormatString((ULONGLONG)size);dur_str= pDlg->FormatString((ULONGLONG)dur);
item.Format(L"偏移量=%s 大小=%s 长度=%s", offset_str, size_str, dur_str);
INFO* pXSizeX = new INFO();
pXSizeX->item = pDlg->FormatString(wLongsPerEntry*4) + L"字节";
pXSizeX->pRect = new CRect(); pXSizeX->pRect->CopyRect(pXSize8->pRect); pXSizeX->pRect->OffsetRect(0, (rect.Height() - 1)*(i+1));
pXSizeX->color = Color;
pDlg->ar.Add((CObArray*)pXSizeX);
INFO* pXDSX = new INFO();
if (bIndexSubType == 0)pXDSX->ID = L"可读取-指向索引块";
if (bIndexSubType == 1)pXDSX->ID = L"可读取-指向数据块";
if (bIndexSubType == 8)pXDSX->ID = L"可读取-条目是真实数据";
pXDSX->item = item;
pXDSX->STAR = offset;
pXDSX->LEN = size;
pXDSX->pRect = new CRect(); pXDSX->pRect->CopyRect(pXDS8->pRect); pXDSX->pRect->right = pXM6->pRect->right; pXDSX->pRect->OffsetRect(0, (rect.Height() - 1)*(i+1));
pXDSX->color = RGB(255, 150, 150);
pDlg->ar.Add((CObArray*)pXDSX);
pChunk->pRect->bottom = pXSizeX->pRect->bottom;
}
ULONGLONG Last = End - pDlg->F.GetPosition();
if (Last > 0)
{
pDlg->F.Seek(End, CFile::begin);
INFO* pX = new INFO();
pX->item= pDlg->FormatString(Last) + L"字节";
pX->pRect = new CRect(); pX->pRect->CopyRect(rect); pX->pRect->OffsetRect(rect.Width() - 1, 0); pX->pRect->MoveToY(pChunk->pRect->bottom-1);
pX->color = Color;
pDlg->ar.Add((CObArray*)pX);
INFO* pXM= new INFO();
pXM->pRect = new CRect(); pXM->pRect->CopyRect(pX->pRect); pXM->pRect->OffsetRect(pX->pRect->Width() - 1, 0);
pXM->color = Color;
pDlg->ar.Add((CObArray*)pXM);
pChunk->pRect->bottom = pXM->pRect->bottom;
}
return CPoint(pt.x, pChunk->pRect->bottom);
}
CPoint Read_hdrl_LIST(CPoint pt)
{
C解析AVIDlg* pDlg = (C解析AVIDlg*)theApp.m_pMainWnd;
COLORREF ChunkColor = RGB(240, 121, 50),Color= RGB(200, 200, 200);
pDlg->F.Seek(-12, CFile::current);
ULONGLONG uPos = pDlg->F.GetPosition();
LINE* pLine = new LINE();
pLine->star = CPoint(pt.x, pt.y - 1);
pLine->end = CPoint(970, pt.y - 1);
pLine->pos = pDlg->FormatString(uPos) + L"字节";
pDlg->arLine.Add((CObArray*)pLine);
char ch[5]; ch[4] = 0; DWORD mSize; char ch2[5]; ch2[4] = 0;
pDlg->F.Read(ch, 4); pDlg->F.Read(&mSize, 4);
ULONGLONG End = pDlg->F.GetPosition() + mSize;
pDlg->F.Read(ch2, 4);
CRect rect(pt.x, pt.y-1, pt.x + 121, pt.y + 14), rect1(pt.x + 121 - 1, pt.y-1, pt.x + 121 - 1 + 121, pt.y + 14);
INFO* phdrlListChunk = new INFO();
phdrlListChunk->item = L"hdrl_LIST\r\n" + pDlg->FormatString(8 + mSize) + L"字节";
phdrlListChunk->pRect = new CRect(); phdrlListChunk->pRect->CopyRect(rect);
phdrlListChunk->color = ChunkColor;
pDlg->ar.Add((CObArray*)phdrlListChunk);
INFO* pSize1 = new INFO();
pSize1->item = L"4字节";
pSize1->pRect = new CRect(); pSize1->pRect->CopyRect(rect1);
pSize1->color = Color;
pDlg->ar.Add((CObArray*)pSize1);
INFO* pSize2 = new INFO();
pSize2->item = L"4字节";
pSize2->pRect = new CRect(); pSize2->pRect->CopyRect(pSize1->pRect); pSize2->pRect->OffsetRect(0, rect1.Height()-1);
pSize2->color = Color;
pDlg->ar.Add((CObArray*)pSize2);
INFO* pSize3 = new INFO();
pSize3->item = L"4字节";
pSize3->pRect = new CRect(); pSize3->pRect->CopyRect(pSize2->pRect); pSize3->pRect->OffsetRect(0, rect1.Height() - 1);
pSize3->color = Color;
pDlg->ar.Add((CObArray*)pSize3);
INFO* pComment1 = new INFO();
pComment1->item = L"LIST";
pComment1->pRect = new CRect; pComment1->pRect->CopyRect(rect1); pComment1->pRect->OffsetRect(rect1.Width() - 1, 0);
pComment1->color = Color;
pDlg->ar.Add((CObArray*)pComment1);
INFO* pComment2 = new INFO();
pComment2->item = pDlg->FormatString(mSize);
pComment2->pRect = new CRect; pComment2->pRect->CopyRect(pComment1->pRect); pComment2->pRect->OffsetRect(0, rect1.Height() - 1);
pComment2->color = Color;
pDlg->ar.Add((CObArray*)pComment2);
INFO* pComment3 = new INFO();
pComment3->item = L"hdrl";
pComment3->pRect = new CRect(); pComment3->pRect->CopyRect(pComment2->pRect); pComment3->pRect->OffsetRect(0, rect1.Height() - 1);
pComment3->color = Color;
pDlg->ar.Add((CObArray*)pComment3);
CPoint point = Read_avih(CPoint(pSize3->pRect->left, pSize3->pRect->bottom));
Agan:
pDlg->F.Read(ch, 4); pDlg->F.Read(&mSize, 4);
if ((CString)ch == L"LIST")
{
pDlg->F.Read(ch, 4);
if ((CString)ch == L"strl")
{
point = Read_strl_LIST(point);
}
else
{
point = Read_X_LIST(point);
}
}
else
{
point = Read_X(point);
}
if (pDlg->F.GetPosition() < End)goto Agan;
if (pDlg->F.GetPosition() != End)
{
AfxMessageBox(L"读取hdrl_LIST未能正确到末尾");
pDlg->F.Seek(End, CFile::begin);
}
phdrlListChunk->pRect->bottom = point.y;
return CPoint(pt.x, point.y);
}
CPoint Read_avih(CPoint pt)
{
C解析AVIDlg* pDlg = (C解析AVIDlg*)theApp.m_pMainWnd;
COLORREF ChunkColor = RGB(199, 167, 116), Color = RGB(246, 225, 192);
ULONGLONG uPos = pDlg->F.GetPosition();
CString pos_str; pos_str.Format(L"%u字节", uPos);
LINE* pLine = new LINE();
pLine->star = CPoint(pt.x, pt.y-1);
pLine->end = CPoint(970, pt.y - 1);
pLine->pos = pos_str;
pDlg->arLine.Add((CObArray*)pLine);
char ch[5]; ch[4] = 0; DWORD mSize; AVIMAINHEADER AviHeader;
pDlg->F.Read(ch, 4);
pDlg->F.Read(&mSize, 4);
pDlg->F.Read(&AviHeader, mSize);
CRect rect(pt.x, pt.y - 1, pt.x + 121, pt.y + 14), rectW(pt.x, pt.y - 1, pt.x + 201 , pt.y + 14);
INFO* pavihCHUNK = new INFO();
pavihCHUNK->item = L"avih\r\n" + pDlg->FormatString(8 + mSize) + L"字节";
pavihCHUNK->pRect = new CRect(); pavihCHUNK->pRect->CopyRect(rect);
pavihCHUNK->color = ChunkColor;
pDlg->ar.Add((CObArray*)pavihCHUNK);
INFO* pavihSize1 = new INFO();
pavihSize1->item = L"4字节";
pavihSize1->pRect = new CRect(); pavihSize1->pRect->CopyRect(rect); pavihSize1->pRect->OffsetRect(rect.Width() - 1, 0);
pavihSize1->color = Color;
pDlg->ar.Add((CObArray*)pavihSize1);
INFO* pavihSize2 = new INFO();
pavihSize2->item = L"4字节";
pavihSize2->pRect = new CRect(); pavihSize2->pRect->CopyRect(pavihSize1->pRect); pavihSize2->pRect->OffsetRect(0, rect.Height() - 1);
pavihSize2->color = Color;
pDlg->ar.Add((CObArray*)pavihSize2);
INFO* pavihSize3 = new INFO();
pavihSize3->item = L"4字节";
pavihSize3->pRect = new CRect(); pavihSize3->pRect->CopyRect(pavihSize2->pRect); pavihSize3->pRect->OffsetRect(0, rect.Height() - 1);
pavihSize3->color = Color;
pDlg->ar.Add((CObArray*)pavihSize3);
INFO* pavihSize4 = new INFO();
pavihSize4->item = L"4字节";
pavihSize4->pRect = new CRect(); pavihSize4->pRect->CopyRect(pavihSize3->pRect); pavihSize4->pRect->OffsetRect(0, rect.Height() - 1);
pavihSize4->color = Color;
pDlg->ar.Add((CObArray*)pavihSize4);
INFO* pavihSize5 = new INFO();
pavihSize5->item = L"4字节";
pavihSize5->pRect = new CRect(); pavihSize5->pRect->CopyRect(pavihSize4->pRect); pavihSize5->pRect->OffsetRect(0, rect.Height() - 1);
pavihSize5->color = Color;
pDlg->ar.Add((CObArray*)pavihSize5);
INFO* pavihSize6 = new INFO();
pavihSize6->item = L"4字节";
pavihSize6->pRect = new CRect(); pavihSize6->pRect->CopyRect(pavihSize5->pRect); pavihSize6->pRect->OffsetRect(0, rect.Height() - 1);
pavihSize6->color = Color;
pDlg->ar.Add((CObArray*)pavihSize6);
INFO* pavihSize7 = new INFO();
pavihSize7->item = L"4字节";
pavihSize7->pRect = new CRect(); pavihSize7->pRect->CopyRect(pavihSize6->pRect); pavihSize7->pRect->OffsetRect(0, rect.Height() - 1);
pavihSize7->color = Color;
pDlg->ar.Add((CObArray*)pavihSize7);
INFO* pavihSize8 = new INFO();
pavihSize8->item = L"4字节";
pavihSize8->pRect = new CRect(); pavihSize8->pRect->CopyRect(pavihSize7->pRect); pavihSize8->pRect->OffsetRect(0, rect.Height() - 1);
pavihSize8->color = Color;
pDlg->ar.Add((CObArray*)pavihSize8);
INFO* pavihSize9 = new INFO();
pavihSize9->item = L"4字节";
pavihSize9->pRect = new CRect(); pavihSize9->pRect->CopyRect(pavihSize8->pRect); pavihSize9->pRect->OffsetRect(0, rect.Height() - 1);
pavihSize9->color = Color;
pDlg->ar.Add((CObArray*)pavihSize9);
INFO* pavihSize10 = new INFO();
pavihSize10->item = L"4字节";
pavihSize10->pRect = new CRect(); pavihSize10->pRect->CopyRect(pavihSize9->pRect); pavihSize10->pRect->OffsetRect(0, rect.Height() - 1);
pavihSize10->color = Color;
pDlg->ar.Add((CObArray*)pavihSize10);
INFO* pavihSize11 = new INFO();
pavihSize11->item = L"4字节";
pavihSize11->pRect = new CRect(); pavihSize11->pRect->CopyRect(pavihSize10->pRect); pavihSize11->pRect->OffsetRect(0, rect.Height() - 1);
pavihSize11->color = Color;
pDlg->ar.Add((CObArray*)pavihSize11);
INFO* pavihSize12 = new INFO();
pavihSize12->item = L"4字节";
pavihSize12->pRect = new CRect(); pavihSize12->pRect->CopyRect(pavihSize11->pRect); pavihSize12->pRect->OffsetRect(0, rect.Height() - 1);
pavihSize12->color = Color;
pDlg->ar.Add((CObArray*)pavihSize12);
INFO* pavihSize13 = new INFO();
pavihSize13->item = L"16字节";
pavihSize13->pRect = new CRect(); pavihSize13->pRect->CopyRect(pavihSize12->pRect); pavihSize13->pRect->OffsetRect(0, rect.Height() - 1);
pavihSize13->color = Color;
pDlg->ar.Add((CObArray*)pavihSize13);
INFO* pavihDes1 = new INFO();
pavihDes1->item = L"avih";
pavihDes1->pRect = new CRect(); pavihDes1->pRect->CopyRect(rect); pavihDes1->pRect->OffsetRect((rect.Width() - 1)*2, 0);
pavihDes1->color = Color;
pDlg->ar.Add((CObArray*)pavihDes1);
INFO* pavihDes2 = new INFO();
pavihDes2->item = pDlg->FormatString(mSize);
pavihDes2->pRect = new CRect(); pavihDes2->pRect->CopyRect(pavihDes1->pRect); pavihDes2->pRect->OffsetRect(0, rect.Height()-1);
pavihDes2->color = Color;
pDlg->ar.Add((CObArray*)pavihDes2);
INFO* pavihDes3 = new INFO();
pavihDes3->item = pDlg->FormatString(AviHeader.dwMicroSecPerFrame);
pavihDes3->pRect = new CRect(); pavihDes3->pRect->CopyRect(pavihDes2->pRect); pavihDes3->pRect->OffsetRect(0, rect.Height() - 1);
pavihDes3->color = Color;
pDlg->ar.Add((CObArray*)pavihDes3);
INFO* pavihDes4 = new INFO();
pavihDes4->item = pDlg->FormatString(AviHeader.dwMaxBytesPerSec);
pavihDes4->pRect = new CRect(); pavihDes4->pRect->CopyRect(pavihDes3->pRect); pavihDes4->pRect->OffsetRect(0, rect.Height() - 1);
pavihDes4->color = Color;
pDlg->ar.Add((CObArray*)pavihDes4);
INFO* pavihDes5 = new INFO();
pavihDes5->item = pDlg->FormatString(AviHeader.dwPaddingGranularity);
pavihDes5->pRect = new CRect(); pavihDes5->pRect->CopyRect(pavihDes4->pRect); pavihDes5->pRect->OffsetRect(0, rect.Height() - 1);
pavihDes5->color = Color;
pDlg->ar.Add((CObArray*)pavihDes5);
INFO* pavihDes6 = new INFO();
pavihDes6->item = pDlg->FormatString(AviHeader.dwFlags);
pavihDes6->pRect = new CRect(); pavihDes6->pRect->CopyRect(pavihDes5->pRect); pavihDes6->pRect->OffsetRect(0, rect.Height() - 1);
pavihDes6->color = Color;
pDlg->ar.Add((CObArray*)pavihDes6);
INFO* pavihDes7 = new INFO();
pavihDes7->item = pDlg->FormatString(AviHeader.dwTotalFrames);
pavihDes7->pRect = new CRect(); pavihDes7->pRect->CopyRect(pavihDes6->pRect); pavihDes7->pRect->OffsetRect(0, rect.Height() - 1);
pavihDes7->color = Color;
pDlg->ar.Add((CObArray*)pavihDes7);
INFO* pavihDes8 = new INFO();
pavihDes8->item = pDlg->FormatString(AviHeader.dwInitialFrames);
pavihDes8->pRect = new CRect(); pavihDes8->pRect->CopyRect(pavihDes7->pRect); pavihDes8->pRect->OffsetRect(0, rect.Height() - 1);
pavihDes8->color = Color;
pDlg->ar.Add((CObArray*)pavihDes8);
INFO* pavihDes9 = new INFO();
pavihDes9->item = pDlg->FormatString(AviHeader.dwStreams);
pavihDes9->pRect = new CRect(); pavihDes9->pRect->CopyRect(pavihDes8->pRect); pavihDes9->pRect->OffsetRect(0, rect.Height() - 1);
pavihDes9->color = Color;
pDlg->ar.Add((CObArray*)pavihDes9);
INFO* pavihDes10 = new INFO();
pavihDes10->item = pDlg->FormatString(AviHeader.dwSuggestedBufferSize);
pavihDes10->pRect = new CRect(); pavihDes10->pRect->CopyRect(pavihDes9->pRect); pavihDes10->pRect->OffsetRect(0, rect.Height() - 1);
pavihDes10->color = Color;
pDlg->ar.Add((CObArray*)pavihDes10);
INFO* pavihDes11 = new INFO();
pavihDes11->item = pDlg->FormatString(AviHeader.dwWidth);
pavihDes11->pRect = new CRect(); pavihDes11->pRect->CopyRect(pavihDes10->pRect); pavihDes11->pRect->OffsetRect(0, rect.Height() - 1);
pavihDes11->color = Color;
pDlg->ar.Add((CObArray*)pavihDes11);
INFO* pavihDes12 = new INFO();
pavihDes12->item = pDlg->FormatString(AviHeader.dwHeight);
pavihDes12->pRect = new CRect(); pavihDes12->pRect->CopyRect(pavihDes11->pRect); pavihDes12->pRect->OffsetRect(0, rect.Height() - 1);
pavihDes12->color = Color;
pDlg->ar.Add((CObArray*)pavihDes12);
INFO* pavihDes13 = new INFO();
pavihDes13->item.Format(L"{%u,%u,%u,%u}", AviHeader.dwReserved[0], AviHeader.dwReserved[1], AviHeader.dwReserved[2], AviHeader.dwReserved[3]);
pavihDes13->pRect = new CRect(); pavihDes13->pRect->CopyRect(pavihDes12->pRect); pavihDes13->pRect->OffsetRect(0, rect.Height() - 1);
pavihDes13->color = Color;
pDlg->ar.Add((CObArray*)pavihDes13);
INFO* pavihSm1 = new INFO();
pavihSm1->item = L"帧持续时间,单位微秒";
pavihSm1->pRect = new CRect(); pavihSm1->pRect->CopyRect(rectW); pavihSm1->pRect->OffsetRect((rect.Width() - 1)*3, (rect.Height()-1)*2);
pavihSm1->color = Color;
pDlg->ar.Add((CObArray*)pavihSm1);
INFO* pavihSm2 = new INFO();
pavihSm2->item = L"传输率";
pavihSm2->pRect = new CRect(); pavihSm2->pRect->CopyRect(pavihSm1->pRect); pavihSm2->pRect->OffsetRect(0, rect.Height() - 1);
pavihSm2->color = Color;
pDlg->ar.Add((CObArray*)pavihSm2);
INFO* pavihSm3 = new INFO();
pavihSm3->item = L"块对齐";
pavihSm3->pRect = new CRect(); pavihSm3->pRect->CopyRect(pavihSm2->pRect); pavihSm3->pRect->OffsetRect(0, rect.Height() - 1);
pavihSm3->color = Color;
pDlg->ar.Add((CObArray*)pavihSm3);
INFO* pavihSm4 = new INFO();
pavihSm4->item = L"文件属性";
pavihSm4->pRect = new CRect(); pavihSm4->pRect->CopyRect(pavihSm3->pRect); pavihSm4->pRect->OffsetRect(0, rect.Height() - 1);
pavihSm4->color = Color;
pDlg->ar.Add((CObArray*)pavihSm4);
INFO* pavihSm5 = new INFO();
pavihSm5->item = L"帧总数";
pavihSm5->pRect = new CRect(); pavihSm5->pRect->CopyRect(pavihSm4->pRect); pavihSm5->pRect->OffsetRect(0, rect.Height() - 1);
pavihSm5->color = Color;
pDlg->ar.Add((CObArray*)pavihSm5);
INFO* pavihSm6 = new INFO();
pavihSm6->item = L"开始播放前需要多少帧";
pavihSm6->pRect = new CRect(); pavihSm6->pRect->CopyRect(pavihSm5->pRect); pavihSm6->pRect->OffsetRect(0, rect.Height() - 1);
pavihSm6->color = Color;
pDlg->ar.Add((CObArray*)pavihSm6);
INFO* pavihSm7 = new INFO();
pavihSm7->item = L"流数量";
pavihSm7->pRect = new CRect(); pavihSm7->pRect->CopyRect(pavihSm6->pRect); pavihSm7->pRect->OffsetRect(0, rect.Height() - 1);
pavihSm7->color = Color;
pDlg->ar.Add((CObArray*)pavihSm7);
INFO* pavihSm8 = new INFO();
pavihSm8->item = L"建议的缓冲区的大小";
pavihSm8->pRect = new CRect(); pavihSm8->pRect->CopyRect(pavihSm7->pRect); pavihSm8->pRect->OffsetRect(0, rect.Height() - 1);
pavihSm8->color = Color;
pDlg->ar.Add((CObArray*)pavihSm8);
INFO* pavihSm9 = new INFO();
pavihSm9->item = L"图像的宽度";
pavihSm9->pRect = new CRect(); pavihSm9->pRect->CopyRect(pavihSm8->pRect); pavihSm9->pRect->OffsetRect(0, rect.Height() - 1);
pavihSm9->color = Color;
pDlg->ar.Add((CObArray*)pavihSm9);
INFO* pavihSm10 = new INFO();
pavihSm10->item = L"图像的高度";
pavihSm10->pRect = new CRect(); pavihSm10->pRect->CopyRect(pavihSm9->pRect); pavihSm10->pRect->OffsetRect(0, rect.Height() - 1);
pavihSm10->color = Color;
pDlg->ar.Add((CObArray*)pavihSm10);
INFO* pavihSm11 = new INFO();
pavihSm11->item = L"DWORD[4],保留";
pavihSm11->pRect = new CRect(); pavihSm11->pRect->CopyRect(pavihSm10->pRect); pavihSm11->pRect->OffsetRect(0, rect.Height() - 1);
pavihSm11->color = Color;
pDlg->ar.Add((CObArray*)pavihSm11);
CPoint point;
point.x = pt.x; point.y = pavihSize13->pRect->bottom; pavihCHUNK->pRect->bottom = pavihSize13->pRect->bottom;
return point;
}
CPoint Read_strl_LIST(CPoint pt)
{
C解析AVIDlg* pDlg = (C解析AVIDlg*)theApp.m_pMainWnd;
COLORREF ChunkColor = RGB(143, 172, 138), Color = RGB(200, 200, 200);
pDlg->F.Seek(-12, CFile::current);
ULONGLONG uPos = pDlg->F.GetPosition();
LINE* pLine = new LINE();
pLine->star = CPoint(pt.x, pt.y - 1);
pLine->end = CPoint(970, pt.y - 1);
pLine->pos = pDlg->FormatString(uPos) + L"字节";
pDlg->arLine.Add((CObArray*)pLine);
char ch[5]; ch[4] = 0; DWORD mSize; char ch2[5]; ch2[4] = 0;
pDlg->F.Read(ch, 4); pDlg->F.Read(&mSize, 4);
ULONGLONG End = pDlg->F.GetPosition() + mSize;
pDlg->F.Read(ch2, 4);
CRect rect(pt.x, pt.y-1, pt.x + 121, pt.y + 14), rect1(pt.x + 121 - 1, pt.y-1, pt.x + 121 - 1 + 121, pt.y + 14);
INFO* pstrl_LISTCHUNK = new INFO();
pstrl_LISTCHUNK->item = L"strl_LIST\r\n" + pDlg->FormatString(8 + mSize) + L"字节";
pstrl_LISTCHUNK->pRect = new CRect(); pstrl_LISTCHUNK->pRect->CopyRect(rect);
pstrl_LISTCHUNK->color = ChunkColor;
pDlg->ar.Add((CObArray*)pstrl_LISTCHUNK);
INFO* pMSize1 = new INFO();
pMSize1->item = L"4字节";
pMSize1->pRect = new CRect(); pMSize1->pRect->CopyRect(rect1);
pMSize1->color = Color;
pDlg->ar.Add((CObArray*)pMSize1);
INFO* pMSize2 = new INFO();
pMSize2->item = L"4字节";
pMSize2->pRect = new CRect(); pMSize2->pRect->CopyRect(pMSize1->pRect); pMSize2->pRect->OffsetRect(0, rect1.Height()-1);
pMSize2->color = Color;
pDlg->ar.Add((CObArray*)pMSize2);
INFO* pMSize3 = new INFO();
pMSize3->item = L"4字节";
pMSize3->pRect = new CRect(); pMSize3->pRect->CopyRect(pMSize2->pRect); pMSize3->pRect->OffsetRect(0, rect1.Height() - 1);
pMSize3->color = Color;
pDlg->ar.Add((CObArray*)pMSize3);
INFO* pSM1 = new INFO();
pSM1->item = L"LIST";
pSM1->pRect = new CRect(); pSM1->pRect->CopyRect(pMSize1->pRect); pSM1->pRect->OffsetRect(rect1.Width() - 1, 0);
pSM1->color = Color;
pDlg->ar.Add((CObArray*)pSM1);
INFO* pSM2 = new INFO();
pSM2->item = pDlg->FormatString(mSize);
pSM2->pRect = new CRect(); pSM2->pRect->CopyRect(pSM1->pRect); pSM2->pRect->OffsetRect(0, 14);
pSM2->color = Color;
pDlg->ar.Add((CObArray*)pSM2);
INFO* pSM3 = new INFO();
pSM3->item = L"strl";
pSM3->pRect = new CRect(); pSM3->pRect->CopyRect(pSM2->pRect); pSM3->pRect->OffsetRect(0, 14);
pSM3->color = Color;
pDlg->ar.Add((CObArray*)pSM3);
CString Format;
CPoint point = Read_strh(CPoint(pt.x, pSM3->pRect->bottom), Format);
point = Read_strf(point, Format);
if(pDlg->F.GetPosition() == End)goto END;
Agan:
pDlg->F.Read(ch, 4);
pDlg->F.Read(&mSize, 4);
if ((CString)ch == L"indx")
{
point = Read_indx(point);
}
else
{
point = Read_X(point);
}
if (pDlg->F.GetPosition() < End)goto Agan;
pstrl_LISTCHUNK->pRect->bottom = point.y;
if (End != pDlg->F.GetPosition())
{
MessageBox(0, L"读取strl_LIST出错", L"解析AVI", MB_OK);
pDlg->F.Seek(End, CFile::begin);
}
END:
pstrl_LISTCHUNK->pRect->bottom = point.y; point.x = pt.x;
return point;
}
CPoint Read_strh(CPoint pt, CString& Format)
{
C解析AVIDlg* pDlg = (C解析AVIDlg*)theApp.m_pMainWnd;
COLORREF ChunkColor = RGB(138, 144, 172), Color = RGB(209, 213, 227);
ULONGLONG uPos = pDlg->F.GetPosition();
LINE* pLine = new LINE();
pLine->star = CPoint(pt.x + 120, pt.y - 1);
pLine->end = CPoint(970, pt.y - 1);
pLine->pos = pDlg->FormatString(uPos) + L"字节";
pDlg->arLine.Add((CObArray*)pLine);
char ch[5]; ch[4] = 0; DWORD mSize;
pDlg->F.Read(ch, 4); pDlg->F.Read(&mSize, 4);
strh_struct strh;
pDlg->F.Read(&strh, mSize);
CRect rect(pt.x + 121 - 1, pt.y - 1, pt.x + 121 - 1 + 121, pt.y + 14), rectW(pt.x + 121 - 1, pt.y - 1, pt.x + 121 - 1 + 201, pt.y + 14);
INFO* pstrhCHUNK = new INFO();
pstrhCHUNK->item = L"strh\r\n" + pDlg->FormatString(8 + mSize) + L"字节";
pstrhCHUNK->pRect = new CRect(); pstrhCHUNK->pRect->CopyRect(rect);
pstrhCHUNK->color = ChunkColor;
pDlg->ar.Add((CObArray*)pstrhCHUNK);
INFO* pstrhSize1 = new INFO();
pstrhSize1->item = L"4字节";
pstrhSize1->pRect = new CRect(); pstrhSize1->pRect->CopyRect(rect); pstrhSize1->pRect->OffsetRect(rect.Width()-1, 0);
pstrhSize1->color = Color;
pDlg->ar.Add((CObArray*)pstrhSize1);
INFO* pstrhSize2 = new INFO();
pstrhSize2->item = L"4字节";
pstrhSize2->pRect = new CRect(); pstrhSize2->pRect->CopyRect(pstrhSize1->pRect); pstrhSize2->pRect->OffsetRect(0, rect.Height()-1);
pstrhSize2->color = Color;
pDlg->ar.Add((CObArray*)pstrhSize2);
INFO* pstrhSize3 = new INFO();
pstrhSize3->item = L"4字节";
pstrhSize3->pRect = new CRect(); pstrhSize3->pRect->CopyRect(pstrhSize2->pRect); pstrhSize3->pRect->OffsetRect(0, rect.Height() - 1);
pstrhSize3->color = Color;
pDlg->ar.Add((CObArray*)pstrhSize3);
INFO* pstrhSize4 = new INFO();
pstrhSize4->item = L"4字节";
pstrhSize4->pRect = new CRect(); pstrhSize4->pRect->CopyRect(pstrhSize3->pRect); pstrhSize4->pRect->OffsetRect(0, rect.Height() - 1);
pstrhSize4->color = Color;
pDlg->ar.Add((CObArray*)pstrhSize4);
INFO* pstrhSize5 = new INFO();
pstrhSize5->item = L"4字节";
pstrhSize5->pRect = new CRect(); pstrhSize5->pRect->CopyRect(pstrhSize4->pRect); pstrhSize5->pRect->OffsetRect(0, rect.Height() - 1);
pstrhSize5->color = Color;
pDlg->ar.Add((CObArray*)pstrhSize5);
INFO* pstrhSize6 = new INFO();
pstrhSize6->item = L"2字节";
pstrhSize6->pRect = new CRect(); pstrhSize6->pRect->CopyRect(pstrhSize5->pRect); pstrhSize6->pRect->OffsetRect(0, rect.Height() - 1);
pstrhSize6->color = Color;
pDlg->ar.Add((CObArray*)pstrhSize6);
INFO* pstrhSize7 = new INFO();
pstrhSize7->item = L"2字节";
pstrhSize7->pRect = new CRect(); pstrhSize7->pRect->CopyRect(pstrhSize6->pRect); pstrhSize7->pRect->OffsetRect(0, rect.Height() - 1);
pstrhSize7->color = Color;
pDlg->ar.Add((CObArray*)pstrhSize7);
INFO* pstrhSize8 = new INFO();
pstrhSize8->item = L"4字节";
pstrhSize8->pRect = new CRect(); pstrhSize8->pRect->CopyRect(pstrhSize7->pRect); pstrhSize8->pRect->OffsetRect(0, rect.Height() - 1);
pstrhSize8->color = Color;
pDlg->ar.Add((CObArray*)pstrhSize8);
INFO* pstrhSize9 = new INFO();
pstrhSize9->item = L"4字节";
pstrhSize9->pRect = new CRect(); pstrhSize9->pRect->CopyRect(pstrhSize8->pRect); pstrhSize9->pRect->OffsetRect(0, rect.Height() - 1);
pstrhSize9->color = Color;
pDlg->ar.Add((CObArray*)pstrhSize9);
INFO* pstrhSize10 = new INFO();
pstrhSize10->item = L"4字节";
pstrhSize10->pRect = new CRect(); pstrhSize10->pRect->CopyRect(pstrhSize9->pRect); pstrhSize10->pRect->OffsetRect(0, rect.Height() - 1);
pstrhSize10->color = Color;
pDlg->ar.Add((CObArray*)pstrhSize10);
INFO* pstrhSize11 = new INFO();
pstrhSize11->item = L"4字节";
pstrhSize11->pRect = new CRect(); pstrhSize11->pRect->CopyRect(pstrhSize10->pRect); pstrhSize11->pRect->OffsetRect(0, rect.Height() - 1);
pstrhSize11->color = Color;
pDlg->ar.Add((CObArray*)pstrhSize11);
INFO* pstrhSize12 = new INFO();
pstrhSize12->item = L"4字节";
pstrhSize12->pRect = new CRect(); pstrhSize12->pRect->CopyRect(pstrhSize11->pRect); pstrhSize12->pRect->OffsetRect(0, rect.Height() - 1);
pstrhSize12->color = Color;
pDlg->ar.Add((CObArray*)pstrhSize12);
INFO* pstrhSize13 = new INFO();
pstrhSize13->item = L"4字节";
pstrhSize13->pRect = new CRect(); pstrhSize13->pRect->CopyRect(pstrhSize12->pRect); pstrhSize13->pRect->OffsetRect(0, rect.Height() - 1);
pstrhSize13->color = Color;
pDlg->ar.Add((CObArray*)pstrhSize13);
INFO* pstrhSize14 = new INFO();
pstrhSize14->item = L"4字节";
pstrhSize14->pRect = new CRect(); pstrhSize14->pRect->CopyRect(pstrhSize13->pRect); pstrhSize14->pRect->OffsetRect(0, rect.Height() - 1);
pstrhSize14->color = Color;
pDlg->ar.Add((CObArray*)pstrhSize14);
INFO* pstrhSize15 = new INFO();
pstrhSize15->item = L"4字节";
pstrhSize15->pRect = new CRect(); pstrhSize15->pRect->CopyRect(pstrhSize14->pRect); pstrhSize15->pRect->OffsetRect(0, rect.Height() - 1);
pstrhSize15->color = Color;
pDlg->ar.Add((CObArray*)pstrhSize15);
INFO* pstrhSize16 = new INFO();
pstrhSize16->item = L"8字节";
pstrhSize16->pRect = new CRect(); pstrhSize16->pRect->CopyRect(pstrhSize15->pRect); pstrhSize16->pRect->OffsetRect(0, rect.Height() - 1);
pstrhSize16->color = Color;
pDlg->ar.Add((CObArray*)pstrhSize16);
INFO* pstrhSM1 = new INFO();
pstrhSM1->item = (CString)ch;
pstrhSM1->pRect = new CRect(); pstrhSM1->pRect->CopyRect(pstrhSize1->pRect); pstrhSM1->pRect->OffsetRect(rect.Width() - 1, 0);
pstrhSM1->color = Color;
pDlg->ar.Add((CObArray*)pstrhSM1);
INFO* pstrhSM2 = new INFO();
pstrhSM2->item = pDlg->FormatString(mSize);
pstrhSM2->pRect = new CRect(); pstrhSM2->pRect->CopyRect(pstrhSM1->pRect); pstrhSM2->pRect->OffsetRect(0, rect.Height()-1);
pstrhSM2->color = Color;
pDlg->ar.Add((CObArray*)pstrhSM2);
INFO* pstrhSM3 = new INFO();
char ch2[5]; ch2[4] = 0;
CopyMemory(ch2, strh.fccType, 4);
pstrhSM3->item = Format = (CString)ch2;
pstrhSM3->pRect = new CRect(); pstrhSM3->pRect->CopyRect(pstrhSM2->pRect); pstrhSM3->pRect->OffsetRect(0, rect.Height() - 1);
pstrhSM3->color = Color;
pDlg->ar.Add((CObArray*)pstrhSM3);
INFO* pstrhSM4 = new INFO();
if ((CString)ch2 == L"vids")
{
char ch3[5]; ch3[4] = 0;
CopyMemory(ch3, strh.fccHandler, 4);
pstrhSM4->item = (CString)ch3;
}
else
{
pstrhSM4->item.Format(L"%u", (DWORD)strh.fccHandler);
}
pstrhSM4->pRect = new CRect(); pstrhSM4->pRect->CopyRect(pstrhSM3->pRect); pstrhSM4->pRect->OffsetRect(0, rect.Height() - 1);
pstrhSM4->color = Color;
pDlg->ar.Add((CObArray*)pstrhSM4);
INFO* pstrhSM5 = new INFO();
pstrhSM5->item = pDlg->FormatString(strh.dwFlags);
pstrhSM5->pRect = new CRect(); pstrhSM5->pRect->CopyRect(pstrhSM4->pRect); pstrhSM5->pRect->OffsetRect(0, rect.Height() - 1);
pstrhSM5->color = Color;
pDlg->ar.Add((CObArray*)pstrhSM5);
INFO* pstrhSM6 = new INFO();
pstrhSM6->item = pDlg->FormatString(strh.wPriority);
pstrhSM6->pRect = new CRect(); pstrhSM6->pRect->CopyRect(pstrhSM5->pRect); pstrhSM6->pRect->OffsetRect(0, rect.Height() - 1);
pstrhSM6->color = Color;
pDlg->ar.Add((CObArray*)pstrhSM6);
INFO* pstrhSM7 = new INFO();
pstrhSM7->item = pDlg->FormatString(strh.wLanguage);
pstrhSM7->pRect = new CRect(); pstrhSM7->pRect->CopyRect(pstrhSM6->pRect); pstrhSM7->pRect->OffsetRect(0, rect.Height() - 1);
pstrhSM7->color = Color;
pDlg->ar.Add((CObArray*)pstrhSM7);
INFO* pstrhSM8 = new INFO();
pstrhSM8->item = pDlg->FormatString(strh.dwInitialFrames);
pstrhSM8->pRect = new CRect(); pstrhSM8->pRect->CopyRect(pstrhSM7->pRect); pstrhSM8->pRect->OffsetRect(0, rect.Height() - 1);
pstrhSM8->color = Color;
pDlg->ar.Add((CObArray*)pstrhSM8);
INFO* pstrhSM9 = new INFO();
pstrhSM9->item = pDlg->FormatString(strh.dwScale);
pstrhSM9->pRect = new CRect(); pstrhSM9->pRect->CopyRect(pstrhSM8->pRect); pstrhSM9->pRect->OffsetRect(0, rect.Height() - 1);
pstrhSM9->color = Color;
pDlg->ar.Add((CObArray*)pstrhSM9);
INFO* pstrhSM10 = new INFO();
pstrhSM10->item = pDlg->FormatString(strh.dwRate);
pstrhSM10->pRect = new CRect(); pstrhSM10->pRect->CopyRect(pstrhSM9->pRect); pstrhSM10->pRect->OffsetRect(0, rect.Height() - 1);
pstrhSM10->color = Color;
pDlg->ar.Add((CObArray*)pstrhSM10);
INFO* pstrhSM11 = new INFO();
pstrhSM11->item = pDlg->FormatString(strh.dwStart);
pstrhSM11->pRect = new CRect(); pstrhSM11->pRect->CopyRect(pstrhSM10->pRect); pstrhSM11->pRect->OffsetRect(0, rect.Height() - 1);
pstrhSM11->color = Color;
pDlg->ar.Add((CObArray*)pstrhSM11);
INFO* pstrhSM12 = new INFO();
pstrhSM12->item = pDlg->FormatString(strh.dwLength);
pstrhSM12->pRect = new CRect(); pstrhSM12->pRect->CopyRect(pstrhSM11->pRect); pstrhSM12->pRect->OffsetRect(0, rect.Height() - 1);
pstrhSM12->color = Color;
pDlg->ar.Add((CObArray*)pstrhSM12);
INFO* pstrhSM13 = new INFO();
pstrhSM13->item = pDlg->FormatString(strh.dwSuggestedBufferSize);
pstrhSM13->pRect = new CRect(); pstrhSM13->pRect->CopyRect(pstrhSM12->pRect); pstrhSM13->pRect->OffsetRect(0, rect.Height() - 1);
pstrhSM13->color = Color;
pDlg->ar.Add((CObArray*)pstrhSM13);
INFO* pstrhSM14 = new INFO();
if (strh.dwQuality == 4294967295)
pstrhSM14->item = L"-1";
else
pstrhSM14->item = pDlg->FormatString(strh.dwQuality);
pstrhSM14->pRect = new CRect(); pstrhSM14->pRect->CopyRect(pstrhSM13->pRect); pstrhSM14->pRect->OffsetRect(0, rect.Height() - 1);
pstrhSM14->color = Color;
pDlg->ar.Add((CObArray*)pstrhSM14);
INFO* pstrhSM15 = new INFO();
pstrhSM15->item = pDlg->FormatString(strh.dwSampleSize);
pstrhSM15->pRect = new CRect(); pstrhSM15->pRect->CopyRect(pstrhSM14->pRect); pstrhSM15->pRect->OffsetRect(0, rect.Height() - 1);
pstrhSM15->color = Color;
pDlg->ar.Add((CObArray*)pstrhSM15);
INFO* pstrhSM16 = new INFO();
pstrhSM16->item.Format(L"{%d,%d,%d,%d}", strh.rcFrame.left, strh.rcFrame.top, strh.rcFrame.right, strh.rcFrame.bottom);
pstrhSM16->pRect = new CRect(); pstrhSM16->pRect->CopyRect(pstrhSM15->pRect); pstrhSM16->pRect->OffsetRect(0, rect.Height() - 1);
pstrhSM16->color = Color;
pDlg->ar.Add((CObArray*)pstrhSM16);
INFO* pstrhZS1 = new INFO();
if ((CString)ch2 == L"vids")
pstrhZS1->item = L"视频";
else if ((CString)ch2 == L"auds")
pstrhZS1->item = L"音频";
else
pstrhZS1->item = (CString)ch2;
pstrhZS1->pRect = new CRect(); pstrhZS1->pRect->CopyRect(rectW); pstrhZS1->pRect->OffsetRect((rect.Width() - 1)*3, (rect.Height()-1)*2);
pstrhZS1->color = Color;
pDlg->ar.Add((CObArray*)pstrhZS1);
INFO* pstrhZS2 = new INFO();
pstrhZS2->item = L"处理器";
pstrhZS2->pRect = new CRect(); pstrhZS2->pRect->CopyRect(pstrhZS1->pRect); pstrhZS2->pRect->OffsetRect(0, rectW.Height()-1);
pstrhZS2->color = Color;
pDlg->ar.Add((CObArray*)pstrhZS2);
INFO* pstrhZS3 = new INFO();
pstrhZS3->item = L"标志";
pstrhZS3->pRect = new CRect(); pstrhZS3->pRect->CopyRect(pstrhZS2->pRect); pstrhZS3->pRect->OffsetRect(0, rectW.Height() - 1);
pstrhZS3->color = Color;
pDlg->ar.Add((CObArray*)pstrhZS3);
INFO* pstrhZS4 = new INFO();
pstrhZS4->item = L"流的优先级";
pstrhZS4->pRect = new CRect(); pstrhZS4->pRect->CopyRect(pstrhZS3->pRect); pstrhZS4->pRect->OffsetRect(0, rectW.Height() - 1);
pstrhZS4->color = Color;
pDlg->ar.Add((CObArray*)pstrhZS4);
INFO* pstrhZS5 = new INFO();
pstrhZS5->item = L"语言";
pstrhZS5->pRect = new CRect(); pstrhZS5->pRect->CopyRect(pstrhZS4->pRect); pstrhZS5->pRect->OffsetRect(0, rectW.Height() - 1);
pstrhZS5->color = Color;
pDlg->ar.Add((CObArray*)pstrhZS5);
INFO* pstrhZS6 = new INFO();
pstrhZS6->item = L"初始帧";
pstrhZS6->pRect = new CRect(); pstrhZS6->pRect->CopyRect(pstrhZS5->pRect); pstrhZS6->pRect->OffsetRect(0, rectW.Height() - 1);
pstrhZS6->color = Color;
pDlg->ar.Add((CObArray*)pstrhZS6);
INFO* pstrhZS7 = new INFO();
pstrhZS7->item = L"采样率分母";
pstrhZS7->pRect = new CRect(); pstrhZS7->pRect->CopyRect(pstrhZS6->pRect); pstrhZS7->pRect->OffsetRect(0, rectW.Height() - 1);
pstrhZS7->color = Color;
pDlg->ar.Add((CObArray*)pstrhZS7);
INFO* pstrhZS8 = new INFO();
pstrhZS8->item = L"采样率分子";
pstrhZS8->pRect = new CRect(); pstrhZS8->pRect->CopyRect(pstrhZS7->pRect); pstrhZS8->pRect->OffsetRect(0, rectW.Height() - 1);
pstrhZS8->color = Color;
pDlg->ar.Add((CObArray*)pstrhZS8);
INFO* pstrhZS9 = new INFO();
pstrhZS9->item = L"流的开始时间";
pstrhZS9->pRect = new CRect(); pstrhZS9->pRect->CopyRect(pstrhZS8->pRect); pstrhZS9->pRect->OffsetRect(0, rectW.Height() - 1);
pstrhZS9->color = Color;
pDlg->ar.Add((CObArray*)pstrhZS9);
INFO* pstrhZS10 = new INFO();
if ((CString)ch2 == L"vids")
pstrhZS10->item = L"流的长度,以视频帧为单位";
else if ((CString)ch2 == L"auds")
pstrhZS10->item = L"流的长度,以音频帧为单位";
pstrhZS10->pRect = new CRect(); pstrhZS10->pRect->CopyRect(pstrhZS9->pRect); pstrhZS10->pRect->OffsetRect(0, rectW.Height() - 1);
pstrhZS10->color = Color;
pDlg->ar.Add((CObArray*)pstrhZS10);
INFO* pstrhZS11 = new INFO();
pstrhZS11->item = L"建议的缓冲区大小";
pstrhZS11->pRect = new CRect(); pstrhZS11->pRect->CopyRect(pstrhZS10->pRect); pstrhZS11->pRect->OffsetRect(0, rectW.Height() - 1);
pstrhZS11->color = Color;
pDlg->ar.Add((CObArray*)pstrhZS11);
INFO* pstrhZS12 = new INFO();
pstrhZS12->item = L"解压缩质量参数";
pstrhZS12->pRect = new CRect(); pstrhZS12->pRect->CopyRect(pstrhZS11->pRect); pstrhZS12->pRect->OffsetRect(0, rectW.Height() - 1);
pstrhZS12->color = Color;
pDlg->ar.Add((CObArray*)pstrhZS12);
INFO* pstrhZS13 = new INFO();
pstrhZS13->item = L"单个数据样本的大小";
pstrhZS13->pRect = new CRect(); pstrhZS13->pRect->CopyRect(pstrhZS12->pRect); pstrhZS13->pRect->OffsetRect(0, rectW.Height() - 1);
pstrhZS13->color = Color;
pDlg->ar.Add((CObArray*)pstrhZS13);
INFO* pstrhZS14 = new INFO();
pstrhZS14->item = L"short[4],目标矩形";
pstrhZS14->pRect = new CRect(); pstrhZS14->pRect->CopyRect(pstrhZS13->pRect); pstrhZS14->pRect->OffsetRect(0, rectW.Height() - 1);
pstrhZS14->color = Color;
pDlg->ar.Add((CObArray*)pstrhZS14);
CPoint point;
point.x = pt.x + 121-1; point.y = pstrhCHUNK->pRect->bottom = pstrhZS14->pRect->bottom;
return point;
}
CPoint Read_strf(CPoint pt, CString Format)
{
C解析AVIDlg* pDlg = (C解析AVIDlg*)theApp.m_pMainWnd;
COLORREF ChunkColor = RGB(138, 169, 172), Color = RGB(182, 199, 201);
ULONGLONG uPos = pDlg->F.GetPosition();
LINE* pLine = new LINE();
pLine->star = CPoint(pt.x + 120, pt.y - 1);
pLine->end = CPoint(970, pt.y - 1);
pLine->pos = pDlg->FormatString(uPos) + L"字节";
pDlg->arLine.Add((CObArray*)pLine);
char chF[5]; chF[4] = 0; DWORD mSize;
pDlg->F.Read(chF, 4); pDlg->F.Read(&mSize, 4);
CRect rect(pt.x, pt.y-1, pt.x + 121, pt.y + 14), rectW(pt.x + 121 - 1, pt.y-1, pt.x + 121 - 1 + 201, pt.y + 14);
CPoint point;
INFO* pstrfCHUNK = new INFO();
pstrfCHUNK->item = (CString)chF + L"\r\n" + pDlg->FormatString(mSize + 8) + L"字节";
pstrfCHUNK->pRect = new CRect(); pstrfCHUNK->pRect->CopyRect(rect);
pstrfCHUNK->color = ChunkColor;
pDlg->ar.Add((CObArray*)pstrfCHUNK);
INFO* pstrfSize1 = new INFO();
pstrfSize1->item = L"4字节";
pstrfSize1->pRect = new CRect(); pstrfSize1->pRect->CopyRect(rect); pstrfSize1->pRect->OffsetRect(rect.Width() - 1, 0);
pstrfSize1->color = Color;
pDlg->ar.Add((CObArray*)pstrfSize1);
INFO* pstrfSize2 = new INFO();
pstrfSize2->item = L"4字节";
pstrfSize2->pRect = new CRect(); pstrfSize2->pRect->CopyRect(pstrfSize1->pRect); pstrfSize2->pRect->OffsetRect(0, rect.Height() - 1);
pstrfSize2->color = Color;
pDlg->ar.Add((CObArray*)pstrfSize2);
INFO* pstrfDS1 = new INFO();
pstrfDS1->item = (CString)chF;
pstrfDS1->pRect = new CRect(); pstrfDS1->pRect->CopyRect(pstrfSize1->pRect); pstrfDS1->pRect->OffsetRect(rect.Width() - 1, 0);
pstrfDS1->color = Color;
pDlg->ar.Add((CObArray*)pstrfDS1);
INFO* pstrfDS2 = new INFO();
pstrfDS2->item = pDlg->FormatString(mSize);
pstrfDS2->pRect = new CRect(); pstrfDS2->pRect->CopyRect(pstrfDS1->pRect); pstrfDS2->pRect->OffsetRect(0, rect.Height() - 1);
pstrfDS2->color = Color;
pDlg->ar.Add((CObArray*)pstrfDS2);
if (Format == L"vids")
{
BITMAPINFOHEADER bh;
pDlg->F.Read(&bh, sizeof(BITMAPINFOHEADER)); pDlg->F.Seek(mSize - sizeof(BITMAPINFOHEADER),CFile::current);
INFO* pstrfSize3 = new INFO();
pstrfSize3->item = L"4字节";
pstrfSize3->pRect = new CRect(); pstrfSize3->pRect->CopyRect(pstrfSize2->pRect); pstrfSize3->pRect->OffsetRect(0, rect.Height() - 1);
pstrfSize3->color = Color;
pDlg->ar.Add((CObArray*)pstrfSize3);
INFO* pstrfSize4 = new INFO();
pstrfSize4->item = L"4字节";
pstrfSize4->pRect = new CRect(); pstrfSize4->pRect->CopyRect(pstrfSize3->pRect); pstrfSize4->pRect->OffsetRect(0, rect.Height() - 1);
pstrfSize4->color = Color;
pDlg->ar.Add((CObArray*)pstrfSize4);
INFO* pstrfSize5 = new INFO();
pstrfSize5->item = L"4字节";
pstrfSize5->pRect = new CRect(); pstrfSize5->pRect->CopyRect(pstrfSize4->pRect); pstrfSize5->pRect->OffsetRect(0, rect.Height() - 1);
pstrfSize5->color = Color;
pDlg->ar.Add((CObArray*)pstrfSize5);
INFO* pstrfSize6 = new INFO();
pstrfSize6->item = L"2字节";
pstrfSize6->pRect = new CRect(); pstrfSize6->pRect->CopyRect(pstrfSize5->pRect); pstrfSize6->pRect->OffsetRect(0, rect.Height() - 1);
pstrfSize6->color = Color;
pDlg->ar.Add((CObArray*)pstrfSize6);
INFO* pstrfSize7 = new INFO();
pstrfSize7->item = L"2字节";
pstrfSize7->pRect = new CRect(); pstrfSize7->pRect->CopyRect(pstrfSize6->pRect); pstrfSize7->pRect->OffsetRect(0, rect.Height() - 1);
pstrfSize7->color = Color;
pDlg->ar.Add((CObArray*)pstrfSize7);
INFO* pstrfSize8 = new INFO();
pstrfSize8->item = L"4字节";
pstrfSize8->pRect = new CRect(); pstrfSize8->pRect->CopyRect(pstrfSize7->pRect); pstrfSize8->pRect->OffsetRect(0, rect.Height() - 1);
pstrfSize8->color = Color;
pDlg->ar.Add((CObArray*)pstrfSize8);
INFO* pstrfSize9 = new INFO();
pstrfSize9->item = L"4字节";
pstrfSize9->pRect = new CRect(); pstrfSize9->pRect->CopyRect(pstrfSize8->pRect); pstrfSize9->pRect->OffsetRect(0, rect.Height() - 1);
pstrfSize9->color = Color;
pDlg->ar.Add((CObArray*)pstrfSize9);
INFO* pstrfSize10 = new INFO();
pstrfSize10->item = L"4字节";
pstrfSize10->pRect = new CRect(); pstrfSize10->pRect->CopyRect(pstrfSize9->pRect); pstrfSize10->pRect->OffsetRect(0, rect.Height() - 1);
pstrfSize10->color = Color;
pDlg->ar.Add((CObArray*)pstrfSize10);
INFO* pstrfSize11 = new INFO();
pstrfSize11->item = L"4字节";
pstrfSize11->pRect = new CRect(); pstrfSize11->pRect->CopyRect(pstrfSize10->pRect); pstrfSize11->pRect->OffsetRect(0, rect.Height() - 1);
pstrfSize11->color = Color;
pDlg->ar.Add((CObArray*)pstrfSize11);
INFO* pstrfSize12 = new INFO();
pstrfSize12->item = L"4字节";
pstrfSize12->pRect = new CRect(); pstrfSize12->pRect->CopyRect(pstrfSize11->pRect); pstrfSize12->pRect->OffsetRect(0, rect.Height() - 1);
pstrfSize12->color = Color;
pDlg->ar.Add((CObArray*)pstrfSize12);
INFO* pstrfSize13 = new INFO();
pstrfSize13->item = L"4字节";
pstrfSize13->pRect = new CRect(); pstrfSize13->pRect->CopyRect(pstrfSize12->pRect); pstrfSize13->pRect->OffsetRect(0, rect.Height() - 1);
pstrfSize13->color = Color;
pDlg->ar.Add((CObArray*)pstrfSize13);
INFO* pstrfDS3 = new INFO();
pstrfDS3->item = pDlg->FormatString(bh.biSize);
pstrfDS3->pRect = new CRect(); pstrfDS3->pRect->CopyRect(pstrfDS2->pRect); pstrfDS3->pRect->OffsetRect(0, rect.Height() - 1);
pstrfDS3->color = Color;
pDlg->ar.Add((CObArray*)pstrfDS3);
INFO* pstrfDS4 = new INFO();
pstrfDS4->item = pDlg->FormatString(bh.biWidth);
pstrfDS4->pRect = new CRect(); pstrfDS4->pRect->CopyRect(pstrfDS3->pRect); pstrfDS4->pRect->OffsetRect(0, rect.Height() - 1);
pstrfDS4->color = Color;
pDlg->ar.Add((CObArray*)pstrfDS4);
INFO* pstrfDS5 = new INFO();
pstrfDS5->item = pDlg->FormatString(bh.biHeight);
pstrfDS5->pRect = new CRect(); pstrfDS5->pRect->CopyRect(pstrfDS4->pRect); pstrfDS5->pRect->OffsetRect(0, rect.Height() - 1);
pstrfDS5->color = Color;
pDlg->ar.Add((CObArray*)pstrfDS5);
INFO* pstrfDS6 = new INFO();
pstrfDS6->item = pDlg->FormatString(bh.biPlanes);
pstrfDS6->pRect = new CRect(); pstrfDS6->pRect->CopyRect(pstrfDS5->pRect); pstrfDS6->pRect->OffsetRect(0, rect.Height() - 1);
pstrfDS6->color = Color;
pDlg->ar.Add((CObArray*)pstrfDS6);
INFO* pstrfDS7 = new INFO();
pstrfDS7->item = pDlg->FormatString(bh.biBitCount);
pstrfDS7->pRect = new CRect(); pstrfDS7->pRect->CopyRect(pstrfDS6->pRect); pstrfDS7->pRect->OffsetRect(0, rect.Height() - 1);
pstrfDS7->color = Color;
pDlg->ar.Add((CObArray*)pstrfDS7);
INFO* pstrfDS8 = new INFO();
char chCop[5]; chCop[4] = 0;
CopyMemory(chCop, &bh.biCompression, 4);
pstrfDS8->item = (CString)chCop;
pstrfDS8->pRect = new CRect(); pstrfDS8->pRect->CopyRect(pstrfDS7->pRect); pstrfDS8->pRect->OffsetRect(0, rect.Height() - 1);
pstrfDS8->color = Color;
pDlg->ar.Add((CObArray*)pstrfDS8);
INFO* pstrfDS9 = new INFO();
pstrfDS9->item = pDlg->FormatString(bh.biSizeImage);
pstrfDS9->pRect = new CRect(); pstrfDS9->pRect->CopyRect(pstrfDS8->pRect); pstrfDS9->pRect->OffsetRect(0, rect.Height() - 1);
pstrfDS9->color = Color;
pDlg->ar.Add((CObArray*)pstrfDS9);
INFO* pstrfDS10 = new INFO();
pstrfDS10->item = pDlg->FormatString(bh.biXPelsPerMeter);
pstrfDS10->pRect = new CRect(); pstrfDS10->pRect->CopyRect(pstrfDS9->pRect); pstrfDS10->pRect->OffsetRect(0, rect.Height() - 1);
pstrfDS10->color = Color;
pDlg->ar.Add((CObArray*)pstrfDS10);
INFO* pstrfDS11 = new INFO();
pstrfDS11->item = pDlg->FormatString(bh.biYPelsPerMeter);
pstrfDS11->pRect = new CRect(); pstrfDS11->pRect->CopyRect(pstrfDS10->pRect); pstrfDS11->pRect->OffsetRect(0, rect.Height() - 1);
pstrfDS11->color = Color;
pDlg->ar.Add((CObArray*)pstrfDS11);
INFO* pstrfDS12 = new INFO();
pstrfDS12->item = pDlg->FormatString(bh.biClrUsed);
pstrfDS12->pRect = new CRect(); pstrfDS12->pRect->CopyRect(pstrfDS11->pRect); pstrfDS12->pRect->OffsetRect(0, rect.Height() - 1);
pstrfDS12->color = Color;
pDlg->ar.Add((CObArray*)pstrfDS12);
INFO* pstrfDS13 = new INFO();
pstrfDS13->item = pDlg->FormatString(bh.biClrImportant);
pstrfDS13->pRect = new CRect(); pstrfDS13->pRect->CopyRect(pstrfDS12->pRect); pstrfDS13->pRect->OffsetRect(0, rect.Height() - 1);
pstrfDS13->color = Color;
pDlg->ar.Add((CObArray*)pstrfDS13);
INFO* pstrfMS1 = new INFO();
pstrfMS1->item = L"位图头大小";
pstrfMS1->pRect = new CRect(); pstrfMS1->pRect->CopyRect(rectW); pstrfMS1->pRect->MoveToXY(pstrfDS3->pRect->right - 1, pstrfDS3->pRect->top);
pstrfMS1->color = Color;
pDlg->ar.Add((CObArray*)pstrfMS1);
INFO* pstrfMS2 = new INFO();
pstrfMS2->item = L"位图的宽度";
pstrfMS2->pRect = new CRect(); pstrfMS2->pRect->CopyRect(pstrfMS1->pRect); pstrfMS2->pRect->OffsetRect(0, rect.Height() - 1);
pstrfMS2->color = Color;
pDlg->ar.Add((CObArray*)pstrfMS2);
INFO* pstrfMS3 = new INFO();
pstrfMS3->item = L"位图的高度";
pstrfMS3->pRect = new CRect(); pstrfMS3->pRect->CopyRect(pstrfMS2->pRect); pstrfMS3->pRect->OffsetRect(0, rect.Height() - 1);
pstrfMS3->color = Color;
pDlg->ar.Add((CObArray*)pstrfMS3);
INFO* pstrfMS4 = new INFO();
pstrfMS4->item = L"平面数";
pstrfMS4->pRect = new CRect(); pstrfMS4->pRect->CopyRect(pstrfMS3->pRect); pstrfMS4->pRect->OffsetRect(0, rect.Height() - 1);
pstrfMS4->color = Color;
pDlg->ar.Add((CObArray*)pstrfMS4);
INFO* pstrfMS5 = new INFO();
pstrfMS5->item = L"每个像素的位数";
pstrfMS5->pRect = new CRect(); pstrfMS5->pRect->CopyRect(pstrfMS4->pRect); pstrfMS5->pRect->OffsetRect(0, rect.Height() - 1);
pstrfMS5->color = Color;
pDlg->ar.Add((CObArray*)pstrfMS5);
INFO* pstrfMS6 = new INFO();
pstrfMS6->item = L"编码方式";
pstrfMS6->pRect = new CRect(); pstrfMS6->pRect->CopyRect(pstrfMS5->pRect); pstrfMS6->pRect->OffsetRect(0, rect.Height() - 1);
pstrfMS6->color = Color;
pDlg->ar.Add((CObArray*)pstrfMS6);
INFO* pstrfMS7 = new INFO();
pstrfMS7->item = L"图像大小";
pstrfMS7->pRect = new CRect(); pstrfMS7->pRect->CopyRect(pstrfMS6->pRect); pstrfMS7->pRect->OffsetRect(0, rect.Height() - 1);
pstrfMS7->color = Color;
pDlg->ar.Add((CObArray*)pstrfMS7);
INFO* pstrfMS8 = new INFO();
pstrfMS8->item = L"目标设备的水平分辨率";
pstrfMS8->pRect = new CRect(); pstrfMS8->pRect->CopyRect(pstrfMS7->pRect); pstrfMS8->pRect->OffsetRect(0, rect.Height() - 1);
pstrfMS8->color = Color;
pDlg->ar.Add((CObArray*)pstrfMS8);
INFO* pstrfMS9 = new INFO();
pstrfMS9->item = L"目标设备的垂直分辨率";
pstrfMS9->pRect = new CRect(); pstrfMS9->pRect->CopyRect(pstrfMS8->pRect); pstrfMS9->pRect->OffsetRect(0, rect.Height() - 1);
pstrfMS9->color = Color;
pDlg->ar.Add((CObArray*)pstrfMS9);
INFO* pstrfMS10 = new INFO();
pstrfMS10->item = L"颜色数量";
pstrfMS10->pRect = new CRect(); pstrfMS10->pRect->CopyRect(pstrfMS9->pRect); pstrfMS10->pRect->OffsetRect(0, rect.Height() - 1);
pstrfMS10->color = Color;
pDlg->ar.Add((CObArray*)pstrfMS10);
INFO* pstrfMS11 = new INFO();
pstrfMS11->item = L"重要颜色数量";
pstrfMS11->pRect = new CRect(); pstrfMS11->pRect->CopyRect(pstrfMS10->pRect); pstrfMS11->pRect->OffsetRect(0, rect.Height() - 1);
pstrfMS11->color = Color;
pDlg->ar.Add((CObArray*)pstrfMS11);
pstrfCHUNK->pRect->bottom = pstrfMS11->pRect->bottom;
point.x = pt.x; point.y = pstrfCHUNK->pRect->bottom;
if (mSize > sizeof(BITMAPINFOHEADER))
{
INFO* pM1 = new INFO();
pM1->item = pDlg->FormatString(mSize - sizeof(BITMAPINFOHEADER)) + L"字节";
pM1->pRect = new CRect(); pM1->pRect->CopyRect(pstrfSize13->pRect); pM1->pRect->OffsetRect(0, pstrfSize13->pRect->Height() - 1);
pM1->color = Color;
pDlg->ar.Add((CObArray*)pM1);
INFO* pS1 = new INFO();
pS1->pRect = new CRect(); pS1->pRect->CopyRect(pM1->pRect); pS1->pRect->OffsetRect(pM1->pRect->Width() - 1,0);
pS1->color = Color;
pDlg->ar.Add((CObArray*)pS1);
pstrfCHUNK->pRect->bottom = pS1->pRect->bottom;
point.x = pt.x; point.y = pstrfCHUNK->pRect->bottom;
}
}
else if (Format == "auds")
{
WORD wFormatTag;
WORD nChannels;
DWORD nSamplesPerSec;
DWORD nAvgBytesPerSec;
WORD nBlockAlign;
WORD wBitsPerSample;
pDlg->F.Read(&wFormatTag, 2); pDlg->F.Read(&nChannels, 2); pDlg->F.Read(&nSamplesPerSec, 4);
pDlg->F.Read(&nAvgBytesPerSec, 4); pDlg->F.Read(&nBlockAlign, 2); pDlg->F.Read(&wBitsPerSample, 2);
INFO* pstrfSize3 = new INFO();
pstrfSize3->item = L"2字节";
pstrfSize3->pRect = new CRect(); pstrfSize3->pRect->CopyRect(pstrfSize2->pRect); pstrfSize3->pRect->OffsetRect(0, rect.Height() - 1);
pstrfSize3->color = Color;
pDlg->ar.Add((CObArray*)pstrfSize3);
INFO* pstrfSize4 = new INFO();
pstrfSize4->item = L"2字节";
pstrfSize4->pRect = new CRect(); pstrfSize4->pRect->CopyRect(pstrfSize3->pRect); pstrfSize4->pRect->OffsetRect(0, rect.Height() - 1);
pstrfSize4->color = Color;
pDlg->ar.Add((CObArray*)pstrfSize4);
INFO* pstrfSize5 = new INFO();
pstrfSize5->item = L"4字节";
pstrfSize5->pRect = new CRect(); pstrfSize5->pRect->CopyRect(pstrfSize4->pRect); pstrfSize5->pRect->OffsetRect(0, rect.Height() - 1);
pstrfSize5->color = Color;
pDlg->ar.Add((CObArray*)pstrfSize5);
INFO* pstrfSize6 = new INFO();
pstrfSize6->item = L"4字节";
pstrfSize6->pRect = new CRect(); pstrfSize6->pRect->CopyRect(pstrfSize5->pRect); pstrfSize6->pRect->OffsetRect(0, rect.Height() - 1);
pstrfSize6->color = Color;
pDlg->ar.Add((CObArray*)pstrfSize6);
INFO* pstrfSize7 = new INFO();
pstrfSize7->item = L"2字节";
pstrfSize7->pRect = new CRect(); pstrfSize7->pRect->CopyRect(pstrfSize6->pRect); pstrfSize7->pRect->OffsetRect(0, rect.Height() - 1);
pstrfSize7->color = Color;
pDlg->ar.Add((CObArray*)pstrfSize7);
INFO* pstrfSize8 = new INFO();
pstrfSize8->item = L"2字节";
pstrfSize8->pRect = new CRect(); pstrfSize8->pRect->CopyRect(pstrfSize7->pRect); pstrfSize8->pRect->OffsetRect(0, rect.Height() - 1);
pstrfSize8->color = Color;
pDlg->ar.Add((CObArray*)pstrfSize8);
INFO* pstrfDS3 = new INFO();
pstrfDS3->item = pDlg->FormatString(wFormatTag);
pstrfDS3->pRect = new CRect(); pstrfDS3->pRect->CopyRect(pstrfDS2->pRect); pstrfDS3->pRect->OffsetRect(0, rect.Height() - 1);
pstrfDS3->color = Color;
pDlg->ar.Add((CObArray*)pstrfDS3);
INFO* pstrfDS4 = new INFO();
pstrfDS4->item = pDlg->FormatString(nChannels);
pstrfDS4->pRect = new CRect(); pstrfDS4->pRect->CopyRect(pstrfDS3->pRect); pstrfDS4->pRect->OffsetRect(0, rect.Height() - 1);
pstrfDS4->color = Color;
pDlg->ar.Add((CObArray*)pstrfDS4);
INFO* pstrfDS5 = new INFO();
pstrfDS5->item = pDlg->FormatString(nSamplesPerSec);
pstrfDS5->pRect = new CRect(); pstrfDS5->pRect->CopyRect(pstrfDS4->pRect); pstrfDS5->pRect->OffsetRect(0, rect.Height() - 1);
pstrfDS5->color = Color;
pDlg->ar.Add((CObArray*)pstrfDS5);
INFO* pstrfDS6 = new INFO();
pstrfDS6->item = pDlg->FormatString(nAvgBytesPerSec);
pstrfDS6->pRect = new CRect(); pstrfDS6->pRect->CopyRect(pstrfDS5->pRect); pstrfDS6->pRect->OffsetRect(0, rect.Height() - 1);
pstrfDS6->color = Color;
pDlg->ar.Add((CObArray*)pstrfDS6);
INFO* pstrfDS7 = new INFO();
pstrfDS7->item = pDlg->FormatString(nBlockAlign);
pstrfDS7->pRect = new CRect(); pstrfDS7->pRect->CopyRect(pstrfDS6->pRect); pstrfDS7->pRect->OffsetRect(0, rect.Height() - 1);
pstrfDS7->color = Color;
pDlg->ar.Add((CObArray*)pstrfDS7);
INFO* pstrfDS8 = new INFO();
pstrfDS8->item = pDlg->FormatString(wBitsPerSample);
pstrfDS8->pRect = new CRect(); pstrfDS8->pRect->CopyRect(pstrfDS7->pRect); pstrfDS8->pRect->OffsetRect(0, rect.Height() - 1);
pstrfDS8->color = Color;
pDlg->ar.Add((CObArray*)pstrfDS8);
INFO* pstrfM3 = new INFO();
pstrfM3->item = L"编码方式";
pstrfM3->pRect = new CRect(); pstrfM3->pRect->CopyRect(rectW); pstrfM3->pRect->MoveToXY(pstrfDS3->pRect->right - 1, pstrfDS3->pRect->top);
pstrfM3->color= Color;
pDlg->ar.Add((CObArray*)pstrfM3);
INFO* pstrfM4 = new INFO();
pstrfM4->item = L"声道数";
pstrfM4->pRect = new CRect(); pstrfM4->pRect->CopyRect(pstrfM3->pRect); pstrfM4->pRect->OffsetRect(0, rectW.Height() - 1);
pstrfM4->color = Color;
pDlg->ar.Add((CObArray*)pstrfM4);
INFO* pstrfM5 = new INFO();
pstrfM5->item = L"采样率";
pstrfM5->pRect = new CRect(); pstrfM5->pRect->CopyRect(pstrfM4->pRect); pstrfM5->pRect->OffsetRect(0, rectW.Height() - 1);
pstrfM5->color = Color;
pDlg->ar.Add((CObArray*)pstrfM5);
INFO* pstrfM6 = new INFO();
pstrfM6->item = L"传输率";
pstrfM6->pRect = new CRect(); pstrfM6->pRect->CopyRect(pstrfM5->pRect); pstrfM6->pRect->OffsetRect(0, rectW.Height() - 1);
pstrfM6->color = Color;
pDlg->ar.Add((CObArray*)pstrfM6);
INFO* pstrfM7 = new INFO();
pstrfM7->item = L"块对齐";
pstrfM7->pRect = new CRect(); pstrfM7->pRect->CopyRect(pstrfM6->pRect); pstrfM7->pRect->OffsetRect(0, rectW.Height() - 1);
pstrfM7->color = Color;
pDlg->ar.Add((CObArray*)pstrfM7);
INFO* pstrfM8 = new INFO();
pstrfM8->item = L"样本位数";
pstrfM8->pRect = new CRect(); pstrfM8->pRect->CopyRect(pstrfM7->pRect); pstrfM8->pRect->OffsetRect(0, rectW.Height() - 1);
pstrfM8->color = Color;
pDlg->ar.Add((CObArray*)pstrfM8);
pstrfCHUNK->pRect->bottom = pstrfDS8->pRect->bottom;
point.x = pt.x; point.y = pstrfCHUNK->pRect->bottom;
if (mSize > 16)
{
WORD cbSize;
pDlg->F.Read(&cbSize, 2);
if (mSize == 18)
{
INFO* pstrfSize9 = new INFO();
pstrfSize9->item = L"2字节";
pstrfSize9->pRect = new CRect(); pstrfSize9->pRect->CopyRect(pstrfSize8->pRect); pstrfSize9->pRect->OffsetRect(0, rect.Height() - 1);
pstrfSize9->color = Color;
pDlg->ar.Add((CObArray*)pstrfSize9);
INFO* pstrfDS9 = new INFO();
pstrfDS9->item = pDlg->FormatString(cbSize);
pstrfDS9->pRect = new CRect(); pstrfDS9->pRect->CopyRect(pstrfDS8->pRect); pstrfDS9->pRect->OffsetRect(0, rect.Height() - 1);
pstrfDS9->color = Color;
pDlg->ar.Add((CObArray*)pstrfDS9);
INFO* pstrfM9 = new INFO();
pstrfM9->item = L"附加信息大小";
pstrfM9->pRect = new CRect(); pstrfM9->pRect->CopyRect(pstrfM8->pRect); pstrfM9->pRect->OffsetRect(0, rectW.Height() - 1);
pstrfM9->color = Color;
pDlg->ar.Add((CObArray*)pstrfM9);
pstrfCHUNK->pRect->bottom = pstrfDS9->pRect->bottom;
point.x = pt.x; point.y = pstrfCHUNK->pRect->bottom;
}
else
{
INFO* pstrfSize9 = new INFO();
pstrfSize9->item = L"2字节";
pstrfSize9->pRect = new CRect(); pstrfSize9->pRect->CopyRect(pstrfSize8->pRect); pstrfSize9->pRect->OffsetRect(0, rect.Height() - 1);
pstrfSize9->color = Color;
pDlg->ar.Add((CObArray*)pstrfSize9);
INFO* pstrfSize10 = new INFO();
pstrfSize10->item = pDlg->FormatString(cbSize) + L"字节";
pstrfSize10->pRect = new CRect(); pstrfSize10->pRect->CopyRect(pstrfSize9->pRect); pstrfSize10->pRect->OffsetRect(0, rect.Height() - 1);
pstrfSize10->color = Color;
pDlg->ar.Add((CObArray*)pstrfSize10);
INFO* pstrfDS9 = new INFO();
pstrfDS9->item = pDlg->FormatString(cbSize);
pstrfDS9->pRect = new CRect(); pstrfDS9->pRect->CopyRect(pstrfDS8->pRect); pstrfDS9->pRect->OffsetRect(0, rect.Height() - 1);
pstrfDS9->color = Color;
pDlg->ar.Add((CObArray*)pstrfDS9);
INFO* pstrfDS10 = new INFO();
BYTE* pS = new BYTE[mSize - 18];
pDlg->F.Read(pS, mSize - 18);
CString ss = L"{", s;
for (DWORD i = 0; i < mSize - 18; i++)
{
s.Format(L"%d", pS[i]);
if (i == mSize - 19)
{
ss += s + L"}";
}
else
{
ss += s + L",";
}
}
delete[] pS;
if (cbSize)
pstrfDS10->item = ss;
else
pstrfDS10->item = L"";
pstrfDS10->pRect = new CRect(); pstrfDS10->pRect->CopyRect(rectW); pstrfDS10->pRect->MoveToXY(pstrfDS9->pRect->left, pstrfDS9->pRect->bottom - 1);
pstrfDS10->color = Color;
pDlg->ar.Add((CObArray*)pstrfDS10);
INFO* pstrfM9 = new INFO();
pstrfM9->item = L"附加信息大小";
pstrfM9->pRect = new CRect(); pstrfM9->pRect->CopyRect(pstrfM8->pRect); pstrfM9->pRect->OffsetRect(0, rectW.Height() - 1);
pstrfM9->color = Color;
pDlg->ar.Add((CObArray*)pstrfM9);
INFO* pstrfM10 = new INFO();
pstrfM10->item = L"附加信息";
pstrfM10->pRect = new CRect(); pstrfM10->pRect->CopyRect(CRect(pstrfDS10->pRect->right - 1, pstrfDS10->pRect->top, pstrfM9->pRect->right, pstrfDS10->pRect->bottom));
pstrfM10->color = Color;
pDlg->ar.Add((CObArray*)pstrfM10);
pstrfCHUNK->pRect->bottom = pstrfDS10->pRect->bottom;
point.x = pt.x; point.y = pstrfCHUNK->pRect->bottom;
}
}
}
return point;
}
CPoint Read_X(CPoint pt)
{
C解析AVIDlg* pDlg = (C解析AVIDlg*)theApp.m_pMainWnd;
COLORREF ChunkColor = RGB(205, 149, 126), Color = RGB(250, 201, 181);
pDlg->F.Seek(-8, CFile::current);
char ch[5]; ch[4] = 0; DWORD mSize;
pDlg->F.Read(ch, 4); pDlg->F.Read(&mSize, 4);
ULONGLONG uPos = pDlg->F.GetPosition();
pDlg->F.Seek(mSize, CFile::current);
LINE* pLine = new LINE();
pLine->star = CPoint(pt.x + 120, pt.y - 1);
pLine->end = CPoint(970, pt.y - 1);
pLine->pos = pDlg->FormatString(uPos+8) + L"字节";
pDlg->arLine.Add((CObArray*)pLine);
CRect rect(pt.x, pt.y - 1, pt.x + 121, pt.y + 14);
INFO* pChunk = new INFO();
pChunk->item = (CString)ch + L"\r\n" + pDlg->FormatString(mSize + 8) + L"字节";
pChunk->pRect = new CRect(); pChunk->pRect->CopyRect(rect);
pChunk->color = ChunkColor;
pDlg->ar.Add((CObArray*)pChunk);
INFO* pSize1 = new INFO();
pSize1->item = L"4字节";
pSize1->pRect = new CRect(); pSize1->pRect->CopyRect(rect); pSize1->pRect->OffsetRect(rect.Width() - 1, 0);
pSize1->color = Color;
pDlg->ar.Add((CObArray*)pSize1);
INFO* pSize2 = new INFO();
pSize2->item = L"4字节";
pSize2->pRect = new CRect(); pSize2->pRect->CopyRect(pSize1->pRect); pSize2->pRect->OffsetRect(0,rect.Height()-1);
pSize2->color = Color;
pDlg->ar.Add((CObArray*)pSize2);
INFO* pSize3 = new INFO();
pSize3->item = pDlg->FormatString(mSize) + L"字节";
pSize3->pRect = new CRect(); pSize3->pRect->CopyRect(pSize2->pRect); pSize3->pRect->OffsetRect(0, rect.Height() - 1);
pSize3->color = Color;
pDlg->ar.Add((CObArray*)pSize3);
INFO* pN1 = new INFO();
pN1->item = (CString)ch;
pN1->pRect = new CRect(); pN1->pRect->CopyRect(pSize1->pRect); pN1->pRect->OffsetRect(pSize1->pRect->Width() - 1, 0);
pN1->color = Color;
pDlg->ar.Add((CObArray*)pN1);
INFO* pN2 = new INFO();
pN2->item = pDlg->FormatString(mSize);
pN2->pRect = new CRect(); pN2->pRect->CopyRect(pN1->pRect); pN2->pRect->OffsetRect(0, rect.Height() - 1);
pN2->color = Color;
pDlg->ar.Add((CObArray*)pN2);
INFO* pN3 = new INFO();
if ((CString)ch == L"idx1")
{
pN3->ID = L"可读取-idx1";
pN3->color = RGB(255, 150, 150);
pN3->STAR = uPos;
pN3->LEN = mSize;
}
else if ((CString)ch == L"vprp")
{
pN3->ID = L"可读取-二进制";
pN3->color = RGB(255, 150, 150);
pN3->STAR = uPos;
pN3->LEN = mSize;
}
else
{
pN3->color = Color;
}
pN3->pRect = new CRect(); pN3->pRect->CopyRect(pN2->pRect); pN3->pRect->OffsetRect(0, rect.Height() - 1);
pDlg->ar.Add((CObArray*)pN3);
pChunk->pRect->bottom = pN3->pRect->bottom;
return CPoint(pt.x, pN3->pRect->bottom);
}
CPoint Read_X_LIST(CPoint pt)
{
C解析AVIDlg* pDlg = (C解析AVIDlg*)theApp.m_pMainWnd;
COLORREF ChunkColor = RGB(153, 190, 190), Color = RGB(202, 218, 218);
pDlg->F.Seek(-12, CFile::current);
ULONGLONG uPos = pDlg->F.GetPosition();
LINE* pLine = new LINE();
pLine->star = CPoint(pt.x + 120, pt.y - 1);
pLine->end = CPoint(970, pt.y - 1);
pLine->pos = pDlg->FormatString(uPos) + L"字节";
pDlg->arLine.Add((CObArray*)pLine);
char ch[5]; ch[4] = 0; DWORD mSize; char ch2[5]; ch2[4] = 0;
pDlg->F.Read(ch, 4); pDlg->F.Read(&mSize, 4); pDlg->F.Read(ch2, 4);
pDlg->F.Seek(mSize-4, CFile::current);
CRect rect(pt.x, pt.y - 1, pt.x + 121, pt.y + 14);
INFO* pChunk = new INFO();
pChunk->item = (CString)ch2 + L"_LIST\r\n" + pDlg->FormatString(mSize + 8) + L"字节";
pChunk->pRect = new CRect(); pChunk->pRect->CopyRect(rect);
pChunk->color = ChunkColor;
pDlg->ar.Add((CObArray*)pChunk);
INFO* pSize1 = new INFO();
pSize1->item = L"4字节";
pSize1->pRect = new CRect(); pSize1->pRect->CopyRect(rect); pSize1->pRect->OffsetRect(rect.Width() - 1, 0);
pSize1->color = Color;
pDlg->ar.Add((CObArray*)pSize1);
INFO* pSize2 = new INFO();
pSize2->item = L"4字节";
pSize2->pRect = new CRect(); pSize2->pRect->CopyRect(pSize1->pRect); pSize2->pRect->OffsetRect(0, rect.Height() - 1);
pSize2->color = Color;
pDlg->ar.Add((CObArray*)pSize2);
INFO* pSize3 = new INFO();
pSize3->item = L"4字节";
pSize3->pRect = new CRect(); pSize3->pRect->CopyRect(pSize2->pRect); pSize3->pRect->OffsetRect(0, rect.Height() - 1);
pSize3->color = Color;
pDlg->ar.Add((CObArray*)pSize3);
INFO* pSize4 = new INFO();
pSize4->item = pDlg->FormatString(mSize - 4) + L"字节";
pSize4->pRect = new CRect(); pSize4->pRect->CopyRect(pSize3->pRect); pSize4->pRect->OffsetRect(0, rect.Height() - 1);
pSize4->color = Color;
pDlg->ar.Add((CObArray*)pSize4);
INFO* pN1 = new INFO();
pN1->item = (CString)ch;
pN1->pRect = new CRect(); pN1->pRect->CopyRect(pSize1->pRect); pN1->pRect->OffsetRect(pSize1->pRect->Width() - 1, 0);
pN1->color = Color;
pDlg->ar.Add((CObArray*)pN1);
INFO* pN2 = new INFO();
pN2->item = pDlg->FormatString(mSize);
pN2->pRect = new CRect(); pN2->pRect->CopyRect(pN1->pRect); pN2->pRect->OffsetRect(0, rect.Height() - 1);
pN2->color = Color;
pDlg->ar.Add((CObArray*)pN2);
INFO* pN3 = new INFO();
pN3->item = (CString)ch2;
pN3->pRect = new CRect(); pN3->pRect->CopyRect(pN2->pRect); pN3->pRect->OffsetRect(0, rect.Height() - 1);
pN3->color = Color;
pDlg->ar.Add((CObArray*)pN3);
INFO* pN4 = new INFO();
pN4->item = L"";
pN4->pRect = new CRect(); pN4->pRect->CopyRect(pN3->pRect); pN4->pRect->OffsetRect(0, rect.Height() - 1);
pN4->color = Color;
pDlg->ar.Add((CObArray*)pN4);
pChunk->pRect->bottom = pN4->pRect->bottom;
return CPoint(pt.x, pN4->pRect->bottom);
}
CPoint Read_RIFF_AVIX(CPoint pt)
{
C解析AVIDlg* pDlg = (C解析AVIDlg*)theApp.m_pMainWnd;
COLORREF ChunkColor = RGB(255, 146, 101), Color = RGB(200, 200, 200);
COLORREF ChunkColor2 = RGB(251, 198, 115), Color2 = RGB(235, 221, 199);
pDlg->F.Seek(-8, CFile::current);
ULONGLONG uPos = pDlg->F.GetPosition();
LINE* pLine = new LINE();
pLine->star = CPoint(pt.x + 120, pt.y - 1);
pLine->end = CPoint(970, pt.y - 1);
pLine->pos = pDlg->FormatString(uPos) + L"字节";
pDlg->arLine.Add((CObArray*)pLine);
char chRIFF[5]; chRIFF[4] = 0; DWORD mSize1; char chAVIX[5]; chAVIX[4] = 0;
pDlg->F.Read(chRIFF, 4); pDlg->F.Read(&mSize1, 4); pDlg->F.Read(chAVIX, 4);
uPos = pDlg->F.GetPosition();
char chLIST[5]; chLIST[4] = 0; DWORD mSize2; char ch_movi[5]; ch_movi[4] = 0;
pDlg->F.Read(chLIST, 4); pDlg->F.Read(&mSize2, 4); pDlg->F.Read(ch_movi, 4);
pDlg->F.Seek(mSize2 - 4, CFile::current);
CRect rect(pt.x, pt.y - 1, pt.x + 121, pt.y + 14);
INFO* pChunk = new INFO();
pChunk->item = (CString)chRIFF + L"_AVIX\r\n" + pDlg->FormatString(mSize1 + 8) + L"字节";
pChunk->pRect = new CRect(); pChunk->pRect->CopyRect(rect);
pChunk->color = RGB(255, 146, 101);
pDlg->ar.Add((CObArray*)pChunk);
INFO* pSize1 = new INFO();
pSize1->item = L"4字节";
pSize1->pRect = new CRect(); pSize1->pRect->CopyRect(rect); pSize1->pRect->OffsetRect(rect.Width() - 1, 0);
pSize1->color = Color;
pDlg->ar.Add((CObArray*)pSize1);
INFO* pSize2 = new INFO();
pSize2->item = L"4字节";
pSize2->pRect = new CRect(); pSize2->pRect->CopyRect(pSize1->pRect); pSize2->pRect->OffsetRect(0, rect.Height() - 1);
pSize2->color = Color;
pDlg->ar.Add((CObArray*)pSize2);
INFO* pSize3 = new INFO();
pSize3->item = L"4字节";
pSize3->pRect = new CRect(); pSize3->pRect->CopyRect(pSize2->pRect); pSize3->pRect->OffsetRect(0, rect.Height() - 1);
pSize3->color = Color;
pDlg->ar.Add((CObArray*)pSize3);
INFO* pN1 = new INFO();
pN1->item = (CString)chRIFF;
pN1->pRect = new CRect(); pN1->pRect->CopyRect(pSize1->pRect); pN1->pRect->OffsetRect(pSize1->pRect->Width() - 1, 0);
pN1->color = Color;
pDlg->ar.Add((CObArray*)pN1);
INFO* pN2 = new INFO();
pN2->item = pDlg->FormatString(mSize1);
pN2->pRect = new CRect(); pN2->pRect->CopyRect(pN1->pRect); pN2->pRect->OffsetRect(0, rect.Height() - 1);
pN2->color = Color;
pDlg->ar.Add((CObArray*)pN2);
INFO* pN3 = new INFO();
pN3->item = (CString)chAVIX;
pN3->pRect = new CRect(); pN3->pRect->CopyRect(pN2->pRect); pN3->pRect->OffsetRect(0, rect.Height() - 1);
pN3->color = Color;
pDlg->ar.Add((CObArray*)pN3);
INFO* pMovi_LIST_CGUNK = new INFO();
pMovi_LIST_CGUNK->item = (CString)ch_movi + L"_" + (CString)chLIST + L"\r\n" + pDlg->FormatString(mSize2 + 8) + L"字节";
pMovi_LIST_CGUNK->pRect = new CRect(); pMovi_LIST_CGUNK->pRect->CopyRect(pSize3->pRect); pMovi_LIST_CGUNK->pRect->OffsetRect(0, pSize3->pRect->Height() - 1);
pMovi_LIST_CGUNK->color= ChunkColor2;
pDlg->ar.Add((CObArray*)pMovi_LIST_CGUNK);
LINE* pLine2 = new LINE();
pLine2->star = CPoint(pMovi_LIST_CGUNK->pRect->right, pMovi_LIST_CGUNK->pRect->top);
pLine2->end = CPoint(970, pMovi_LIST_CGUNK->pRect->top);
pLine2->pos = pDlg->FormatString(uPos) + L"字节";
pDlg->arLine.Add((CObArray*)pLine2);
INFO* pMSize1 = new INFO();
pMSize1->item = L"4字节";
pMSize1->pRect = new CRect(); pMSize1->pRect->CopyRect(pN3->pRect); pMSize1->pRect->OffsetRect(0, rect.Height() - 1);;
pMSize1->color = Color2;
pDlg->ar.Add((CObArray*)pMSize1);
INFO* pMSize2 = new INFO();
pMSize2->item = L"4字节";
pMSize2->pRect = new CRect(); pMSize2->pRect->CopyRect(pMSize1->pRect); pMSize2->pRect->OffsetRect(0, rect.Height() - 1);
pMSize2->color = Color2;
pDlg->ar.Add((CObArray*)pMSize2);
INFO* pMSize3 = new INFO();
pMSize3->item = L"4字节";
pMSize3->pRect = new CRect(); pMSize3->pRect->CopyRect(pMSize2->pRect); pMSize3->pRect->OffsetRect(0, rect.Height() - 1);
pMSize3->color = Color2;
pDlg->ar.Add((CObArray*)pMSize3);
INFO* pMSize4 = new INFO();
pMSize4->item = pDlg->FormatString(mSize2 - 4) + L"字节";
pMSize4->pRect = new CRect(); pMSize4->pRect->CopyRect(pMSize3->pRect); pMSize4->pRect->OffsetRect(0, rect.Height() - 1);
pMSize4->color = Color2;
pDlg->ar.Add((CObArray*)pMSize4);
INFO* pM1 = new INFO();
pM1->item = (CString)chLIST;
pM1->pRect = new CRect(); pM1->pRect->CopyRect(pMSize1->pRect); pM1->pRect->OffsetRect(pMSize1->pRect->Width() - 1, 0);
pM1->color = Color2;
pDlg->ar.Add((CObArray*)pM1);
INFO* pM2 = new INFO();
pM2->item = pDlg->FormatString(mSize2);
pM2->pRect = new CRect(); pM2->pRect->CopyRect(pM1->pRect); pM2->pRect->OffsetRect(0, rect.Height() - 1);
pM2->color = Color2;
pDlg->ar.Add((CObArray*)pM2);
INFO* pM3 = new INFO();
pM3->item = (CString)ch_movi;
pM3->pRect = new CRect(); pM3->pRect->CopyRect(pM2->pRect); pM3->pRect->OffsetRect(0, rect.Height() - 1);
pM3->color = Color2;
pDlg->ar.Add((CObArray*)pM3);
INFO* pM4 = new INFO();
pM4->item = L"";
pM4->pRect = new CRect(); pM4->pRect->CopyRect(pM3->pRect); pM4->pRect->OffsetRect(0, rect.Height() - 1);
pM4->color = Color2;
pDlg->ar.Add((CObArray*)pM4);
pChunk->pRect->bottom = pMovi_LIST_CGUNK->pRect->bottom = pMSize4->pRect->bottom;
return CPoint(pt.x, pChunk->pRect->bottom);
}
#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();
virtual BOOL OnInitDialog();
virtual BOOL PreTranslateMessage(MSG* pMsg);
afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
};
// Dlg1.cpp : 实现文件
//
#include "stdafx.h"
#include "解析AVI.h"
#include "Dlg1.h"
#include "afxdialogex.h"
#include "解析AVIDlg.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_VSCROLL()
ON_WM_HSCROLL()
END_MESSAGE_MAP()
void CDlg1::OnBnClickedOk()
{
}
BOOL CDlg1::OnInitDialog()
{
CDialogEx::OnInitDialog();
return TRUE;
}
BOOL CDlg1::PreTranslateMessage(MSG* pMsg)
{
if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_ESCAPE)//防止ESC键关闭窗口
return TRUE;
return CDialogEx::PreTranslateMessage(pMsg);
}
void CDlg1::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
C解析AVIDlg* pDlg = (C解析AVIDlg*)theApp.m_pMainWnd;
int Min, Max;
GetScrollRange(SB_VERT, &Min, &Max);
int pos;
switch (nSBCode)
{
case SB_LINEDOWN: //向下滚动行
pos = GetScrollPos(SB_VERT) + 20;
if (pos > Max)pos = Max;
SetScrollPos(SB_VERT, pos);
pDlg->dlg2.MoveWindow(0, -pos, pDlg->dlg2.dlg2_rect.Width(), pDlg->dlg2.dlg2_rect.Height());
break;
case SB_LINEUP: //向上滚动行
pos = GetScrollPos(SB_VERT) - 20;
if (pos < Min)pos = Min;
SetScrollPos(SB_VERT, pos);
pDlg->dlg2.MoveWindow(0, -pos, pDlg->dlg2.dlg2_rect.Width(), pDlg->dlg2.dlg2_rect.Height());
break;
case SB_PAGEDOWN: //向下滚动页
pos = GetScrollPos(SB_VERT) + 100;
if (pos > Max)pos = Max;
SetScrollPos(SB_VERT, pos);
pDlg->dlg2.MoveWindow(0, -pos, pDlg->dlg2.dlg2_rect.Width(), pDlg->dlg2.dlg2_rect.Height());
break;
case SB_PAGEUP: //向上滚动页
pos = GetScrollPos(SB_VERT) - 100;
if (pos < Min)pos = Min;
SetScrollPos(SB_VERT, pos);
pDlg->dlg2.MoveWindow(0, -pos, pDlg->dlg2.dlg2_rect.Width(), pDlg->dlg2.dlg2_rect.Height());
break;
case SB_THUMBTRACK: //拖动滑块
SetScrollPos(SB_VERT, nPos);
pos = nPos;
pDlg->dlg2.MoveWindow(0, -pos, pDlg->dlg2.dlg2_rect.Width(), pDlg->dlg2.dlg2_rect.Height());
break;
}
CDialogEx::OnVScroll(nSBCode, nPos, pScrollBar);
}
void CDlg1::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
C解析AVIDlg* pDlg = (C解析AVIDlg*)theApp.m_pMainWnd;
int Min, Max;
GetScrollRange(SB_VERT, &Min, &Max);
int pos;
switch (nSBCode)
{
case SB_LINELEFT: //向左滚动一行。
pos = GetScrollPos(SB_HORZ) - 20;
if (pos < Min)pos = Min;
SetScrollPos(SB_HORZ, pos);
pDlg->dlg2.MoveWindow(-pos, 0, pDlg->dlg2.dlg2_rect.Width(), pDlg->dlg2.dlg2_rect.Height());
break;
case SB_LINERIGHT: //向右滚动一行。
pos = GetScrollPos(SB_HORZ) + 20;
if (pos > Max)pos = Max;
SetScrollPos(SB_HORZ, pos);
pDlg->dlg2.MoveWindow(-pos, 0, pDlg->dlg2.dlg2_rect.Width(), pDlg->dlg2.dlg2_rect.Height());
break;
case SB_PAGELEFT: //向左滚动一页。
pos = GetScrollPos(SB_HORZ) - 100;
if (pos < Min)pos = Min;
SetScrollPos(SB_HORZ, pos);
pDlg->dlg2.MoveWindow(-pos, 0, pDlg->dlg2.dlg2_rect.Width(), pDlg->dlg2.dlg2_rect.Height());
break;
case SB_PAGERIGHT: //向右滚动一页。
pos = GetScrollPos(SB_HORZ) + 100;
if (pos > Max)pos = Max;
SetScrollPos(SB_HORZ, pos);
pDlg->dlg2.MoveWindow(-pos, 0, pDlg->dlg2.dlg2_rect.Width(), pDlg->dlg2.dlg2_rect.Height());
break;
case SB_THUMBTRACK: //拖动过程中,多次传递该值。 nPos是滚动框已被拖动到的位置。
SetScrollPos(SB_HORZ, nPos);
pos = nPos;
pDlg->dlg2.MoveWindow(-pos, 0, pDlg->dlg2.dlg2_rect.Width(), pDlg->dlg2.dlg2_rect.Height());
break;
}
CDialogEx::OnHScroll(nSBCode, nPos, pScrollBar);
}
#pragma once
// 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();
CFont font1;
CRect dlg2_rect;
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
virtual BOOL OnInitDialog();
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
};
// Dlg2.cpp : 实现文件
//
#include "stdafx.h"
#include "解析AVI.h"
#include "Dlg2.h"
#include "afxdialogex.h"
#include "解析AVIDlg.h"
// CDlg2 对话框
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_LBUTTONDOWN()
END_MESSAGE_MAP()
void CDlg2::OnBnClickedOk()
{
}
BOOL CDlg2::OnEraseBkgnd(CDC* pDC)
{
C解析AVIDlg* pDlg = (C解析AVIDlg*)theApp.m_pMainWnd;
CRect rect;
GetClientRect(rect);
pDC->FillSolidRect(rect, pDlg->BkColor);
pDC->SelectObject(&font1);
int Count = pDlg->ar.GetCount();
for (int i = 0; i < Count; i++)
{
INFO* pInfo = (INFO*)pDlg->ar.GetAt(i);
pDC->FillSolidRect(pInfo->pRect, pInfo->color);
pDC->DrawText(pInfo->item, pInfo->pRect, DT_CENTER);
pDC->FrameRect(pInfo->pRect, &CBrush(RGB(0, 0, 0)));
}
pDC->SetBkMode(TRANSPARENT);
int LineCount = pDlg->arLine.GetCount();
for (int i = 0; i < LineCount; i++)
{
LINE* pLine = (LINE*)pDlg->arLine.GetAt(i);
pDC->MoveTo(pLine->star);
pDC->LineTo(pLine->end);
pDC->TextOut(pLine->end.x+2, pLine->end.y - 7, pLine->pos);
}
return TRUE;
// return CDialogEx::OnEraseBkgnd(pDC);
}
BOOL CDlg2::OnInitDialog()
{
CDialogEx::OnInitDialog();
return TRUE;
}
void CDlg2::OnLButtonDown(UINT nFlags, CPoint point)
{
C解析AVIDlg* pDlg = (C解析AVIDlg*)theApp.m_pMainWnd;
int Count = pDlg->ar.GetCount();
for (int i = 0; i < Count; i++)
{
INFO* pInfo = (INFO*)pDlg->ar.GetAt(i);
if (pInfo->pRect->PtInRect(point))
{
CString cr = pInfo->ID.Left(3);
CString id = pInfo->ID.Right(pInfo->ID.GetLength() - 4);
if (cr == L"可读取")
{
if (id == L"指向索引块")
{
pDlg->ParsingIx(pInfo->STAR, pInfo->LEN);
break;
}
if(id == L"idx1")
{
pDlg->ParsingIdx1(pInfo->STAR, pInfo->LEN);
break;
}
if (id == L"二进制")
{
pDlg->ParsingX(pInfo->STAR, pInfo->LEN);
}
}
}
}
CDialogEx::OnLButtonDown(nFlags, point);
}
#pragma once
#include "afxcmn.h"
#include "MyEdit.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:
CMyEdit richedit;
virtual BOOL OnInitDialog();
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
afx_msg void On32780();
afx_msg void On32779();
afx_msg void On32781();
afx_msg void On32782();
afx_msg void OnPaint();
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
};
// Dlg3.cpp : 实现文件
//
#include "stdafx.h"
#include "解析AVI.h"
#include "Dlg3.h"
#include "afxdialogex.h"
DWORD CALLBACK MyStreamOutCallback(DWORD dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb)
{
CFile* pFile = (CFile*)dwCookie; pFile->Write(pbBuff, cb);
*pcb = cb;
return 0;
}
DWORD CALLBACK InRichEdit(DWORD dwCookie, LPBYTE lpBuf, LONG nCount, LONG* nRead)//从内存输入到多格式编辑控件
{
CFile* pFile = (CFile*)dwCookie;
*nRead = pFile->Read(lpBuf, nCount);
return 0;
}
IMPLEMENT_DYNAMIC(CDlg3, CDialogEx)
CDlg3::CDlg3(CWnd* pParent /*=NULL*/)
: CDialogEx(IDD_DIALOG3, pParent)
{
}
CDlg3::~CDlg3()
{
}
void CDlg3::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Control(pDX, IDC_RICHEDIT5, richedit);
}
BEGIN_MESSAGE_MAP(CDlg3, CDialogEx)
ON_WM_ERASEBKGND()
ON_COMMAND(ID_32780, &CDlg3::On32780)
ON_COMMAND(ID_32779, &CDlg3::On32779)
ON_COMMAND(ID_32781, &CDlg3::On32781)
ON_COMMAND(ID_32782, &CDlg3::On32782)
ON_WM_PAINT()
ON_WM_CREATE()
END_MESSAGE_MAP()
BOOL CDlg3::OnInitDialog()
{
CDialogEx::OnInitDialog();
CRect rect(0, 0, 1000, 600);//设置客户区大小,宽1000像素,高600像素
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();//居中对话框
CRect ClientRect;
GetClientRect(ClientRect);
ClientRect.DeflateRect(6, 6);
richedit.MoveWindow(ClientRect);
richedit.SetBackgroundColor(FALSE, RGB(255, 193, 132));
CRect EditRect;
richedit.GetRect(EditRect);
EditRect.DeflateRect(20, 2, 20, 2);
richedit.SetRect(EditRect);
HRSRC hRes = FindResource(NULL, MAKEINTRESOURCE(IDR_RIF1), _T("RIF"));
HGLOBAL hMem = LoadResource(NULL, hRes);
BYTE* pb = (BYTE*)LockResource(hMem);//获取数据的起始内存地址
DWORD Len=SizeofResource(NULL, hRes);//获取数据的大小,以字节为单位
CMemFile F;//声明内存文件对象
F.Attach(pb, Len);
EDITSTREAM es;
es.pfnCallback = &InRichEdit;//InRichEdit的函数定义,参见“多格式编辑控件显示图片”
es.dwCookie = (DWORD)&F;//将内存文件指针传递给dwCookie参数
es.dwError = 0;
richedit.StreamIn(SF_RTF, es);//将内存中的内容输入到多格式编辑控件
FreeResource(hMem);//最后释放数据占用的内存
return TRUE;
}
BOOL CDlg3::OnEraseBkgnd(CDC* pDC)
{
CRect rect;
GetClientRect(rect);
pDC->FillSolidRect(rect, RGB(49, 49, 49));
return TRUE;
// return CDialogEx::OnEraseBkgnd(pDC);
}
void CDlg3::On32780()//复制
{
richedit.Copy();
}
void CDlg3::On32779()//粘贴
{
richedit.Paste();
}
void CDlg3::On32781()
{
richedit.SetSel(0, -1);
}
void CDlg3::On32782()//保存
{
CFile file(_T("帮助.rtf"), CFile::modeCreate | CFile::modeWrite); //声明文件对象
EDITSTREAM es;
es.pfnCallback = MyStreamOutCallback;//指定流输出使用的回调函数
es.dwCookie = (DWORD)&file;//将文件指针传递给dwCookie参数
richedit.StreamOut(SF_RTF, es);//以RTF格式输出
}
void CDlg3::OnPaint()
{
CPaintDC dc(this);
richedit.SetSel(0, 0);
}
int CDlg3::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CDialogEx::OnCreate(lpCreateStruct) == -1)
return -1;
LoadLibrary(TEXT("Msftedit.dll"));
HWND hwndEdit = CreateWindowEx(0, MSFTEDIT_CLASS, TEXT(""),
ES_MULTILINE | ES_WANTRETURN | WS_VISIBLE | WS_CHILD | WS_VSCROLL,
10, 10, 400, 300, GetSafeHwnd(), NULL, theApp.m_hInstance, NULL);
if (hwndEdit != NULL)
{
richedit.SubclassWindow(hwndEdit);
richedit.SetDlgCtrlID(IDC_RICHEDIT5);
}
return 0;
}