📄 flexgridview.cpp
字号:
// FlexGridView.cpp : implementation of the CFlexGridView class
//
#include "stdafx.h"
#include "FlexGrid.h"
#include "FlexGridDoc.h"
#include "FlexGridView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CFlexGridView
IMPLEMENT_DYNCREATE(CFlexGridView, CFormView)
BEGIN_MESSAGE_MAP(CFlexGridView, CFormView)
//{{AFX_MSG_MAP(CFlexGridView)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CFormView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CFormView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CFormView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CFlexGridView construction/destruction
CFlexGridView::CFlexGridView()
: CFormView(CFlexGridView::IDD)
{
//{{AFX_DATA_INIT(CFlexGridView)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// TODO: add construction code here
}
CFlexGridView::~CFlexGridView()
{
}
void CFlexGridView::DoDataExchange(CDataExchange* pDX)
{
CFormView::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CFlexGridView)
DDX_Control(pDX, IDC_MSFLEXGRID1, m_grid);
//}}AFX_DATA_MAP
}
BOOL CFlexGridView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CFormView::PreCreateWindow(cs);
}
void CFlexGridView::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
GetParentFrame()->RecalcLayout();
ResizeParentToFit();
CWnd * hwnd = GetDlgItem (IDC_MSFLEXGRID1);
hGrid = hwnd->GetSafeHwnd ();
CString sHeading;
sHeading = _T(" | FIRST NAME | SECOND NAME | PHONE NUMBER | CITY | ZIP CODE ");
m_grid.SetFormatString ( sHeading);
}
/////////////////////////////////////////////////////////////////////////////
// CFlexGridView printing
BOOL CFlexGridView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CFlexGridView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CFlexGridView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
void CFlexGridView::OnPrint(CDC* pDC, CPrintInfo* /*pInfo*/)
{
// TODO: add customized printing code here
}
/////////////////////////////////////////////////////////////////////////////
// CFlexGridView diagnostics
#ifdef _DEBUG
void CFlexGridView::AssertValid() const
{
CFormView::AssertValid();
}
void CFlexGridView::Dump(CDumpContext& dc) const
{
CFormView::Dump(dc);
}
CFlexGridDoc* CFlexGridView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CFlexGridDoc)));
return (CFlexGridDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CFlexGridView message handlers
BEGIN_EVENTSINK_MAP(CFlexGridView, CFormView)
//{{AFX_EVENTSINK_MAP(CFlexGridView)
ON_EVENT(CFlexGridView, IDC_MSFLEXGRID1, -600 /* Click */, OnClickMsflexgrid1, VTS_NONE)
ON_EVENT(CFlexGridView, IDC_MSFLEXGRID1, -601 /* DblClick */, OnDblClickMsflexgrid1, VTS_NONE)
ON_EVENT(CFlexGridView, IDC_MSFLEXGRID1, -603 /* KeyPress */, OnKeyPressMsflexgrid1, VTS_PI2)
ON_EVENT(CFlexGridView, IDC_MSFLEXGRID1, 74 /* Compare */, OnCompareMsflexgrid1, VTS_I4 VTS_I4 VTS_PI2)
//}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()
void CFlexGridView::OnClickMsflexgrid1()
{
m_grid.OnClickGrid ();
}
void CFlexGridView::OnDblClickMsflexgrid1()
{
m_grid.OnClickGrid ();
}
void CFlexGridView::OnKeyPressMsflexgrid1(short FAR* KeyAscii)
{
m_grid.OnKeyPressGrid ( KeyAscii);
}
void CFlexGridView::OnCompareMsflexgrid1(long Row1, long Row2, short FAR* Cmp)
{
// TODO: Add your control notification handler code here
}
BOOL CFlexGridView::PreTranslateMessage(MSG* pMsg)
{
if (pMsg->message == WM_KEYDOWN && (pMsg->hwnd == hGrid ) ) {
switch (pMsg->wParam ) {
case VK_UP :
m_grid.GoUp ();
return TRUE;
case VK_DOWN:
m_grid.GoDown();
return TRUE;
case VK_LEFT :
m_grid.GoLeft();
return TRUE;
case VK_RIGHT:
m_grid.GoRight();
return TRUE;
}
}
return CFormView::PreTranslateMessage(pMsg);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -