📄 lgxgridformoredocview.cpp
字号:
// LgxgridForMoreDocView.cpp : implementation of the CLgxgridForMoreDocView class
//
#include "stdafx.h"
#include "LgxgridForMoreDoc.h"
#include "LgxgridForMoreDocDoc.h"
#include "LgxgridForMoreDocView.h"
#include "_lgxgrid.h"
#include "GridInto.h"
#include "SetHW.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CLgxgridForMoreDocView
IMPLEMENT_DYNCREATE(CLgxgridForMoreDocView, CView)
BEGIN_MESSAGE_MAP(CLgxgridForMoreDocView, CView)
//{{AFX_MSG_MAP(CLgxgridForMoreDocView)
ON_WM_KEYDOWN()
ON_WM_CREATE()
ON_WM_PAINT()
ON_WM_SIZE()
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, OnPrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, OnPrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, OnPrintView)
ON_COMMAND(ID_FILE_PRINT_SETUP, OnPrintSetup)
ON_COMMAND(ID_EDIT_COPY, OnCopy)//复制
ON_COMMAND(ID_EDIT_PASTE, OnPase)//粘贴
ON_COMMAND(ID_EDIT_CUT, OnCut)//剪切
ON_COMMAND(ID_UNITE, OnUnite)//合并单元格
ON_COMMAND(ID_SPLIT, OnSplit)//拆分单元格
ON_COMMAND(ID_IntoGrid, OnIntoGrid)//拆分单元格
ON_COMMAND(ID_InRow, OnInRow)
ON_COMMAND(ID_DelRow, OnDelRow)
ON_COMMAND(ID_ghw,OnHW)
ON_COMMAND( ID_DelData,OnDelData)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CLgxgridForMoreDocView construction/destruction
CLgxgridForMoreDocView::CLgxgridForMoreDocView()
{
// TODO: add construction code here
}
CLgxgridForMoreDocView::~CLgxgridForMoreDocView()
{
}
BOOL CLgxgridForMoreDocView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CLgxgridForMoreDocView drawing
void CLgxgridForMoreDocView::OnDraw(CDC* pDC)
{
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CLgxgridForMoreDocView printing
BOOL CLgxgridForMoreDocView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CLgxgridForMoreDocView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CLgxgridForMoreDocView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CLgxgridForMoreDocView diagnostics
#ifdef _DEBUG
void CLgxgridForMoreDocView::AssertValid() const
{
CView::AssertValid();
}
void CLgxgridForMoreDocView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CLgxgridForMoreDocDoc* CLgxgridForMoreDocView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CLgxgridForMoreDocDoc)));
return (CLgxgridForMoreDocDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CLgxgridForMoreDocView message handlers
void CLgxgridForMoreDocView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call default
CView::OnKeyDown(nChar, nRepCnt, nFlags);
}
int CLgxgridForMoreDocView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CView::OnCreate(lpCreateStruct) == -1)
return -1;
xi=0;
return 0;
}
BEGIN_EVENTSINK_MAP(CLgxgridForMoreDocView, CView)//声明事件
//{{AFX_EVENTSINK_MAP(CMainWnd)
ON_EVENT_RANGE(CLgxgridForMoreDocView, 1009,1018, 4 /* DataChang */, OnDataChangLgxs,VTS_I4 VTS_I4 VTS_I4 VTS_BSTR VTS_BSTR)
ON_EVENT_RANGE(CLgxgridForMoreDocView, 1009,1018, 17 /* DragDropXY */, OnDragDropXYLgxs, VTS_I4 VTS_R4 VTS_R4)
ON_EVENT_RANGE(CLgxgridForMoreDocView, 1009,1018, 16 /* DragOverXY */, OnDragOverXYLgxs, VTS_I4 VTS_R4 VTS_R4)
ON_EVENT_RANGE(CLgxgridForMoreDocView, 1009,1018, 7 /* Click */, OnClickLgxs, VTS_I4)
ON_EVENT_RANGE(CLgxgridForMoreDocView, 1009,1018, 6 /* MouseDown */, OnMouseDownLgxs, VTS_I4 VTS_I2 VTS_I2 VTS_R4 VTS_R4)
ON_EVENT_RANGE(CLgxgridForMoreDocView, 1009,1018, 18 /* LwChang */, OnLwChangLgxs, VTS_I4 VTS_I4 VTS_I4)
ON_EVENT_RANGE(CLgxgridForMoreDocView, 1009,1018, 19 /* UnChang */, OnUnChangLgxs, VTS_I4 VTS_I4 VTS_I4 VTS_I4 VTS_I4)
ON_EVENT_RANGE(CLgxgridForMoreDocView, 1009,1018, 20 /* SpChang */, OnSpChangLgxs, VTS_I4 VTS_I4 VTS_I4)
//}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()
void CLgxgridForMoreDocView::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
// Do not call CView::OnPaint() for painting messages
}
void CLgxgridForMoreDocView::OnSize(UINT nType, int cx, int cy)
{
CView::OnSize(nType, cx, cy);
CRect MRect;
for(int i=1;i<=xi;i++)
{
Lgxs[i].GetWindowRect(MRect);
ScreenToClient(&MRect);
Lgxs[i].MoveWindow(MRect,true);
Lgxs[i].ShowWindow(SW_SHOW);//显示表格
}
}
void CLgxgridForMoreDocView::OnInitialUpdate()
{
CLgxgridForMoreDocDoc* MyDoc;
MyDoc=this->GetDocument();
int i;
int Gid;
//创建表
int Ln;
int Lists,Rows,Left,Top,Height,Width;
Ln=MyDoc->Grids;
if(Ln>0)
{
for(i=1;i<=Ln;i++)
{
Lists=MyDoc->GData[i].Lists;
Rows=MyDoc->GData[i].Rows;
Left=MyDoc->GData[i].Left;
Top=MyDoc->GData[i].Top;
Height=MyDoc->GData[i].Height;
Width=MyDoc->GData[i].Width;
xi=i;
id=1008+xi;
CLgxgridForMoreDocView::GridAdd(xi,Lists,Rows,Left,Top,Height,Width);
}
}
//设置列宽
int Lws;
int Ls,Lw;
Lws=MyDoc->Lws;
if(Lws>0)
{
for(i=1;i<=Lws;i++)
{
Gid=MyDoc->Ldata[i].Gid;
Ls=MyDoc->Ldata[i].Ls;
Lw=MyDoc->Ldata[i].Lw;
Lgxs[Gid].SetListWidth(Ls,Lw);
}
}
//设置合并单元格
int Us;
int d1r,d1l,d2r,d2l;
Us=MyDoc->Us;
if(Us>0)
{
for(i=1;i<=Us;i++)
{
Gid=MyDoc->UData[i].Gid;
d1r=MyDoc->UData[i].d1r;
d1l=MyDoc->UData[i].d1l;
d2r=MyDoc->UData[i].d2r;
d2l=MyDoc->UData[i].d2l;
if(d2r>0 && d2l>0)
{
Lgxs[Gid].GridUnite(d1r,d1l,d2r,d2l,0);
}
}
}
//设置数据
int Datas;
int hid,lid;
CString Data;
Datas=MyDoc->Datas;
if(Datas>0)
{
for(i=1;i<=Datas;i++)
{
Gid=MyDoc->Data[i].Gid;
hid=MyDoc->Data[i].hid;
lid=MyDoc->Data[i].lid;
Data=MyDoc->Data[i].Data;
Lgxs[Gid].SetData(hid,lid,Data);
}
}
CView::OnInitialUpdate();
}
void CLgxgridForMoreDocView::OnInRow()//插入行
{
if(NowId>0)
{
int Hindex;
Hindex=Lgxs[NowId].GetNrow();
if(Hindex>0)
{
Lgxs[NowId].InRow(Hindex);
CLgxgridForMoreDocDoc* Mdoc=this->GetDocument();
int Datas;
Datas=Mdoc->Datas;
if(Datas>0)
{
for(int i=1;i<=Datas;i++)
{
if(Mdoc->Data[i].Gid==NowId && Mdoc->Data[i].hid>=Hindex)
{
Mdoc->Data[i].hid=Mdoc->Data[i].hid+1;
}
}
}
}
}
}
void CLgxgridForMoreDocView::OnDelRow()//删除行
{
if(NowId>0)
{
int Hindex;
Hindex=Lgxs[NowId].GetNrow();
if(Hindex>0)
{
Lgxs[NowId].DelRow(Hindex);
CLgxgridForMoreDocDoc* Mdoc=this->GetDocument();
int Datas;
Datas=Mdoc->Datas;
if(Datas>0)
{
for(int i=1;i<=Datas;i++)
{
if(Mdoc->Data[i].Gid==NowId && Mdoc->Data[i].hid==Hindex)
{
if(Mdoc->Data[Datas].hid>Hindex && Mdoc->Data[Datas].Gid==NowId)
{
Mdoc->Data[i].Gid=Mdoc->Data[Datas].Gid;
Mdoc->Data[i].hid=Mdoc->Data[Datas].hid-1;
Mdoc->Data[i].lid=Mdoc->Data[Datas].lid;
Mdoc->Data[i].Data=Mdoc->Data[Datas].Data;
Mdoc->Datas=Mdoc->Datas-1;
Datas=Datas-1;
}
else
{
Mdoc->Data[i].Gid=Mdoc->Data[Datas].Gid;
Mdoc->Data[i].hid=Mdoc->Data[Datas].hid;
Mdoc->Data[i].lid=Mdoc->Data[Datas].lid;
Mdoc->Data[i].Data=Mdoc->Data[Datas].Data;
Mdoc->Datas=Mdoc->Datas-1;
Datas=Datas-1;
}
}
else if(Mdoc->Data[i].Gid==NowId && Mdoc->Data[i].hid>Hindex)
{
Mdoc->Data[i].hid=Mdoc->Data[i].hid-1;
}
}
}
}
}
}
void CLgxgridForMoreDocView::OnPrintView() //打印预览
{
if(NowId>0)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -