QListCtrlCtl.h
上传用户:cnjubao
上传日期:2007-01-02
资源大小:34k
文件大小:7k
- /************************************
- REVISION LOG ENTRY
- Revision By: Mihai Filimon
- Revised on 11/2/98 3:35:23 PM
- Comments: QListCtrlCtl.h : Declaration of the CQListCtrlCtrl ActiveX Control class.
- ************************************/
- #if !defined(AFX_QLISTCTRLCTL_H__BFCC1BD4_7257_11D2_86E6_0040055C08D9__INCLUDED_)
- #define AFX_QLISTCTRLCTL_H__BFCC1BD4_7257_11D2_86E6_0040055C08D9__INCLUDED_
- #if _MSC_VER >= 1000
- #pragma once
- #endif // _MSC_VER >= 1000
- /////////////////////////////////////////////////////////////////////////////
- // CQListCtrlCtrl : See QListCtrlCtl.cpp for implementation.
- #define defaultStyles LVS_REPORT | LVS_OWNERDRAWFIXED | LVS_SHOWSELALWAYS
- #define defaultItemHeight 18
- #define defaultColumnWidth 96
- #define minCountLoading 16
- #define IDSBVERT 0x1000
- #include <afxcmn.h>
- class CQListCtrlCtrl;
- typedef int (CQListCtrlCtrl::*TLoadFunction) (int nLineFrom, int nHowMany = +1);
- typedef TCHAR (*RNDSTR) (CString* pString);
- TCHAR RandomLimited(CString* pString)
- {
- return (TCHAR)pString->GetAt(((BYTE)rand()) % pString->GetLength());
- }
- TCHAR RandomUnLimited(CString* pString)
- {
- return (TCHAR)(BYTE)rand();
- }
- CString RandomString(int nLength = 16, CString sWhat = _T("0123456789"))
- {
- RNDSTR f = sWhat.IsEmpty() ? RandomUnLimited : RandomLimited;
- CString result;
- for (int i = 0; i < nLength; i++)
- result += f(&sWhat);
- return result;
- }
- class CQListCtrlCtrl : public COleControl
- {
- DECLARE_DYNCREATE(CQListCtrlCtrl)
- // Constructor
- public:
- CQListCtrlCtrl();
- virtual BOOL CreateControlWindow(HWND hWndParent, const CRect& rcPos, LPCRECT prcClipped = NULL);
- virtual void OnSetClientSite( );
- virtual int GetCountItem();
- virtual LPCTSTR Label(int nLine, LPARAM& lParamItem);
- void LoadRestOfLine(int nLine, int nTrueLine);
- // Overrides
- // ClassWizard generated virtual function overrides
- //{{AFX_VIRTUAL(CQListCtrlCtrl)
- public:
- virtual void OnDraw(CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid);
- virtual void DoPropExchange(CPropExchange* pPX);
- virtual void OnResetState();
- //}}AFX_VIRTUAL
- protected:
- struct QSnapLoader
- {
- CQListCtrlCtrl* m_pParent;
- struct SNodeItemsInfo
- {
- static int m_nCountRef;
- int m_nItemLine;
- int m_nCount;
- int m_nItemLB;
- SNodeItemsInfo* m_pNextNode;
- SNodeItemsInfo* m_pPrevNode;
- SNodeItemsInfo(int nItemLine, int nCount, int nItemLB)
- {
- m_nItemLine = nItemLine;
- m_nCount = nCount;
- m_nItemLB = nItemLB;
- m_pNextNode = NULL;
- m_pPrevNode = NULL;
- m_nCountRef++;
- }
- ~SNodeItemsInfo()
- {
- m_nCountRef--;
- }
- int GetLastLine()
- {
- return m_nItemLine + m_nCount;
- }
- int GetLastItem()
- {
- return m_nItemLB + m_nCount;
- }
- };
- SNodeItemsInfo* m_pFirstNode;
- public:
- virtual int GetItemLine(int nItemLB);
- virtual CString GetListNodes();
- void SetParent(CQListCtrlCtrl* pParent);
- virtual int Load(int nItemFrom, int nHowMany);
- QSnapLoader();
- virtual ~QSnapLoader();
- };
- friend struct CQListCtrlCtrl::QSnapLoader;
- public:
- QSnapLoader m_QuickLoader;
- TLoadFunction m_fctLoadFunction;
- virtual int AlreadyLoadPartialListCtrl(int nLineFrom, int nHowMany = +1);
- virtual int LoadPartial(int nLineFrom, int nHowMany = +1);
- virtual int LoadPartialListCtrl(int nLineFrom, int nHowMany = +1);
- // Implementation
- protected:
- CScrollBar m_sbVert;
- int GetVisibleCount();
- int m_nCountLoading;
- void OnItemsCountChanged();
- void Resize();
- long m_nItemsCount;
- virtual void OnInit();
- UINT FormatColumn(int iColumn);
- ~CQListCtrlCtrl();
- BEGIN_OLEFACTORY(CQListCtrlCtrl) // Class factory and guid
- virtual BOOL VerifyUserLicense();
- virtual BOOL GetLicenseKey(DWORD, BSTR FAR*);
- END_OLEFACTORY(CQListCtrlCtrl)
- DECLARE_OLETYPELIB(CQListCtrlCtrl) // GetTypeInfo
- DECLARE_PROPPAGEIDS(CQListCtrlCtrl) // Property page IDs
- DECLARE_OLECTLTYPE(CQListCtrlCtrl) // Type name and misc status
- // Subclassed control support
- BOOL PreCreateWindow(CREATESTRUCT& cs);
- BOOL IsSubclassedControl();
- LRESULT OnOcmCommand(WPARAM wParam, LPARAM lParam);
- // Message maps
- //{{AFX_MSG(CQListCtrlCtrl)
- afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
- afx_msg void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
- afx_msg void MeasureItem( LPMEASUREITEMSTRUCT lpMeasureItemStruct );
- afx_msg void OnSize(UINT nType, int cx, int cy);
- afx_msg void OnDestroy();
- afx_msg void OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp);
- afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
- afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
- afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
- //}}AFX_MSG
- DECLARE_MESSAGE_MAP()
- // Dispatch maps
- //{{AFX_DISPATCH(CQListCtrlCtrl)
- long m_nItemHeight;
- afx_msg void OnItemHeightChanged();
- BOOL m_bGridLines;
- afx_msg void OnGridLinesChanged();
- CString m_sHeader;
- afx_msg void OnHeaderChanged();
- BOOL m_bMultiSelect;
- afx_msg void OnMultiSelectChanged();
- BOOL m_bNoHeader;
- afx_msg void OnNoHeaderChanged();
- BOOL m_bSColumn;
- afx_msg void OnSColumnChanged();
- afx_msg void InitItemsCount();
- //}}AFX_DISPATCH
- DECLARE_DISPATCH_MAP()
- afx_msg void AboutBox();
- // Event maps
- //{{AFX_EVENT(CQListCtrlCtrl)
- void FireItemsCount(long FAR* nItemsCount)
- {FireEvent(eventidItemsCount,EVENT_PARAM(VTS_PI4), nItemsCount);}
- void FireAllItemsLoaded()
- {FireEvent(eventidAllItemsLoaded,EVENT_PARAM(VTS_NONE));}
- void FireLoadLabel(long nIndex, BSTR FAR* sText, long FAR* lParam)
- {FireEvent(eventidLoadLabel,EVENT_PARAM(VTS_I4 VTS_PBSTR VTS_PI4), nIndex, sText, lParam);}
- void FireLoadSubItem(long nIndex, long nSubIndex, BSTR FAR* sText)
- {FireEvent(eventidLoadSubItem,EVENT_PARAM(VTS_I4 VTS_I4 VTS_PBSTR), nIndex, nSubIndex, sText);}
- //}}AFX_EVENT
- DECLARE_EVENT_MAP()
- // Dispatch and event IDs
- public:
- virtual void Header(LPCTSTR lpszHeader);
- virtual CListCtrl* GetListCtrl();
- enum {
- //{{AFX_DISP_ID(CQListCtrlCtrl)
- dispidItemHeight = 1L,
- dispidGridLines = 2L,
- dispidHeader = 3L,
- dispidMultiSelect = 4L,
- dispidNoHeader = 5L,
- dispidSColumn = 6L,
- dispidInitItemsCount = 7L,
- eventidItemsCount = 1L,
- eventidAllItemsLoaded = 2L,
- eventidLoadLabel = 3L,
- eventidLoadSubItem = 4L,
- //}}AFX_DISP_ID
- };
- private:
- UINT ColumnFormatFromString(CString& sFormat);
- };
- //{{AFX_INSERT_LOCATION}}
- // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
- #endif // !defined(AFX_QLISTCTRLCTL_H__BFCC1BD4_7257_11D2_86E6_0040055C08D9__INCLUDED)