#ifndef _CELLCTRL_H_
|
#define _CELLCTRL_H_
|
#define _CELLCTRL_LIB_H_
|
#if _MSC_VER > 1000
|
#pragma once
|
#endif // _MSC_VER > 1000
|
// CellCtrl.h : header file
|
//
|
#include "HeadCtrl.h"
|
|
#ifndef __AFXTEMPL_H
|
#include <afxtempl.h>
|
#endif
|
|
/////////////////////////////////////////////////////////////////////////////
|
// CCellCtrl window
|
#define CCMSG_USE_EDIT WM_USER+1
|
#define CCMSG_MOVE_EDIT WM_USER+2
|
#define CCMSG_RECT_CHANGE WM_USER+3
|
//#define CCMSG_SEL_PRINT WM_USER+4
|
#define CCMSG_LIST_PRINT WM_USER+5
|
#define CCMSG_FONT_CHANGE WM_USER+6
|
#define CCMSG_SAVE_FILE WM_USER+7
|
#define CCMSG_OPEN_EXCEL WM_USER+8
|
#define CCMSG_OPEN_LIST WM_USER+9
|
#define CCMSG_MODIFY_EDIT WM_USER+10
|
#define CCMSG_COPY_CLIPBOARD WM_USER+11
|
#define CCMSG_PASTE_CLIPBOARD WM_USER+12
|
#define CCMSG_CUT_CLIPBOARD WM_USER+13
|
#define CCMSG_SELITEM_DELETE WM_USER+14
|
#define CCMSG_BACK_COLOR WM_USER+15
|
#define CCMSG_TEXT_COLOR WM_USER+16
|
#define CCMSG_LIST WM_USER-1
|
|
const COLORREF clrTEXT=0x00000000;
|
const COLORREF clrBACK=0x00FFFFFF;
|
|
class AFX_EXT_CLASS CCellCtrl : public CListCtrl
|
{
|
public:
|
struct LOCATION
|
{
|
int nItem;
|
int nSubItem;
|
};
|
|
struct CELLCOLOR
|
{
|
COLORREF txtclr;
|
COLORREF bkgclr;
|
};
|
|
struct CELLINFO
|
{
|
int nId; //CONTROL ID
|
int nItem; //LIST ITEM
|
int nSubItem; //LIST SUBITEM
|
CELLCOLOR oldClr; //汲沥傈狼 祸
|
CELLCOLOR newClr; //汲沥饶狼 祸
|
LPWSTR lpstrOld; //涝仿傈 巩磊凯
|
LPWSTR lpstrNew; //涝仿茄 巩磊凯
|
};
|
|
struct CELLDATA
|
{
|
COLORREF txtclr;//臂磊祸
|
COLORREF bkgclr;//硅版祸
|
bool bUseCtl;//牧飘费 荤侩
|
bool bTurn; //馆娄馆娄
|
DWORD dwData;
|
};
|
|
class CCellData : public CELLDATA
|
{
|
public:
|
CCellData()
|
{
|
bTurn =false;
|
bUseCtl=false;//牧飘费 荤侩
|
txtclr=clrTEXT;
|
bkgclr=clrBACK;
|
dwData=0;
|
}
|
|
CCellData(COLORREF TextColor, COLORREF BackColor,
|
bool bTurning, DWORD dwUserData=0)
|
{
|
bTurn =bTurning;
|
bUseCtl=false;//牧飘费 荤侩
|
txtclr=TextColor;
|
bkgclr=BackColor;
|
dwData=dwUserData;
|
}
|
virtual ~CCellData(){;}
|
void operator=(const CELLDATA& cc)
|
{
|
(CELLDATA)*this=cc;
|
}
|
};
|
typedef CArray<CCellData, CCellData&> CCSArray;
|
virtual void SerializeAllInfo(CArchive& ar);
|
|
protected:
|
CBrush m_brush; //俊叼飘冠胶狼 硅版
|
CEdit m_edit; //俊叼飘 冠胶
|
BOOL m_bCanEdit;
|
CFont* m_pFont; //府胶飘 迄飘
|
|
protected:
|
void Printing(CDC* pDC);//府胶飘甫 橇赴飘肺 免仿茄促.
|
CRect GetLogRect(CDC* pDC, int nItem, int nSubItem);//府胶飘 伎Rect阑 厚啦俊 蝶扼 函券茄促.
|
void SetCrtToPrintRate(CDC* pDC);//拳搁苞 厘钎狼 厚啦阑 备茄促.
|
int GetCrtWidth();//拳搁(府胶飘)狼 气蔼阑 府畔茄促.
|
|
protected:
|
BOOL m_bSort;//Sort Flag
|
BOOL m_bTime;//SetTimer(,,)甫 汲沥沁绰瘤 咯何
|
BOOL m_bTurnDraw;//府胶飘 盎脚矫 伎狼 祸彬捞 函秦具窍绰瘤 咯何
|
UINT m_nClipOptin;//努赋焊靛 可记
|
CHeadCtrl m_head;//HeaderCtrl
|
LOCATION m_mcLct;//right mouse click
|
LOCATION m_edLct;//edit location
|
UINT m_nStartColEdit;
|
UINT m_nEndColEdit;
|
CMenu m_menu;//府胶飘 皋春
|
CMenu* m_pUmenu;//荤侩磊 沥狼 皋春
|
CELLINFO* m_pInfo;
|
|
//汲沥等 Item Data甫 昏力茄促.
|
void DeleteItemData(int nItem);
|
void DeleteAllItemData();
|
|
//俊叼飘冠胶狼 Data甫 荐沥沁绰瘤 咯何甫 眉农窍绊
|
//何葛扩档快肺 皋矫瘤甫 焊辰促.
|
BOOL IsModifyEdit(int nItem, int nSubItem);
|
|
//酒捞袍狼 康开捞 函沁阑 版快俊 俊叼飘冠胶狼 农扁档 函秦具 窍骨肺
|
//促澜窃荐甫 捞侩窍咯 俊叼飘冠胶甫 盎脚茄促.
|
void UpdateEdit(int nItem, int nSubItem);
|
|
//伎狼 康开阑 盎脚茄促.
|
void UpdateCell(int nItem, int nSubItem);
|
|
//伎狼 拿矾啊 函窍档废 汲沥登绢 乐绰瘤 咯何
|
bool IsTurning(int nItem, int nSubItem);
|
|
//府胶飘狼 沥纺 left,right,center 屈侥阑 备茄促.
|
int GetColumnFmt(int nSubItem);
|
|
public:
|
enum ListOption
|
{
|
//MENU OPTION
|
menuNO = 0x00000000,
|
menuEXCEL = 0x00000001,
|
menuLIST = 0x00000002,
|
menuPRINT = 0x00000004,
|
menuINPUT = 0x00000010,
|
menuSAVE = 0x00000020,
|
menuFONT = 0x00000040,
|
menuBACKCOLOR= 0x00000100,
|
menuTEXTCOLOR= 0x00000200,
|
menuCOPY = 0x00010000,
|
menuPASTE = 0x00020000,
|
menuCUT = 0x00040000,
|
menuDELETE = 0x00080000,
|
menuCOMMON = 0x000000FF,
|
menuCLIP = 0x000F0000,
|
menuALL = 0x000FFFFF,
|
menuAceept = 0x00010000,
|
|
//CLIPBOARD OPTION
|
clipNO = 0x00000000,
|
clipCOPY = 0x00000001,
|
clipPASTE = 0x00000002,
|
clipCUT = 0x00000004,
|
clipDELETE = 0x00000008,
|
clipALL = 0x0000FFFF,
|
};
|
CCellCtrl();
|
|
//Sort function
|
void EnableSort(BOOL bSort=TRUE){m_bSort=bSort;}
|
void EnableEdit(BOOL bCanEdit) { m_bCanEdit = bCanEdit; }
|
|
//menu function
|
BOOL CCellCtrl::SetMenu(CMenu* pMenu=NULL){m_pUmenu=pMenu; return TRUE;}
|
void UseMenu( UINT nOption=menuCOMMON/*default=menuCOMMON*/);
|
|
//editbox function
|
BOOL SetEditMovable( int nStartCol, int nEndCol);
|
BOOL UseEdit( int nItem, int nSubItem);
|
void EditCtrl( MSG pMsg );
|
|
//Rect捞 函沁绰瘤 魄窜茄促.
|
BOOL IsSubRectChange();
|
|
//府胶飘甫 橇赴飘肺 免仿茄促.
|
BOOL ListPrinting(BOOL bDialog, int Orientation=1/*啊肺=1, 技肺=2*/);
|
|
//keystate function
|
BOOL IsMultiKey();//shift虐, ctrl虐殿捞 喘矾脸绰瘤 check茄促
|
|
//font function
|
void SetLogFont(LOGFONT logfont);//厘钎 迄飘
|
void SetListFont(LOGFONT* logfont);//府胶飘 迄飘
|
|
//
|
int GetSubItemCount(); //拿烦荐甫 备茄促.
|
int GetLeftSubItem(); //谅螟栏肺何磐 劝己拳等 拿烦阑 茫绰促.
|
int GetRightSubItem(); //快螟栏肺何磐 劝己拳等 拿烦阑 茫绰促.
|
|
//荤侩磊啊 鞘夸茄 蔼阑 历厘窍绊 阂矾棵荐 乐绰 窃荐捞促.
|
BOOL SetCellData(int nItem, int nSubItem, DWORD dwData);
|
DWORD GetCellData(int nItem, int nSubItem);
|
|
//color function
|
BOOL SetItemTextColor(int nItem, COLORREF color);
|
BOOL SetItemTextColor(int nItem, int nSubItem, COLORREF color);
|
BOOL SetItemBkColor(int nItem, COLORREF color, bool bTurn=false);
|
BOOL SetItemBkColor(int nItem, int nSubItem, COLORREF color, bool bTurn=false);
|
BOOL GetItemColor(int nItem, int nSubItem, CELLCOLOR* pCellClr);
|
|
//Clipboard function
|
void UseClipboard( UINT nOption=clipALL/*default=clipALL*/){m_nClipOptin=nOption;}
|
void CopyClipboard();// Ctrl C (select item copy)
|
void PasteClipboard();//Ctrl V (paste)
|
void CutClipboard();//Ctrl V (paste)
|
void SelectItemDelete();
|
|
BOOL DeleteColumn( int nCol );
|
int InsertColumn(int nCol, LPCTSTR lpstTxt,int nFormat=LVCFMT_LEFT,
|
int nWidth = -1, int nSubItem = -1);
|
|
//HeaderCtrl function
|
BOOL GetSafeHead();
|
int GetHeadHeight();
|
int GetHeadItemCount();
|
void SetHeadItemCount(int nCount);
|
void SetHeadItemText(int nItem, int nSubItem, LPCTSTR lpstTxt);
|
CString GetHeadItemText(int nItem, int nSubItem);
|
void SetHeadItemMerge(int nsItem, int nsSubItem,
|
int neItem, int neSubItem);
|
|
protected:
|
|
|
// Overrides
|
// ClassWizard generated virtual function overrides
|
//{{AFX_VIRTUAL(CCellCtrl)
|
public:
|
virtual void Serialize(CArchive& ar);
|
virtual BOOL PreTranslateMessage(MSG* pMsg);
|
protected:
|
//}}AFX_VIRTUAL
|
|
// Implementation
|
public:
|
void SaveFile();
|
virtual ~CCellCtrl();
|
|
// Generated message map functions
|
protected:
|
|
//{{AFX_MSG(CCellCtrl)
|
// afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
|
afx_msg void OnRclick(NMHDR* pNMHDR, LRESULT* pResult);
|
afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
|
afx_msg void OnColumnclick(NMHDR* pNMHDR, LRESULT* pResult);
|
afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
|
afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
|
afx_msg void OnInsertitem(NMHDR* pNMHDR, LRESULT* pResult);
|
afx_msg void OnDeleteitem(NMHDR* pNMHDR, LRESULT* pResult);
|
afx_msg void OnDeleteallitems(NMHDR* pNMHDR, LRESULT* pResult);
|
afx_msg void OnTimer(UINT_PTR nIDEvent);
|
afx_msg void OnDestroy();
|
afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
|
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
|
//}}AFX_MSG
|
afx_msg void OnCustomdrawList ( NMHDR* pNMHDR, LRESULT* pResult );
|
afx_msg void OnSaveFile();
|
afx_msg void OnOpenExcel();
|
afx_msg void OnOpenList();
|
afx_msg void OnUseEdit();
|
afx_msg void OnMoveEdit();
|
afx_msg void OnRectchange();
|
afx_msg void OnListPrint();
|
afx_msg void OnFontChange();
|
afx_msg void OnBackColor();
|
afx_msg void OnTextColor();
|
|
afx_msg void OnCopyClipboard() { CopyClipboard(); }
|
afx_msg void OnPasteClipboard() { PasteClipboard(); }
|
afx_msg void OnCutClipboard() { CutClipboard(); }
|
afx_msg void OnSelItemDelete() { SelectItemDelete(); }
|
|
DECLARE_MESSAGE_MAP()
|
};
|
/////////////////////////////////////////////////////////////////////////////
|
|
//{{AFX_INSERT_LOCATION}}
|
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
|
#endif // !defined(_CELLCTRL_H_)
|