?? combolistctrl.h
字號:
/*******************************************************************************
Author : Aravindan Premkumar
Unregistered Copyright 2003 : Aravindan Premkumar
All Rights Reserved
This piece of code does not have any registered copyright and is free to be
used as necessary. The user is free to modify as per the requirements. As a
fellow developer, all that I expect and request for is to be given the
credit for intially developing this reusable code by not removing my name as
the author.
*******************************************************************************/
#if !defined(AFX_COMBOLISTCTRL_H__9089600F_374F_4BFC_9482_DEAC0E7133E8__INCLUDED_)
#define AFX_COMBOLISTCTRL_H__9089600F_374F_4BFC_9482_DEAC0E7133E8__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
//the max listCtrl columns
#define MAX_LISTCTRL_COLUMNS 100
//The initial state of m_wHitMask
#define INITIAL_HITMASK LVHT_ONITEMLABEL //lwx
#include <afxtempl.h>
class CInPlaceCombo;
class CInPlaceEdit;
// User define message
// This message is posted to the parent
// The message can be handled to make the necessary validations, if any
#define WM_VALIDATE WM_USER + 0x7FFD
// User define message
// This message is posted to the parent
// The message should be handled to spcify the items to the added to the combo
#define WM_SET_ITEMS WM_USER + 0x7FFC
#define WM_VALIDATE_EDIT WM_USER + 9
typedef struct
{
int row;
int col;
CString strText;
}ItemInfo;
#include "ListEdit.h"
class CComboListCtrl : public CListCtrl
{
public:
CListEdit edit;
BOOL DisposeEdit();
int row,col;//
void ShowEdit();
BOOL IsExistNodeNo(CString str);
// CStringArray m_NodeNoArray;
// Implementation
typedef enum {MODE_READONLY,MODE_DIGITAL_EDIT,MODE_TEXT_EDIT,MODE_COMBO} COMBOLISTCTRL_COLUMN_MODE;
// Constructor
CComboListCtrl();
// Destructor
virtual ~CComboListCtrl();
// Sets/Resets the column which support the in place combo box
void SetComboColumns(int iColumnIndex, bool bSet = true);
// Sets/Resets the column which support the in place edit control
void SetReadOnlyColumns(int iColumnIndex, bool bSet = true);
// Sets the valid characters for the edit ctrl
void SetValidEditCtrlCharacters(CString& rstrValidCharacters);
// Sets the vertical scroll
void EnableVScroll(bool bEnable = true);
// Sets the horizontal scroll
void EnableHScroll(bool bEnable = true);
//insert column
int CComboListCtrl::InsertColumn(int nCol,LPCTSTR lpszColumnHeading,int nFormat = LVCFMT_LEFT,int nWidth = -1,int nSubItem = -1);
//Get column counts
int GetColumnCounts();
//delete all column
void DeleteAllColumn();
//set column Valid char string
void SetColumnValidEditCtrlCharacters(CString &rstrValidCharacters,int column = -1);
public:
// Map's SubItems to related tooltip text
CMapStringToString m_ToolTipMap;
// A bit mask of LVHT_* flags the control will show tooltips for
WORD m_wHitMask;
//** CWnd Overrides **
//Provide our own logic for HitTests, specifically, make ToolHitTests respond per SubItem
virtual int OnToolHitTest(CPoint point, TOOLINFO * pTI) const;
//** CTreeCtrl Overrides **
//Overriding the Delete functions makes sure m_ToolTipMap doesn't have excess mappings
virtual BOOL DeleteAllItems( );
virtual BOOL DeleteItem( int nItem );
//** Additional Functions **
//Set the TVHT_* flags that will trigger the display of a tooltip
WORD SetToolTipHitMask(WORD wHitMask);
//Clear all tooltips
virtual void DeleteAllToolTips();
//Set the tooltip text for a specific SubItem
virtual BOOL SetItemToolTipText( int nItem, int nSubItem, LPCTSTR lpszToolTipText );
//Retrieves the tooltip text for a specific SubItem
virtual CString GetItemToolTipText( int nItem, int nSubItem );
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CComboListCtrl)
protected:
virtual void PreSubclassWindow();
//}}AFX_VIRTUAL
protected:
// Methods
// Generated message map functions
//{{AFX_MSG(CComboListCtrl)
afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnEndLabelEdit(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnBeginLabelEdit(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
//}}AFX_MSG
virtual afx_msg BOOL OnToolTipText( UINT id, NMHDR * pNMHDR, LRESULT * pResult ); //lwx
DECLARE_MESSAGE_MAP()
private:
// Implementation
// Returns the row & column index of the column on which mouse click event has occured
bool HitTestEx(CPoint& rHitPoint, int* pRowIndex, int* pColumnIndex) const;
// Creates and displays the in place combo box
CInPlaceCombo* ShowInPlaceList(int iRowIndex, int iColumnIndex, CStringList& rComboItemsList,
CString strCurSelecetion = "", int iSel = -1);
// Creates and displays the in place edit control
CInPlaceEdit* ShowInPlaceEdit(int iRowIndex, int iColumnIndex, CString& rstrCurSelection);
// Calculates the cell rect
void CalculateCellRect(int iColumnIndex, int iRowIndex, CRect& robCellRect);
// Checks whether column supports in place combo box
bool IsCombo(int iColumnIndex);
// Checks whether column is read only
bool IsReadOnly(int iColumnIndex);
// Scrolls the list ctrl to bring the in place ctrl to the view
void ScrollToView(int iColumnIndex, /*int iOffSet, */CRect& obCellRect);
// Attributes
// List of columns that support the in place combo box
CList<int, int> m_ComboSupportColumnsList;
// List of columns that are read only
CList<int, int> m_ReadOnlyColumnsList;
// Valid characters
CString m_strValidEditCtrlChars;
// The window style of the in place edit ctrl
DWORD m_dwEditCtrlStyle;
// The window style of the in place combo ctrl
DWORD m_dwDropDownCtrlStyle;
//columnCounts
int m_iColumnCounts;
//column types
COMBOLISTCTRL_COLUMN_MODE m_modeColumn[MAX_LISTCTRL_COLUMNS];
//column
CString m_strValidChars[MAX_LISTCTRL_COLUMNS];
//int m_
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_COMBOLISTCTRL_H__9089600F_374F_4BFC_9482_DEAC0E7133E8__INCLUDED_)
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -