📄 cellview.cpp
字号:
// TODO: Add your command update UI handler code here
}
void CCellView::OnContextMenu(CWnd* pWnd, CPoint point)
{
// TODO: Add your message handler code here
CMenu menu;
menu.LoadMenu(IDR_MENU_EDITCELL);
menu.GetSubMenu(0)->TrackPopupMenu(TPM_LEFTALIGN|TPM_RIGHTBUTTON,point.x,point.y,this);
}
void CCellView::OnChangeEdit()
{
BOOL bSet=FALSE;
CString szt;
((CMainFrame*)(AfxGetApp()->m_pMainWnd))->m_wndToolBarTextTool.GetDlgItemText(ID_EDIT_CELL,szt);
CCellDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
int nRows,nCols,nRow,nCol;
CCellObj *pFirstObj;
int nSels=pDoc->GetSelectCellNum(&nRows,&nCols,&nRow,&nCol,&pFirstObj);//获取当前选中单元的个数,行数,列数,第一个选中单元的坐标
if(nSels==0)
return;
if((m_nCurEditRow!=nRow)||(m_nCurEditCol!=nCol))
return;
if(pFirstObj->m_szDef!=szt)
{
pFirstObj->m_szDef=szt;
pDoc->UpdateAllViews(NULL);
pDoc->SetModifiedFlag();
}
}
void CCellView::OnLButtonDblClk(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CCellDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
int nRow,nCol;
if(HitTestCell(&nRow,&nCol,point))
{
CCellObj *pCell;
pCell=pDoc->GetCell(nRow,nCol);
if(pCell!=NULL)
{
((CMainFrame*)(AfxGetApp()->m_pMainWnd))->m_wndToolBarTextTool.m_EditText.SetFocus();
m_nCurEditRow=nRow;
m_nCurEditCol=nCol;
}
return;
}
// CView::OnLButtonDblClk(nFlags, point);
}
void CCellView::OnTxtLeft()
{
// TODO: Add your command handler code here
CCellDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if(pDoc->SetSelectAdjust(CELL_TXTLEFT) >0)
{
pDoc->UpdateAllViews(NULL);
pDoc->SetModifiedFlag();
}
}
void CCellView::OnTxtRight()
{
// TODO: Add your command handler code here
CCellDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if(pDoc->SetSelectAdjust(CELL_TXTRIGHT) >0)
{
pDoc->UpdateAllViews(NULL);
pDoc->SetModifiedFlag();
}
}
void CCellView::OnTxtTop()
{
// TODO: Add your command handler code here
CCellDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if(pDoc->SetSelectAdjust(CELL_TXTTOP) >0)
{
pDoc->UpdateAllViews(NULL);
pDoc->SetModifiedFlag();
}
}
void CCellView::OnTxtVmin()
{
// TODO: Add your command handler code here
CCellDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if(pDoc->SetSelectAdjust(CELL_TXTVMID) >0)
{
pDoc->UpdateAllViews(NULL);
pDoc->SetModifiedFlag();
}
}
void CCellView::OnTxtHmid()
{
// TODO: Add your command handler code here
CCellDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if(pDoc->SetSelectAdjust(CELL_TXTHMID) >0)
{
pDoc->UpdateAllViews(NULL);
pDoc->SetModifiedFlag();
}
}
void CCellView::OnTxtBottom()
{
// TODO: Add your command handler code here
CCellDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if(pDoc->SetSelectAdjust(CELL_TXTBOTTOM) >0)
{
pDoc->UpdateAllViews(NULL);
pDoc->SetModifiedFlag();
}
}
void CCellView::OnTxtAuto()
{
// TODO: Add your command handler code here
CCellDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if(pDoc->SetSelectAutoDisp())
{
pDoc->UpdateAllViews(NULL);
pDoc->SetModifiedFlag();
}
}
void CCellView::OnSelchangeComboFont()
{
// TODO: Add your control notification handler code here
CMainFrame *pwndMain;
pwndMain=(CMainFrame *)(AfxGetApp()->m_pMainWnd);
CComboBox * pCombo=(CComboBox *)(&(pwndMain->m_wndToolBarTextTool.m_ComboFont));
int nSel;
nSel=pCombo->GetCurSel();
CCellDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if(pDoc->SetSelectFont((LOGFONT *)pCombo->GetItemDataPtr(nSel)) >0)
{
pDoc->UpdateAllViews(NULL);
pDoc->SetModifiedFlag();
}
}
void CCellView::OnSelchangeComboFontsize()
{
// TODO: Add your control notification handler code here
CMainFrame *pwndMain;
pwndMain=(CMainFrame *)(AfxGetApp()->m_pMainWnd);
CComboBox * pCombo=(CComboBox *)(&(pwndMain->m_wndToolBarTextTool.m_ComboFontSize));
int nSel;
int nw;
CString szw;
nSel=pCombo->GetCurSel();
pCombo->GetLBText( nSel, szw);
nw=atoi(szw);
CCellDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if(pDoc->SetSelectFontSize(nw) >0)
{
pDoc->UpdateAllViews(NULL);
pDoc->SetModifiedFlag();
}
}
void CCellView::OnFontFat()
{
// TODO: Add your command handler code here
CCellDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if(m_bFontFat)
m_bFontFat=FALSE;
else
m_bFontFat=TRUE;
int nSels=pDoc->SetSelectFontFat(m_bFontFat);//
if(nSels>0)
{
pDoc->UpdateAllViews(NULL);
pDoc->SetModifiedFlag();
}
}
void CCellView::OnUpdateFontFat(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
if(m_bFontFat)
pCmdUI->SetCheck(1);
else
pCmdUI->SetCheck(0);
}
void CCellView::OnFontUnderline()
{
// TODO: Add your command handler code here
CCellDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if(m_bFontUnderLine)
m_bFontUnderLine=FALSE;
else
m_bFontUnderLine=TRUE;
int nSels=pDoc->SetSelectFontUnderLine(m_bFontUnderLine);//
if(nSels>0)
{
pDoc->UpdateAllViews(NULL);
pDoc->SetModifiedFlag();
}
}
void CCellView::OnUpdateFontUnderline(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
if(m_bFontUnderLine)
pCmdUI->SetCheck(1);
else
pCmdUI->SetCheck(0);
}
void CCellView::OnFontXt()
{
// TODO: Add your command handler code here
CCellDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if(m_bFontXt)
m_bFontXt=FALSE;
else
m_bFontXt=TRUE;
int nSels=pDoc->SetSelectFontXt(m_bFontXt);//
if(nSels>0)
{
pDoc->UpdateAllViews(NULL);
pDoc->SetModifiedFlag();
}
}
void CCellView::OnUpdateFontXt(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
if(m_bFontXt)
pCmdUI->SetCheck(1);
else
pCmdUI->SetCheck(0);
}
void CCellView::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo)
{
// TODO: Add your specialized code here and/or call the base class
if(pDC->IsPrinting())
{
int nx=pDC->GetDeviceCaps(LOGPIXELSX);
int ny=pDC->GetDeviceCaps(LOGPIXELSY);
pDC->SetMapMode(MM_ANISOTROPIC);
pDC->SetWindowExt(90,90);
pDC->SetViewportExt(nx,ny);
}
else
CView::OnPrepareDC(pDC, pInfo);
}
void CCellView::OnCellfrmLeft()
{
// TODO: Add your command handler code here
CCellDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if(m_bCellFrmLeft)
m_bCellFrmLeft=FALSE;
else
m_bCellFrmLeft=TRUE;
int nSels=pDoc->SetSelectFrm(CELL_FRMLEFT,m_bCellFrmLeft);//
if(nSels>0)
{
pDoc->UpdateAllViews(NULL);
pDoc->SetModifiedFlag();
}
}
void CCellView::OnUpdateCellfrmLeft(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
if(m_bCellFrmLeft)
pCmdUI->SetCheck(1);
else
pCmdUI->SetCheck(0);
}
void CCellView::OnCellfrmRight()
{
// TODO: Add your command handler code here
CCellDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if(m_bCellFrmRight)
m_bCellFrmRight=FALSE;
else
m_bCellFrmRight=TRUE;
int nSels=pDoc->SetSelectFrm(CELL_FRMRIGHT,m_bCellFrmRight);//
if(nSels>0)
{
pDoc->UpdateAllViews(NULL);
pDoc->SetModifiedFlag();
}
}
void CCellView::OnUpdateCellfrmRight(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
if(m_bCellFrmRight)
pCmdUI->SetCheck(1);
else
pCmdUI->SetCheck(0);
}
void CCellView::OnCellfrmTop()
{
// TODO: Add your command handler code here
CCellDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if(m_bCellFrmTop)
m_bCellFrmTop=FALSE;
else
m_bCellFrmTop=TRUE;
int nSels=pDoc->SetSelectFrm(CELL_FRMTOP,m_bCellFrmTop);//
if(nSels>0)
{
pDoc->UpdateAllViews(NULL);
pDoc->SetModifiedFlag();
}
}
void CCellView::OnUpdateCellfrmTop(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
if(m_bCellFrmTop)
pCmdUI->SetCheck(1);
else
pCmdUI->SetCheck(0);
}
void CCellView::OnCellfrmLt2rb()
{
// TODO: Add your command handler code here
CCellDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if(m_bCellFrmLT2RB)
m_bCellFrmLT2RB=FALSE;
else
m_bCellFrmLT2RB=TRUE;
int nSels=pDoc->SetSelectFrm(CELL_FRMLT2RB,m_bCellFrmLT2RB);//
if(nSels>0)
{
pDoc->UpdateAllViews(NULL);
pDoc->SetModifiedFlag();
}
}
void CCellView::OnUpdateCellfrmLt2rb(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
if(m_bCellFrmLT2RB)
pCmdUI->SetCheck(1);
else
pCmdUI->SetCheck(0);
}
void CCellView::OnCellfrmLb2rt()
{
// TODO: Add your command handler code here
CCellDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if(m_bCellFrmLB2RT)
m_bCellFrmLB2RT=FALSE;
else
m_bCellFrmLB2RT=TRUE;
int nSels=pDoc->SetSelectFrm(CELL_FRMLB2RT,m_bCellFrmLB2RT);//
if(nSels>0)
{
pDoc->UpdateAllViews(NULL);
pDoc->SetModifiedFlag();
}
}
void CCellView::OnUpdateCellfrmLb2rt(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
if(m_bCellFrmLB2RT)
pCmdUI->SetCheck(1);
else
pCmdUI->SetCheck(0);
}
void CCellView::OnCellfrmBottom()
{
// TODO: Add your command handler code here
CCellDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if(m_bCellFrmBottom)
m_bCellFrmBottom=FALSE;
else
m_bCellFrmBottom=TRUE;
int nSels=pDoc->SetSelectFrm(CELL_FRMBOTTOM,m_bCellFrmBottom);//
if(nSels>0)
{
pDoc->UpdateAllViews(NULL);
pDoc->SetModifiedFlag();
}
}
void CCellView::OnUpdateCellfrmBottom(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
if(m_bCellFrmBottom)
pCmdUI->SetCheck(1);
else
pCmdUI->SetCheck(0);
}
void CCellView::OnCellfrmNone()
{
// TODO: Add your command handler code here
CCellDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
int nSels=pDoc->SetSelectFrmNone();//
if(nSels>0)
{
pDoc->UpdateAllViews(NULL);
pDoc->SetModifiedFlag();
}
}
void CCellView::OnUpdateCellfrmNone(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
}
void CCellView::OnTxtColor()
{
// TODO: Add your command handler code here
CCellDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
int nRows,nCols,nRow,nCol;
CCellObj *pFirstObj;
int nSels=pDoc->GetSelectCellNum(&nRows,&nCols,&nRow,&nCol,&pFirstObj);//获取当前选中单元的个数,行数,列数,第一个选中单元的坐标
if(nSels==0)
return;
if(pFirstObj==NULL)
return;
COLORREF clr=pFirstObj->m_clrTxt;
CDlgMyColor dlg(clr);
dlg.m_szTitle="设置单元格文本颜色";
if(dlg.DoModal()==IDOK)
{
clr=dlg.GetColor();
if(clr == pFirstObj->m_clrTxt)
{
return;
}
if(pDoc->SetSelectClolor(clr) >0)
{
pDoc->UpdateAllViews(NULL);
pDoc->SetModifiedFlag();
}
}
}
void CCellView::OnTxtBkcolor()
{
// TODO: Add your command handler code here
CCellDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
int nRows,nCols,nRow,nCol;
CCellObj *pFirstObj;
int nSels=pDoc->GetSelectCellNum(&nRows,&nCols,&nRow,&nCol,&pFirstObj);//获取当前选中单元的个数,行数,列数,第一个选中单元的坐标
if(nSels==0)
return;
if(pFirstObj==NULL)
return;
COLORREF clr=pFirstObj->m_clrBk;
CDlgMyColor dlg(clr);
dlg.m_szTitle="设置单元格文本颜色";
if(dlg.DoModal()==IDOK)
{
clr=dlg.GetColor();
if(clr == pFirstObj->m_clrBk)
{
return;
}
if(pDoc->SetSelectClolor(clr,TRUE) >0)
{
pDoc->UpdateAllViews(NULL);
pDoc->SetModifiedFlag();
}
}
}
void CCellView::OnEditCal()
{
// TODO: Add your command handler code here
CCellDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
int nCalNum=pDoc->ReCalAll();
}
void CCellView::OnCellDotnum0()
{
// TODO: Add your command handler code here
CCellDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if(pDoc->SetSelectDot(0) >0)
{
pDoc->UpdateAllViews(NULL);
pDoc->SetModifiedFlag();
}
}
void CCellView::OnCellDotnum1()
{
// TODO: Add your command handler code here
CCellDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if(pDoc->SetSelectDot(1) >0)
{
pDoc->UpdateAllViews(NULL);
pDoc->SetModifiedFlag();
}
}
void CCellView::OnCellDotnum2()
{
// TODO: Add your command handler code here
CCellDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if(pDoc->SetSelectDot(2) >0)
{
pDoc->UpdateAllViews(NULL);
pDoc->SetModifiedFlag();
}
}
void CCellView::OnCellDotnum3()
{
// TODO: Add your command handler code here
CCellDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if(pDoc->SetSelectDot(3) >0)
{
pDoc->UpdateAllViews(NULL);
pDoc->SetModifiedFlag();
}
}
void CCellView::OnCellDotnum4()
{
// TODO: Add your command handler code here
CCellDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if(pDoc->SetSelectDot(4) >0)
{
pDoc->UpdateAllViews(NULL);
pDoc->SetModifiedFlag();
}
}
void CCellView::OnCellDotnum5()
{
// TODO: Add your command handler code here
CCellDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if(pDoc->SetSelectDot(5) >0)
{
pDoc->UpdateAllViews(NULL);
pDoc->SetModifiedFlag();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -