我的程序出了很多这样的错误:must have class/struct/union type请解释一下 我考了一些别人的代码,只是单纯一一加入它们的.cpp和.h文件别的没做,但我不知道做什么? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 好的// binview.cpp : implementation file// #include "stdafx.h" #include "sj5mem.h"#include "bindoc.h" #include "binview.h"#include "stdlib.h" #include "time.h" #include "modeless.h"#ifdef _DEBUG#undef THIS_FILEstatic char BASED_CODE THIS_FILE[] = __FILE__;#endifchar mesg[256];/////////////////////////////////////////////////////////////////////////////// CBinViewIMPLEMENT_DYNCREATE(CBinView, CScrollView)CBinView::CBinView(){ LOGFONT logfont; memset(&logfont, 0, sizeof(logfont)); logfont.lfHeight =-5; logfont.lfWidth=5; static char BASED_CODE szFaceName[] = "MS Scans Serif"; lstrcpy(logfont.lfFaceName, szFaceName); ASSERT(m_Font.CreateFontIndirect(&logfont));// m_dwStartLine = 0;// m_dwTotalLine = 0; // m_nStartPos=0; // m_dwCurLine=0;// m_bsearch=FALSE; m_lTotalength=0; m_lCurPos=0; m_nPageSize=512; searchnum=0; StopWait=FALSE; }CBinView::~CBinView(){}BEGIN_MESSAGE_MAP(CBinView, CScrollView) //{{AFX_MSG_MAP(CBinView) ON_COMMAND(ID_FILE_PRINT, OnFilePrint) ON_COMMAND(ID_FILE_PRINT_PREVIEW, OnFilePrintPreview) ON_WM_VSCROLL() ON_COMMAND(ID_EDIT_SEARCH, OnEditSearch) ON_WM_KEYDOWN() ON_COMMAND(ID_EDIT_DOWN, OnEditDown) ON_COMMAND(ID_EDIT_UP, OnEditUp) ON_COMMAND(ID_VIEW_PAGE, OnViewPage) ON_COMMAND(ID_PAGE_DOWN, OnPageDown) ON_COMMAND(ID_PAGE_UP, OnPageUp) ON_WM_LBUTTONDOWN() //}}AFX_MSG_MAP ON_MESSAGE(ID_EXITWAIT,OnExitWait)END_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////// CBinView drawing LONG CBinView::OnExitWait(UINT wParam,LONG lParam) {StopWait=TRUE; return 0L;} void CBinView::OnInitialUpdate(){ CScrollView::OnInitialUpdate(); m_sScrollSize=GetTotalSize(); m_pDoc = GetDocument(); length = m_pDoc->GetDocLength(); pFile=(CFile*)m_pDoc->GetCFileP(); m_sScrollSize.cy=YSCROLL; ASSERT(m_sScrollSize.cx >= 0 && m_sScrollSize.cy >= 0);// m_dwTotalLine = length/20+1; m_lTotalength=length; SetScrollSizes(MM_TEXT, m_sScrollSize); SetScrollRange(SB_VERT,0,m_sScrollSize.cy);}void CBinView::OnDraw(CDC* pDC){ char text[30]; pDC->SelectObject(&m_Font); CStatusBar *pStatus=(CStatusBar*) AfxGetApp()->m_pMainWnd->GetDescendantWindow(ID_STATUS_BAR); if(pStatus){ wsprintf(text,"Ò³³¤=%d",m_nPageSize); pStatus->SetPaneText(1,text); wsprintf(text,"µ±Ç°Î»Öãº%ld",m_lCurPos); pStatus->SetPaneText(2,text); wsprintf(text,"Îļþ×ܳ¤£º%ld",m_lTotalength); pStatus->SetPaneText(3,text); } Drawdata();}void CBinView::Drawdata(){ long int shift=0; int num; char temp[255]; CClientDC pDC(this); int m_nScrollPos; int Tab[10]; if(m_lTotalength==0)return; Tab[0]=60; m_nScrollPos=(int)(YSCROLL*(float)m_lCurPos/m_lTotalength); SetScrollPos(SB_VERT,m_nScrollPos); for(int i = 0 ; i < 27; ++ i) { shift = m_lCurPos+i*20; if( (length) > (shift + 21)) { num = 20; MyTransData(shift , num , temp); pDC.TabbedTextOut(5,i*13,temp,strlen(temp),1,Tab,10); } else { num = (int)(m_lTotalength-shift) ; MyTransData(shift , num , temp); pDC.TabbedTextOut(5,i*13,temp,strlen(temp),1,Tab,10); break; } } /* if(m_bsearch){ CRect m_rInvRect; m_rInvRect.left=(m_nStartPos/2-1)*60+5; m_rInvRect.right=(m_nStartPos/2-1)*60+43; m_rInvRect.top=(int)(m_dwCurLine-m_dwStartLine)*18; m_rInvRect.bottom=(int)(m_dwCurLine-m_dwStartLine+1)*18; pDC.InvertRect(m_rInvRect); }*/ }void CBinView::MyTransData(long int shift,int num, LPSTR temp){ int i; char string[80]; char array[255]; lstrcpy(temp,""); if(num>=num && sizeof(array)>=num) { pFile->Seek(shift,CFile::begin); pFile->Read(array,num); for(i=0;i<num/2;++i) { wsprintf(string,"%02X%02X\t",(unsigned char)array[2*i], (unsigned char)array[2*i+1]); lstrcat(temp,string); } if(num%2==1) { wsprintf(string,"%02X \t",(unsigned char)array[2*i]); lstrcat(temp,string); } }} BOOL CBinView::OnPreparePrinting(CPrintInfo* pInfo){ _strdate( dbuffer ); _strtime( tbuffer ); //pInfo->SetMaxPage((int)(length/600+1)); //modified at 1996,3,17 liu pInfo->SetMaxPage((int)((length-m_lCurPos)/m_nPageSize)+1); return DoPreparePrinting(pInfo);}/////////////////////////////////////////////////////////////////////////////// CBinView message handlersvoid CBinView::OnFilePrint(){if(m_nPageSize>720) { ::MessageBeep(-1); ::MessageBox(NULL, "Ò³³¤Ì«´ó£¬ÎÞ·¨´òÓ¡, ÇëÖØÐÂÉèÖÃÒ³³¤", "Ìáʾ", MB_ICONINFORMATION | MB_OK); return; }CView::OnFilePrint();}void CBinView::OnFilePrintPreview(){ if(m_nPageSize>720) { ::MessageBeep(-1); ::MessageBox(NULL, "Ò³³¤Ì«´ó£¬ÎÞ·¨Ô¤ÏÔ, ÇëÖØÐÂÉèÖÃÒ³³¤", "Ìáʾ", MB_ICONINFORMATION | MB_OK); return; } CView::OnFilePrintPreview();}void CBinView::OnPrint(CDC* pDC,CPrintInfo* pInfo){ TEXTMETRIC textmetric; char temp[255]; long int shift=0; LPSTR lpBinHdr=0; int nDrawX,nDrawY; CString ftitle; char npage[20]; char tmpbuff[80]; int nCoody ; int num = 0; int i; BeginWaitCursor(); ftitle=m_pDoc->GetTitle(); pDC->GetTextMetrics((LPTEXTMETRIC)&textmetric); nDrawX = 4 * textmetric.tmAveCharWidth; nDrawY = 2 * (textmetric.tmExternalLeading + textmetric.tmHeight); nCoody = nDrawY; shift= (pInfo->m_nCurPage-1)*m_nPageSize+m_lCurPos; pDC->TextOut(nDrawX,0,ftitle); long int writebyte=min(length-shift,(long int)m_nPageSize); int shang,yushu; shang= (int)writebyte/20; yushu = (int)writebyte%20; for(i=0;i<shang;i++) { num = 20; MyTransData( shift , num , temp); shift += 20; nCoody += 25+(textmetric.tmExternalLeading + textmetric.tmHeight) ; pDC->TabbedTextOut(nDrawX,nCoody,temp,strlen(temp),0,NULL,nDrawX); } MyTransData( shift , yushu , temp); nCoody += 25+(textmetric.tmExternalLeading + textmetric.tmHeight) ; pDC->TabbedTextOut(nDrawX,nCoody,temp,strlen(temp),0,NULL,nDrawX); nDrawY=pDC->GetDeviceCaps(VERTRES)-50; wsprintf(tmpbuff,"Îļþ×ܳ¤£º%ld ±¾Ò³ÆðʼλÖãº%ld",length,(pInfo->m_nCurPage-1)*m_nPageSize+m_lCurPos); pDC->TextOut(nDrawX,nDrawY-50,tmpbuff); wsprintf(npage,"µÚ%dÒ³",pInfo->m_nCurPage); pDC->TextOut(nDrawX,nDrawY,npage); pDC->TextOut(nDrawX+200,nDrawY,"´òÓ¡ÈÕÆÚ"); pDC->TextOut(nDrawX+450,nDrawY,dbuffer); pDC->TextOut(nDrawX+700,nDrawY,"´òӡʱ¼ä"); pDC->TextOut(nDrawX+950,nDrawY,tbuffer); EndWaitCursor();}void CBinView::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar){ // TODO: Add your message handler code here and/or call default switch(nSBCode) { case SB_THUMBPOSITION: m_lCurPos=(long int)(((float)nPos/YSCROLL)*m_lTotalength); Invalidate(); break; case SB_LINEDOWN: m_lCurPos+=20; if (m_lCurPos>m_lTotalength) m_lCurPos=m_lTotalength; Invalidate(); break; case SB_LINEUP: if(m_lCurPos>20) m_lCurPos-=20; else m_lCurPos=0; Invalidate(); break; case SB_PAGEDOWN: m_lCurPos+=m_nPageSize; if(m_lCurPos>m_lTotalength) m_lCurPos=m_lTotalength; Invalidate(); break; case SB_PAGEUP: if(m_lCurPos>m_nPageSize) m_lCurPos-=m_nPageSize; else m_lCurPos=0; Invalidate(); break; default: break; } } unsigned char CBinView::change(unsigned char hight ,unsigned char low){unsigned h,l;if (hight>='0' && hight<='9')h=hight-'0';else if(hight>='a' && hight<='f')h=hight-'a'+10;else if(hight>='A' && hight<='F')h=hight-'A'+10;if (low>='0' && low<='9')l=low-'0';else if(low>='a' && low<='f')l=low-'a'+10;else if(low>='A' && low<='F')l=low-'A'+10;return(h*16+l);}int CBinView::isxdigit(unsigned char i) {if(i>='0' && i<='9')return 1;if(i>='a' && i<='f')return 1;if(i>='A' && i<='F')return 1;return 0;} BOOL CBinView::changesearch(){ int i;int k=1; if(searchnum%2==1)return FALSE; for(i=0;i<searchnum && k==1;i++) { k=isxdigit(searchstr[i]); }if(k==0) return FALSE;int num=searchnum/2;for(i=0;i<num;i++) find[i]=change(searchstr[i*2],searchstr[i*2+1]);return TRUE;} void CBinView::OnEditSearch(){ // TODO: Add your command handler code here if(SearchDlg.DoModal()==IDOK) { if(SearchDlg.m_nSelect==1) { lstrcpy(searchstr,""); strcat(searchstr,SearchDlg.m_sSearchText); searchnum=SearchDlg.m_sSearchText.GetLength(); if(changesearch()==-FALSE) { ::MessageBeep(-1); ::MessageBox(NULL, "ÊäÈë×Ö·ûÓÐÎó, ÎÞ·¨²éÕÒ", "Ìáʾ", MB_ICONINFORMATION | MB_OK); } else { if(SearchDlg.m_nDirection==1) { SearchDown(); } if(SearchDlg.m_nDirection==0) { SearchUp(); } } } if(SearchDlg.m_nSelect==0) {Location();} } } void CBinView::SearchDown(){ if(searchnum==0) { ::MessageBeep(-1); ::MessageBox(NULL, "ûÓÐÕÒµ½¸Ã×Ö·û", "Ìáʾ", MB_ICONINFORMATION | MB_OK); return; } CModeless *waitbox; waitbox=new CModeless(this);waitbox->Create("ÕýÔÚ½øÐвéÕÒ£¬ÇëµÈ´ý"); m_bsearch=FALSE;//BeginWaitCursor(); unsigned char buf[1500];long int shang,yushu;long int i,j,k,m;long int lastlength=length-m_lCurPos;MSG Message;if((lastlength)<=1500) {shang=0;yushu=lastlength;}else { shang=(lastlength-500)/1000; yushu=(lastlength-500)%1000+500; } for( i=0;i<shang&&StopWait==FALSE;i++) { if(::PeekMessage(&Message,NULL,0,0,PM_REMOVE)) { ::TranslateMessage(&Message); ::DispatchMessage(&Message); } waitbox->SetBar((int)(i*100/shang)); pFile->Seek((long int)i*1000+m_lCurPos+1,CFile::begin); pFile->Read(buf,1500); for( j=0;j<1300;j++) if(buf[j]==find[0]) { m=0; for( k=0;k<searchnum/2&&StopWait==FALSE;k++) if(buf[j+k]==find[k])m++; if(m==searchnum/2) { m_lCurPos=m_lCurPos+1+(long int)i*1000+j; m_bsearch=TRUE; Invalidate(); break; } } if(m_bsearch==TRUE)break; } if(m_bsearch==TRUE) { waitbox->DestroyWindow(); StopWait=FALSE; return; }pFile->Seek((long int)shang*1000+m_lCurPos+1,CFile::begin);pFile->Read(buf,(int)yushu);for( j=0;j<yushu-searchnum/2&&StopWait==FALSE;j++) if(buf[j]==find[0]) { m=0; for( k=0;k<searchnum/2;k++) if(buf[j+k]==find[k])m++; if(m==searchnum/2) { m_lCurPos=m_lCurPos+1+(long int)shang*1000+j; m_bsearch=TRUE; Invalidate(); break; } } //EndWaitCursor(); waitbox->DestroyWindow(); StopWait=FALSE;if(!m_bsearch) { ::MessageBeep(-1); ::MessageBox(NULL, "ûÓÐÕÒµ½¸Ã×Ö·û", "Ìáʾ", MB_ICONINFORMATION | MB_OK); } }void CBinView::SearchUp(){ unsigned char buf[1500];long int tmppos;long int shang,yushu;long int i,j,k,m;long int lastlength=m_lCurPos;MSG Message; m_bsearch=FALSE;if(searchnum==0) { ::MessageBeep(-1); ::MessageBox(NULL, "ûÓÐÕÒµ½¸Ã×Ö·û", "Ìáʾ", MB_ICONINFORMATION | MB_OK); return; } CModeless *waitbox; waitbox=new CModeless(this);waitbox->Create("ÕýÔÚ½øÐвéÕÒ£¬ÇëµÈ´ý"); //BeginWaitCursor(); if((lastlength)<=1500) {shang=0;yushu=lastlength;}else { shang=(lastlength-500)/1000; yushu=(lastlength-500)%1000+500; } for(i=0;i<shang && StopWait==FALSE;i++) { if(::PeekMessage(&Message,NULL,0,0,PM_REMOVE)) { ::TranslateMessage(&Message); ::DispatchMessage(&Message); } waitbox->SetBar((int)(i*100/shang)); pFile->Seek((long int)i*1000,CFile::begin); pFile->Read(buf,1500); for( j=0;j<1300;j++) if(buf[j]==find[0]) { m=0; for( k=0;k<searchnum/2&&StopWait==FALSE;k++) if(buf[j+k]==find[k])m++; if(m==searchnum/2) { tmppos=(long int)i*1000+j; m_bsearch=TRUE; } } } if(StopWait!=FALSE) { ::MessageBeep(-1); ::MessageBox(NULL, "ûÓÐÕÒµ½¸Ã×Ö·û","Ìáʾ", MB_ICONINFORMATION | MB_OK); return; }pFile->Seek((long int)shang*1000,CFile::begin);pFile->Read(buf,(int)yushu);for( j=0;j<yushu-searchnum/2;j++) if(buf[j]==find[0]) { m=0; for( k=0;k<searchnum/2;k++) if(buf[j+k]==find[k])m++; if(m==searchnum/2) { tmppos=(long int)shang*1000+j; m_bsearch=TRUE; } } //EndWaitCursor(); waitbox->DestroyWindow(); StopWait=FALSE;if(!m_bsearch) { ::MessageBeep(-1); ::MessageBox(NULL, "ûÓÐÕÒµ½¸Ã×Ö·û", "Ìáʾ", MB_ICONINFORMATION | MB_OK); }else { m_lCurPos=tmppos; Invalidate(); } } void CBinView::Location(){ long int pos; m_bsearch=TRUE; pos=atol(SearchDlg.m_sSearchText); m_lCurPos=pos; if(m_lCurPos>m_lTotalength) m_lCurPos=m_lTotalength; if(m_lCurPos<0) m_lCurPos=0; Invalidate();} //#define VK_UP 38//#define VK_DOWN 40#define VK_PAGEUP 33#define VK_PAGEDOWN 34//#define VK_HOME 36//#define VK_END 35void CBinView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags){ // TODO: Add your message handler code here and/or call default switch (nChar) { case VK_PAGEUP: if(m_lCurPos>m_nPageSize) { m_lCurPos-=m_nPageSize; Invalidate(); } else if(m_lCurPos==0) MessageBeep(-1); else { m_lCurPos=0; Invalidate(); } break; case VK_PAGEDOWN: if(m_lCurPos<m_lTotalength-m_nPageSize) { m_lCurPos+=m_nPageSize; Invalidate(); } else MessageBeep(-1); break; case VK_UP: if(m_lCurPos==0) MessageBeep(-1); else { if(m_lCurPos>20) m_lCurPos-=20; else m_lCurPos=0; Invalidate(); } break; case VK_DOWN: if(m_lCurPos==m_lTotalength) MessageBeep(-1); else { m_lCurPos+=20; if(m_lCurPos>m_lTotalength) m_lCurPos=m_lTotalength; Invalidate(); } break; case VK_HOME: if(m_lCurPos==0)MessageBeep(-1); else { m_lCurPos=0; Invalidate(); } break; case VK_END: if(m_lCurPos==m_lTotalength)MessageBeep(-1); else { m_lCurPos=m_lTotalength; Invalidate(); } break; case VK_LEFT: if(m_lCurPos==0)MessageBeep(-1); else { m_lCurPos--; Invalidate(); } break; case VK_RIGHT: if(m_lCurPos==m_lTotalength)MessageBeep(-1); else { m_lCurPos++; Invalidate(); } break; } CScrollView::OnKeyDown(nChar, nRepCnt, nFlags);}void CBinView::OnEditDown(){ // TODO: Add your command handler code here SearchDown();}void CBinView::OnEditUp(){ // TODO: Add your command handler code here SearchUp();}void CBinView::OnViewPage(){ CComboBox *pCombo=(CComboBox*) AfxGetApp()->m_pMainWnd->GetDescendantWindow(IDW_COMBO); int index=pCombo->GetCurSel(); CString temp; if(index==-1) { pCombo->GetWindowText(temp); pCombo->InsertString(0,temp); pCombo->DeleteString(4); } else pCombo->GetLBText(index,temp); m_nPageSize=atoi(temp); CStatusBar *pStatus=(CStatusBar*) AfxGetApp()->m_pMainWnd->GetDescendantWindow(ID_STATUS_BAR); if(pStatus) { char text[30]; wsprintf(text,"Ò³³¤=%d",m_nPageSize); pStatus->SetPaneText(1,text); } SetFocus(); }/////////////////////////////////////////////////////////////////////////////void CBinView::OnPageDown(){ // TODO: Add your command handler code here if(m_lCurPos<m_lTotalength-m_nPageSize) { m_lCurPos+=m_nPageSize; Invalidate(); } }void CBinView::OnPageUp(){ // TODO: Add your command handler code here if(m_lCurPos>m_nPageSize) m_lCurPos-=m_nPageSize; else m_lCurPos=0; Invalidate(); }void CBinView::OnLButtonDown(UINT nFlags, CPoint point){ // TODO: Add your message handler code here and/or call default CScrollView::OnLButtonDown(nFlags, point); CRect rect; GetClientRect(rect); if(rect.PtInRect(point)) SetFocus(); } 第一天上班,学习LINUX下C/C++应该怎样入手,看什么书,用什么开发工具? cs.style |= LVS_REPORT? 帮我看一下这个小程序有什么错误? 如何将_variant_t类型的变量转换成CString型变量?? int *A[3];和int (*A)[3];有什么区别呀? 请问各位大侠哪有ftp服务器源程序?多谢! 如何计算一个表达式 ActiveX控件怎么得到当前容器的句柄?? 字符串类型的转换问题? 谢谢 江湖告急:求一个可以屏蔽其他功能的“超级”弹出框 如何把BSTR转化成char *或CString类型 这个问题难道真的需要高手才能解决吗?
// binview.cpp : implementation file
// #include "stdafx.h"
#include "sj5mem.h"
#include "bindoc.h"
#include "binview.h"
#include "stdlib.h"
#include "time.h"
#include "modeless.h"#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endifchar mesg[256];
/////////////////////////////////////////////////////////////////////////////
// CBinViewIMPLEMENT_DYNCREATE(CBinView, CScrollView)CBinView::CBinView()
{
LOGFONT logfont;
memset(&logfont, 0, sizeof(logfont)); logfont.lfHeight =-5;
logfont.lfWidth=5;
static char BASED_CODE szFaceName[] = "MS Scans Serif";
lstrcpy(logfont.lfFaceName, szFaceName); ASSERT(m_Font.CreateFontIndirect(&logfont));
// m_dwStartLine = 0;
// m_dwTotalLine = 0;
// m_nStartPos=0;
// m_dwCurLine=0;
// m_bsearch=FALSE;
m_lTotalength=0;
m_lCurPos=0;
m_nPageSize=512;
searchnum=0;
StopWait=FALSE;
}CBinView::~CBinView()
{
}
BEGIN_MESSAGE_MAP(CBinView, CScrollView)
//{{AFX_MSG_MAP(CBinView)
ON_COMMAND(ID_FILE_PRINT, OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, OnFilePrintPreview)
ON_WM_VSCROLL()
ON_COMMAND(ID_EDIT_SEARCH, OnEditSearch)
ON_WM_KEYDOWN()
ON_COMMAND(ID_EDIT_DOWN, OnEditDown)
ON_COMMAND(ID_EDIT_UP, OnEditUp)
ON_COMMAND(ID_VIEW_PAGE, OnViewPage)
ON_COMMAND(ID_PAGE_DOWN, OnPageDown)
ON_COMMAND(ID_PAGE_UP, OnPageUp)
ON_WM_LBUTTONDOWN()
//}}AFX_MSG_MAP
ON_MESSAGE(ID_EXITWAIT,OnExitWait)
END_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////
// CBinView drawing
LONG CBinView::OnExitWait(UINT wParam,LONG lParam)
{
StopWait=TRUE;
return 0L;
}
void CBinView::OnInitialUpdate()
{
CScrollView::OnInitialUpdate();
m_sScrollSize=GetTotalSize();
m_pDoc = GetDocument();
length = m_pDoc->GetDocLength();
pFile=(CFile*)m_pDoc->GetCFileP();
m_sScrollSize.cy=YSCROLL;
ASSERT(m_sScrollSize.cx >= 0 && m_sScrollSize.cy >= 0);
// m_dwTotalLine = length/20+1;
m_lTotalength=length; SetScrollSizes(MM_TEXT, m_sScrollSize);
SetScrollRange(SB_VERT,0,m_sScrollSize.cy);
}void CBinView::OnDraw(CDC* pDC)
{
char text[30];
pDC->SelectObject(&m_Font);
CStatusBar *pStatus=(CStatusBar*)
AfxGetApp()->m_pMainWnd->GetDescendantWindow(ID_STATUS_BAR);
if(pStatus){
wsprintf(text,"Ò³³¤=%d",m_nPageSize);
pStatus->SetPaneText(1,text);
wsprintf(text,"µ±Ç°Î»Öãº%ld",m_lCurPos);
pStatus->SetPaneText(2,text);
wsprintf(text,"Îļþ×ܳ¤£º%ld",m_lTotalength);
pStatus->SetPaneText(3,text);
}
Drawdata();
}void CBinView::Drawdata()
{
long int shift=0;
int num;
char temp[255]; CClientDC pDC(this);
int m_nScrollPos;
int Tab[10];
if(m_lTotalength==0)return;
Tab[0]=60;
m_nScrollPos=(int)(YSCROLL*(float)m_lCurPos/m_lTotalength);
SetScrollPos(SB_VERT,m_nScrollPos);
for(int i = 0 ; i < 27; ++ i)
{
shift = m_lCurPos+i*20;
if( (length) > (shift + 21))
{
num = 20;
MyTransData(shift , num , temp);
pDC.TabbedTextOut(5,i*13,temp,strlen(temp),1,Tab,10);
}
else
{
num = (int)(m_lTotalength-shift) ;
MyTransData(shift , num , temp);
pDC.TabbedTextOut(5,i*13,temp,strlen(temp),1,Tab,10);
break;
}
}
/*
if(m_bsearch){
CRect m_rInvRect;
m_rInvRect.left=(m_nStartPos/2-1)*60+5;
m_rInvRect.right=(m_nStartPos/2-1)*60+43;
m_rInvRect.top=(int)(m_dwCurLine-m_dwStartLine)*18;
m_rInvRect.bottom=(int)(m_dwCurLine-m_dwStartLine+1)*18;
pDC.InvertRect(m_rInvRect);
}
*/
}void CBinView::MyTransData(long int shift,int num, LPSTR temp)
{
int i;
char string[80];
char array[255];
lstrcpy(temp,"");
if(num>=num && sizeof(array)>=num)
{
pFile->Seek(shift,CFile::begin);
pFile->Read(array,num);
for(i=0;i<num/2;++i)
{
wsprintf(string,"%02X%02X\t",(unsigned char)array[2*i],
(unsigned char)array[2*i+1]);
lstrcat(temp,string);
}
if(num%2==1)
{
wsprintf(string,"%02X \t",(unsigned char)array[2*i]);
lstrcat(temp,string);
}
}
}
BOOL CBinView::OnPreparePrinting(CPrintInfo* pInfo)
{
_strdate( dbuffer );
_strtime( tbuffer );
//pInfo->SetMaxPage((int)(length/600+1));
//modified at 1996,3,17 liu
pInfo->SetMaxPage((int)((length-m_lCurPos)/m_nPageSize)+1);
return DoPreparePrinting(pInfo);
}/////////////////////////////////////////////////////////////////////////////
// CBinView message handlers
void CBinView::OnFilePrint()
{
if(m_nPageSize>720)
{
::MessageBeep(-1);
::MessageBox(NULL, "Ò³³¤Ì«´ó£¬ÎÞ·¨´òÓ¡, ÇëÖØÐÂÉèÖÃÒ³³¤", "Ìáʾ",
MB_ICONINFORMATION | MB_OK);
return;
}
CView::OnFilePrint();
}void CBinView::OnFilePrintPreview()
{
if(m_nPageSize>720)
{
::MessageBeep(-1);
::MessageBox(NULL, "Ò³³¤Ì«´ó£¬ÎÞ·¨Ô¤ÏÔ, ÇëÖØÐÂÉèÖÃÒ³³¤", "Ìáʾ",
MB_ICONINFORMATION | MB_OK);
return;
}
CView::OnFilePrintPreview();
}void CBinView::OnPrint(CDC* pDC,CPrintInfo* pInfo)
{
TEXTMETRIC textmetric;
char temp[255];
long int shift=0;
LPSTR lpBinHdr=0;
int nDrawX,nDrawY;
CString ftitle;
char npage[20];
char tmpbuff[80];
int nCoody ;
int num = 0;
int i;
BeginWaitCursor();
ftitle=m_pDoc->GetTitle();
pDC->GetTextMetrics((LPTEXTMETRIC)&textmetric);
nDrawX = 4 * textmetric.tmAveCharWidth;
nDrawY = 2 * (textmetric.tmExternalLeading + textmetric.tmHeight);
nCoody = nDrawY;
shift= (pInfo->m_nCurPage-1)*m_nPageSize+m_lCurPos;
pDC->TextOut(nDrawX,0,ftitle);
long int writebyte=min(length-shift,(long int)m_nPageSize);
int shang,yushu;
shang= (int)writebyte/20;
yushu = (int)writebyte%20;
for(i=0;i<shang;i++)
{
num = 20;
MyTransData( shift , num , temp);
shift += 20;
nCoody += 25+(textmetric.tmExternalLeading + textmetric.tmHeight) ;
pDC->TabbedTextOut(nDrawX,nCoody,temp,strlen(temp),0,NULL,nDrawX);
} MyTransData( shift , yushu , temp);
nCoody += 25+(textmetric.tmExternalLeading + textmetric.tmHeight) ;
pDC->TabbedTextOut(nDrawX,nCoody,temp,strlen(temp),0,NULL,nDrawX);
nDrawY=pDC->GetDeviceCaps(VERTRES)-50;
wsprintf(tmpbuff,"Îļþ×ܳ¤£º%ld ±¾Ò³ÆðʼλÖãº%ld",length,(pInfo->m_nCurPage-1)*m_nPageSize+m_lCurPos);
pDC->TextOut(nDrawX,nDrawY-50,tmpbuff); wsprintf(npage,"µÚ%dÒ³",pInfo->m_nCurPage);
pDC->TextOut(nDrawX,nDrawY,npage); pDC->TextOut(nDrawX+200,nDrawY,"´òÓ¡ÈÕÆÚ");
pDC->TextOut(nDrawX+450,nDrawY,dbuffer);
pDC->TextOut(nDrawX+700,nDrawY,"´òӡʱ¼ä");
pDC->TextOut(nDrawX+950,nDrawY,tbuffer);
EndWaitCursor();
}void CBinView::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
// TODO: Add your message handler code here and/or call default
switch(nSBCode)
{
case SB_THUMBPOSITION:
m_lCurPos=(long int)(((float)nPos/YSCROLL)*m_lTotalength);
Invalidate();
break;
case SB_LINEDOWN:
m_lCurPos+=20;
if (m_lCurPos>m_lTotalength)
m_lCurPos=m_lTotalength;
Invalidate();
break;
case SB_LINEUP:
if(m_lCurPos>20)
m_lCurPos-=20;
else
m_lCurPos=0;
Invalidate();
break;
case SB_PAGEDOWN:
m_lCurPos+=m_nPageSize;
if(m_lCurPos>m_lTotalength)
m_lCurPos=m_lTotalength;
Invalidate();
break;
case SB_PAGEUP:
if(m_lCurPos>m_nPageSize)
m_lCurPos-=m_nPageSize;
else
m_lCurPos=0;
Invalidate();
break;
default:
break;
}
}
unsigned char CBinView::change(unsigned char hight ,unsigned char low)
{
unsigned h,l;if (hight>='0' && hight<='9')h=hight-'0';
else if(hight>='a' && hight<='f')h=hight-'a'+10;
else if(hight>='A' && hight<='F')h=hight-'A'+10;
if (low>='0' && low<='9')l=low-'0';
else if(low>='a' && low<='f')l=low-'a'+10;
else if(low>='A' && low<='F')l=low-'A'+10;return(h*16+l);
}
int CBinView::isxdigit(unsigned char i)
{
if(i>='0' && i<='9')return 1;
if(i>='a' && i<='f')return 1;
if(i>='A' && i<='F')return 1;
return 0;
}
BOOL CBinView::changesearch()
{
int i;
int k=1;
if(searchnum%2==1)return FALSE;
for(i=0;i<searchnum && k==1;i++)
{ k=isxdigit(searchstr[i]); }
if(k==0) return FALSE;
int num=searchnum/2;
for(i=0;i<num;i++)
find[i]=change(searchstr[i*2],searchstr[i*2+1]);
return TRUE;
} void CBinView::OnEditSearch()
{
// TODO: Add your command handler code here
if(SearchDlg.DoModal()==IDOK) {
if(SearchDlg.m_nSelect==1)
{
lstrcpy(searchstr,"");
strcat(searchstr,SearchDlg.m_sSearchText);
searchnum=SearchDlg.m_sSearchText.GetLength();
if(changesearch()==-FALSE)
{
::MessageBeep(-1);
::MessageBox(NULL, "ÊäÈë×Ö·ûÓÐÎó, ÎÞ·¨²éÕÒ", "Ìáʾ",
MB_ICONINFORMATION | MB_OK); }
else
{
if(SearchDlg.m_nDirection==1)
{ SearchDown(); }
if(SearchDlg.m_nDirection==0)
{ SearchUp(); }
}
}
if(SearchDlg.m_nSelect==0)
{Location();}
}
} void CBinView::SearchDown()
{
if(searchnum==0)
{
::MessageBeep(-1);
::MessageBox(NULL, "ûÓÐÕÒµ½¸Ã×Ö·û", "Ìáʾ",
MB_ICONINFORMATION | MB_OK);
return;
}
CModeless *waitbox;
waitbox=new CModeless(this);
waitbox->Create("ÕýÔÚ½øÐвéÕÒ£¬ÇëµÈ´ý");
m_bsearch=FALSE;
//BeginWaitCursor();
unsigned char buf[1500];
long int shang,yushu;
long int i,j,k,m;
long int lastlength=length-m_lCurPos;
MSG Message;
if((lastlength)<=1500)
{shang=0;yushu=lastlength;}
else
{
shang=(lastlength-500)/1000;
yushu=(lastlength-500)%1000+500;
}
for( i=0;i<shang&&StopWait==FALSE;i++)
{
if(::PeekMessage(&Message,NULL,0,0,PM_REMOVE))
{
::TranslateMessage(&Message);
::DispatchMessage(&Message);
}
waitbox->SetBar((int)(i*100/shang));
pFile->Seek((long int)i*1000+m_lCurPos+1,CFile::begin);
pFile->Read(buf,1500);
for( j=0;j<1300;j++)
if(buf[j]==find[0])
{
m=0;
for( k=0;k<searchnum/2&&StopWait==FALSE;k++)
if(buf[j+k]==find[k])m++;
if(m==searchnum/2)
{
m_lCurPos=m_lCurPos+1+(long int)i*1000+j;
m_bsearch=TRUE;
Invalidate();
break;
}
}
if(m_bsearch==TRUE)break;
}
if(m_bsearch==TRUE)
{
waitbox->DestroyWindow();
StopWait=FALSE;
return;
}
pFile->Seek((long int)shang*1000+m_lCurPos+1,CFile::begin);
pFile->Read(buf,(int)yushu);
for( j=0;j<yushu-searchnum/2&&StopWait==FALSE;j++)
if(buf[j]==find[0])
{
m=0;
for( k=0;k<searchnum/2;k++)
if(buf[j+k]==find[k])m++;
if(m==searchnum/2)
{
m_lCurPos=m_lCurPos+1+(long int)shang*1000+j;
m_bsearch=TRUE;
Invalidate();
break;
}
} //EndWaitCursor();
waitbox->DestroyWindow();
StopWait=FALSE;
if(!m_bsearch)
{
::MessageBeep(-1);
::MessageBox(NULL, "ûÓÐÕÒµ½¸Ã×Ö·û", "Ìáʾ",
MB_ICONINFORMATION | MB_OK); }
}void CBinView::SearchUp()
{
unsigned char buf[1500];
long int tmppos;
long int shang,yushu;
long int i,j,k,m;
long int lastlength=m_lCurPos;
MSG Message;
m_bsearch=FALSE;
if(searchnum==0)
{
::MessageBeep(-1);
::MessageBox(NULL, "ûÓÐÕÒµ½¸Ã×Ö·û", "Ìáʾ",
MB_ICONINFORMATION | MB_OK);
return;
} CModeless *waitbox;
waitbox=new CModeless(this);
waitbox->Create("ÕýÔÚ½øÐвéÕÒ£¬ÇëµÈ´ý"); //BeginWaitCursor();
if((lastlength)<=1500)
{shang=0;yushu=lastlength;}
else
{
shang=(lastlength-500)/1000;
yushu=(lastlength-500)%1000+500;
} for(i=0;i<shang && StopWait==FALSE;i++)
{
if(::PeekMessage(&Message,NULL,0,0,PM_REMOVE))
{
::TranslateMessage(&Message);
::DispatchMessage(&Message);
}
waitbox->SetBar((int)(i*100/shang)); pFile->Seek((long int)i*1000,CFile::begin);
pFile->Read(buf,1500);
for( j=0;j<1300;j++)
if(buf[j]==find[0])
{
m=0;
for( k=0;k<searchnum/2&&StopWait==FALSE;k++)
if(buf[j+k]==find[k])m++;
if(m==searchnum/2)
{
tmppos=(long int)i*1000+j;
m_bsearch=TRUE;
}
}
} if(StopWait!=FALSE)
{
::MessageBeep(-1);
::MessageBox(NULL, "ûÓÐÕÒµ½¸Ã×Ö·û","Ìáʾ",
MB_ICONINFORMATION | MB_OK);
return;
}pFile->Seek((long int)shang*1000,CFile::begin);
pFile->Read(buf,(int)yushu);
for( j=0;j<yushu-searchnum/2;j++)
if(buf[j]==find[0])
{
m=0;
for( k=0;k<searchnum/2;k++)
if(buf[j+k]==find[k])m++;
if(m==searchnum/2)
{
tmppos=(long int)shang*1000+j;
m_bsearch=TRUE;
}
}
//EndWaitCursor();
waitbox->DestroyWindow();
StopWait=FALSE;if(!m_bsearch)
{
::MessageBeep(-1);
::MessageBox(NULL, "ûÓÐÕÒµ½¸Ã×Ö·û", "Ìáʾ",
MB_ICONINFORMATION | MB_OK);
}
else
{
m_lCurPos=tmppos;
Invalidate();
}
}
void CBinView::Location()
{
long int pos;
m_bsearch=TRUE;
pos=atol(SearchDlg.m_sSearchText);
m_lCurPos=pos;
if(m_lCurPos>m_lTotalength)
m_lCurPos=m_lTotalength;
if(m_lCurPos<0)
m_lCurPos=0;
Invalidate();
} //#define VK_UP 38
//#define VK_DOWN 40
#define VK_PAGEUP 33
#define VK_PAGEDOWN 34
//#define VK_HOME 36
//#define VK_END 35void CBinView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call default
switch (nChar)
{
case VK_PAGEUP:
if(m_lCurPos>m_nPageSize)
{
m_lCurPos-=m_nPageSize;
Invalidate();
}
else if(m_lCurPos==0)
MessageBeep(-1);
else
{
m_lCurPos=0;
Invalidate();
}
break; case VK_PAGEDOWN:
if(m_lCurPos<m_lTotalength-m_nPageSize)
{
m_lCurPos+=m_nPageSize;
Invalidate();
}
else MessageBeep(-1);
break; case VK_UP:
if(m_lCurPos==0)
MessageBeep(-1);
else
{
if(m_lCurPos>20)
m_lCurPos-=20;
else
m_lCurPos=0;
Invalidate();
}
break; case VK_DOWN:
if(m_lCurPos==m_lTotalength)
MessageBeep(-1);
else
{
m_lCurPos+=20;
if(m_lCurPos>m_lTotalength)
m_lCurPos=m_lTotalength;
Invalidate();
}
break;
case VK_HOME:
if(m_lCurPos==0)MessageBeep(-1);
else
{
m_lCurPos=0;
Invalidate();
}
break;
case VK_END:
if(m_lCurPos==m_lTotalength)MessageBeep(-1);
else
{
m_lCurPos=m_lTotalength;
Invalidate();
}
break;
case VK_LEFT:
if(m_lCurPos==0)MessageBeep(-1);
else
{
m_lCurPos--;
Invalidate();
}
break;
case VK_RIGHT:
if(m_lCurPos==m_lTotalength)MessageBeep(-1);
else
{
m_lCurPos++;
Invalidate();
}
break;
} CScrollView::OnKeyDown(nChar, nRepCnt, nFlags);
}void CBinView::OnEditDown()
{
// TODO: Add your command handler code here
SearchDown();
}void CBinView::OnEditUp()
{
// TODO: Add your command handler code here
SearchUp();
}void CBinView::OnViewPage()
{
CComboBox *pCombo=(CComboBox*)
AfxGetApp()->m_pMainWnd->GetDescendantWindow(IDW_COMBO);
int index=pCombo->GetCurSel();
CString temp;
if(index==-1)
{
pCombo->GetWindowText(temp);
pCombo->InsertString(0,temp);
pCombo->DeleteString(4);
}
else
pCombo->GetLBText(index,temp); m_nPageSize=atoi(temp);
CStatusBar *pStatus=(CStatusBar*)
AfxGetApp()->m_pMainWnd->GetDescendantWindow(ID_STATUS_BAR);
if(pStatus)
{
char text[30];
wsprintf(text,"Ò³³¤=%d",m_nPageSize);
pStatus->SetPaneText(1,text);
}
SetFocus();
}/////////////////////////////////////////////////////////////////////////////void CBinView::OnPageDown()
{
// TODO: Add your command handler code here
if(m_lCurPos<m_lTotalength-m_nPageSize)
{
m_lCurPos+=m_nPageSize;
Invalidate();
}
}void CBinView::OnPageUp()
{
// TODO: Add your command handler code here
if(m_lCurPos>m_nPageSize)
m_lCurPos-=m_nPageSize;
else
m_lCurPos=0;
Invalidate();
}void CBinView::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CScrollView::OnLButtonDown(nFlags, point);
CRect rect;
GetClientRect(rect);
if(rect.PtInRect(point)) SetFocus(); }