📄 epbinvw.cpp
字号:
///////////////////////////////////////////////////////////////////////////
// File: epbinvw.cpp
// Version: 1.6.0.10
// Updated: 23-Oct-1999
//
// Binary View core
//
// Copyright: Ferdinand Prantl
// E-mail: prantl@ff.cuni.cz
//
// You are free to use or modify this code to the following restrictions:
// - Acknowledge me somewhere in your about box, simple "Parts of code by.."
// will be enough. If you can't (or don't want to), contact me personally.
// - LEAVE THIS HEADER INTACT
////////////////////////////////////////////////////////////////////////////
// epbinvw.cpp : implementation of the CEditPadBinView class
//
#include "stdafx.h"
#include "editpad.h"
#include "epbindoc.h"
#include "epbinvw.h"
#include "editcmd.h"
#include "generpg.h"
#include "editoroptionspage.h"
#include "fontpg.h"
#include "mainfrm.h"
#include "filesup.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CEditPadBinView
IMPLEMENT_DYNCREATE (CEditPadBinView, CHexEditView)
BEGIN_MESSAGE_MAP (CEditPadBinView, CHexEditView)
//{{AFX_MSG_MAP(CEditPadBinView)
ON_WM_CONTEXTMENU ()
ON_COMMAND (ID_VIEW_OPTIONS, OnViewOptions)
ON_WM_TIMER()
ON_WM_CREATE()
ON_COMMAND (ID_FILE_RELOAD, OnFileReload)
ON_UPDATE_COMMAND_UI(ID_FILE_RELOAD, OnUpdateFileReload)
//}}AFX_MSG_MAP
// Standard printing commands
// ON_COMMAND(ID_FILE_PRINT, CHexEditView::OnFilePrint)
// ON_COMMAND(ID_FILE_PRINT_DIRECT, CHexEditView::OnFilePrint)
// ON_COMMAND(ID_FILE_PRINT_PREVIEW, CHexEditView::OnFilePrintPreview)
END_MESSAGE_MAP ()
/////////////////////////////////////////////////////////////////////////////
// CEditPadBinView construction/destruction
CEditPadBinView::CEditPadBinView ()
{
m_data = NULL;
}
CEditPadBinView:: ~ CEditPadBinView ()
{
}
BOOL CEditPadBinView::
PreCreateWindow (CREATESTRUCT & cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CHexEditView::PreCreateWindow (cs);
}
/////////////////////////////////////////////////////////////////////////////
// CEditPadBinView drawing
void CEditPadBinView::OnDraw(CDC* pDC)
{
CEditPadBinDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CEditPadBinView printing
//BOOL CEditPadBinView::OnPreparePrinting(CPrintInfo* pInfo)
//{
// // default preparation
// return DoPreparePrinting(pInfo);
//}
//
//void CEditPadBinView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
//{
// // TODO: add extra initialization before printing
//}
//
//void CEditPadBinView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
//{
// // TODO: add cleanup after printing
//}
/////////////////////////////////////////////////////////////////////////////
// CEditPadBinView diagnostics
#ifdef _DEBUG
void CEditPadBinView::
AssertValid ()
const
{
CHexEditView::AssertValid ();
}
void CEditPadBinView::Dump (CDumpContext & dc)
const
{
CHexEditView::Dump (dc);
}
CEditPadBinDoc *CEditPadBinView::GetDocument () // non-debug version is inline
{
ASSERT (m_pDocument->IsKindOf (RUNTIME_CLASS (CEditPadBinDoc)));
return (CEditPadBinDoc *) m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CEditPadBinView message handlers
#pragma warning ( disable : 4100 )
void CEditPadBinView::
OnContextMenu (CWnd * pWnd, CPoint point)
{
CMenu menu;
if (menu.LoadMenu (IDR_EDITPADBINTYPE))
{
CMenu *pMenu = menu.GetSubMenu (1);
if (pMenu)
pMenu->TrackPopupMenu (TPM_LEFTBUTTON|TPM_RIGHTBUTTON/*|TPM_RETURNCMD*/|TPM_LEFTALIGN|TPM_TOPALIGN, point.x, point.y, this);
}
}
#pragma warning ( default : 4100 )
void CEditPadBinView::
OnViewOptions ()
{
CGeneralPage pgGeneral;
CEditorOptionsPage pgEditor;
CFontPage pgFont;
CString sTitle;
sTitle.LoadString (IDS_SHEET_OPTIONS);
CPropertySheet psOptions (sTitle, AfxGetMainWnd ());
psOptions.AddPage (&pgGeneral);
psOptions.AddPage (&pgEditor);
psOptions.AddPage (&pgFont);
psOptions.DoModal ();
}
int CEditPadBinView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CHexEditView::OnCreate(lpCreateStruct) == -1)
return -1;
return 0;
}
void CEditPadBinView::
OnFileReload ()
{
CEditPadBinDoc *pDoc = (CEditPadBinDoc*) GetDocument ();
ASSERT (pDoc);
CString sFilePath = pDoc->GetPathName ();
if (!FileExist (sFilePath))
{
AfxMessageBox (_T ("File does not exist."));
return;
}
if (theApp.m_dwFlags & EP_NOTIFY_CHANGES)
{
pDoc->StopWatching ();
pDoc->RemoveFile (sFilePath);
}
bool bResult = pDoc->SaveModified () != 0;
if (bResult)
{
POSITION pos = pDoc->GetFirstViewPosition ();
ASSERT (pos);
CEditPadBinView *pView;
do
{
pView = (CEditPadBinView*) pDoc->GetNextView (pos);
// do pushcursor
}
while (pos);
pDoc->LoadFromFile (sFilePath);
pos = pDoc->GetFirstViewPosition ();
ASSERT (pos);
do
{
pView = (CEditPadBinView*) pDoc->GetNextView (pos);
if (bResult)
;// do popcursor
else
;// do reset
pView->Invalidate ();
}
while (pos);
// pDoc->UpdateAllViews (this);
}
if (theApp.m_dwFlags & EP_NOTIFY_CHANGES)
{
pDoc->AddFile (sFilePath);
pDoc->StartWatching ();
}
}
// ->HE If no file saved yet, disable cmd
void CEditPadBinView::OnUpdateFileReload(CCmdUI* pCmdUI)
{
CEditPadBinDoc *pDoc = (CEditPadBinDoc*) GetDocument ();
ASSERT (pDoc);
pCmdUI->Enable (!pDoc->GetPathName ().IsEmpty ());
}
// <-HE
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -