⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 listboxex.h

📁 用bcg库编写的java IDE 源码
💻 H
字号:
//*-
//
// MODULE NAME:   ListBoxEx.h
//
// DESCRIPTION:   CListBoxEx class declaration
//
// AUTHOR     :   Copyright (C) Stefano Passiglia, December 1999
//                passig@geocities.com
//                You can reuse and redistribute this code, provided this header is
//                kept as is.
//
//+*/

#ifndef _LISTBOXEX_H
#define _LISTBOXEX_H

#if _MSC_VER > 1000
#   pragma once
#endif // _MSC_VER > 1000


//
// Include Files
//
#include "stdafx.h"


//
// Constant definitions.
//
static const UINT NEAR BL_MESSAGE_BROWSE = RegisterWindowMessage(_T("BL_MESSAGE_BROWSE"));
/////////////////////////////////////////////////////////////////////////////
// CHeaderCtrlEx window
#define ON_BL_ITEMBROWSE(id, memberFxn)  \
        ON_CONTROL(BL_MESSAGE_BROWSE,id,memberFxn)



static const UINT NEAR LB_MSG_SETCURSEL = RegisterWindowMessage(_T("LB_MSG_SETCURSEL"));
static const UINT NEAR LB_MSG_ITEMADDED = RegisterWindowMessage(_T("LB_MSG_ITEMADDED"));
static const UINT NEAR LB_MSG_ITEMDEL   = RegisterWindowMessage(_T("LB_MSG_ITEMDEL"));

#define ON_LBN_SETCURSEL(id, memberFxn) \
        ON_CONTROL(LB_MSG_SETCURSEL,id,memberFxn)

#define ON_LBN_ITEMADDED(id, memberFxn) \
        ON_CONTROL(LB_MSG_ITEMADDED,id,memberFxn)

#define ON_LBN_ITEMDEL(id, memberFxn) \
        ON_CONTROL(LB_MSG_ITEMDEL,id,memberFxn)

// Listbox styles
#define LBEX_STYLE\
   WS_CHILD | WS_VISIBLE | WS_VSCROLL|\
   LBS_EXTENDEDSEL | LBS_NOINTEGRALHEIGHT | LBS_HASSTRINGS |\
   LBS_NOTIFY | LBS_WANTKEYBOARDINPUT | LBS_DISABLENOSCROLL |\
   LBS_OWNERDRAWFIXED

// Listbox extended styles
#define LBEX_EXSTYLE\
   WS_EX_CLIENTEDGE


// Listbox editing mode
#define LBEX_EDITBUTTON    0x4000L     // If set, shows a "..." button near the edit box

//
// Type definitions.
//
// None.


//
// Function declarations.
//
// None.

//
// Class declarations.
//

class CListBoxExBuddy;
class CInPlaceEdit;
class CInPlaceButton;

class CListBoxEx : public CDragListBox
{
   DECLARE_DYNCREATE( CListBoxEx )
   int m_nActiveIndex;
   int m_nNewlyAdded;
   int m_nNewlyDeleted;
public:
             
   // Constructor/Destructor
   CListBoxEx();
   virtual ~CListBoxEx();
   
public:
   // "Allow" methods.
   // Editing & drag are anabled by default
   void AllowEditing( BOOL bAllowEditing = TRUE )
   {
      m_bAllowEditing = bAllowEditing;
   };

   void AllowDrag( BOOL bAllowDrag = TRUE )
   {
      m_bAllowDrag = bAllowDrag;
   };

   // Editing methods
   void BeginEditing( int iItem );
   void EndEditing( BOOL fCancel );

   // Add a new empty string and begin editing
   void EditNew();

   void SetEditStyle( DWORD dwEditStyle );

   HWND GetEditHandle() const;

   void SetEditText( const CString & strNewText ) const;

   // Item methods
   int MoveItemUp( int iItem );
   int MoveItemDown( int iItem );
   void SwapItems( int iFirstItem, int iSecondItem );
   
   void SetItem( int iItem, LPCTSTR szItemText, DWORD dwItemData );
   void SetItemText( int iItem, LPCTSTR szItemText );

   void DeleteSelected();
   int SetCurSel(int nSelect);

   //intercepters
   int  AddString(LPCTSTR lpszItem,BOOL bSendMsg = TRUE);
   int  InsertString(int nIndex,LPCTSTR lpszItem,BOOL bSendMsg = TRUE);
   void ResetContent(BOOL bSendMsg = TRUE);
   int  DeleteString(UINT nIndex,BOOL bSendMsg = TRUE);
public:

   // Virtual (overridables) events
   virtual BOOL OnBeginEditing( int iItem );
   virtual BOOL OnEndEditing( int iItem, BOOL fCanceled );

   virtual void OnBrowseButton( int iItem );

public:
	int GetNewlyAdded(){return m_nNewlyAdded;}
	int GetNewlyDeleted(){return m_nNewlyDeleted;}
	int GetSelected(){return m_iSelected;}
   // Data members

   // Overrides
   // ClassWizard generated virtual function overrides
   //{{AFX_VIRTUAL(CListBoxEx)
public:
   virtual BOOL OnChildNotify(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pLResult);
protected:
   virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
   virtual void PreSubclassWindow();
   virtual void MeasureItem( LPMEASUREITEMSTRUCT lpMeasureItemStruct );
   virtual void DrawItem( LPDRAWITEMSTRUCT lpDrawItemStruct );   
   virtual void DrawInsert( int nIndex );
   //}}AFX_VIRTUAL
   
   void DrawSeparator( int nIndex );
   int GetActiveIndex(){return m_nActiveIndex;}
   // Generated message map functions
protected:
   //{{AFX_MSG(CListBoxEx)
   afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
   afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
   afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
   afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
   afx_msg void OnSysKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
   afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
	//}}AFX_MSG
   afx_msg LRESULT OnEndEditMessage(WPARAM wParam, LPARAM lParam);

   DECLARE_MESSAGE_MAP()

private:

   void CreateEdit();

protected:

   CListBoxExBuddy *m_pBuddy;

   DWORD            m_dwEditStyle;
   
   CInPlaceEdit    *m_pEdit;
   CRect            m_rcEdit;

   CInPlaceButton  *m_pBrowseButton;
   CRect            m_rcButton;

   int              m_iSelected;
   int              m_iEdited;

   BOOL             m_bAllowEditing;
   BOOL             m_bAllowDrag;
   BOOL             m_bAddedNullString;
}; // class CListBoxEx

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(_LISTBOXEX_H)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -