Browse Source

added files missed in last check in
[SAB]

git-svn-id: svn://svn.code.sf.net/p/ditto-cp/code/trunk@467 595ec19a-5cb4-439b-94a8-42fb3063c22c

sabrogden 16 năm trước cách đây
mục cha
commit
993cf32bad
3 tập tin đã thay đổi với 158 bổ sung0 xóa
  1. 13 0
      Addins/DittoUtil/res/DittoUtil.rc2
  2. 91 0
      HListBox.cpp
  3. 54 0
      HListBox.h

+ 13 - 0
Addins/DittoUtil/res/DittoUtil.rc2

@@ -0,0 +1,13 @@
+//
+// DittoUtil.RC2 - resources Microsoft Visual C++ does not edit directly
+//
+
+#ifdef APSTUDIO_INVOKED
+#error this file is not editable by Microsoft Visual C++
+#endif //APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+// Add manually edited resources here...
+
+/////////////////////////////////////////////////////////////////////////////

+ 91 - 0
HListBox.cpp

@@ -0,0 +1,91 @@
+#include "stdafx.h"
+#include "HListBox.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// CHListBox
+
+CHListBox::CHListBox()
+{
+ width = 0;
+}
+
+CHListBox::~CHListBox()
+{
+}
+
+
+BEGIN_MESSAGE_MAP(CHListBox, CListBox)
+	//{{AFX_MSG_MAP(CHListBox)
+		// NOTE - the ClassWizard will add and remove mapping macros here.
+	//}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// CHListBox message handlers
+void CHListBox::updateWidth(LPCTSTR s)
+    {
+     CClientDC dc(this);
+     CFont * f = CListBox::GetFont();
+     dc.SelectObject(f);
+     CSize sz = dc.GetTextExtent(s, _tcslen(s));
+     sz.cx += 3 * ::GetSystemMetrics(SM_CXBORDER);
+     if(sz.cx > width)
+	 { /* extend */
+	  width = sz.cx;
+	  CListBox::SetHorizontalExtent(width);
+	 } /* extend */
+    }
+
+int CHListBox::AddString(LPCTSTR s)
+    {
+     int result = CListBox::AddString(s);
+     if(result < 0)
+	 return result;
+     updateWidth(s);
+     return result;
+    }
+
+int CHListBox::InsertString(int i, LPCTSTR s)
+    {
+     int result = CListBox::InsertString(i, s);
+     if(result < 0)
+	 return result;
+     updateWidth(s);
+     return result;
+    }
+
+void CHListBox::ResetContent()
+    {
+     CListBox::ResetContent();
+     width = 0;
+    }
+
+int CHListBox::DeleteString(int n)
+    {
+     int result = CListBox::DeleteString(n);
+     if(result < 0)
+	 return result;
+     CClientDC dc(this);
+
+     CFont * f = CListBox::GetFont();
+     dc.SelectObject(f);
+
+     width = 0;
+     for(int i = 0; i < CListBox::GetCount(); i++)
+	 { /* scan strings */
+	  CString s;
+	  CListBox::GetText(i, s);
+	  CSize sz = dc.GetTextExtent(s);
+          sz.cx += 3 * ::GetSystemMetrics(SM_CXBORDER);
+	  if(sz.cx > width)
+	      width = sz.cx;
+	 } /* scan strings */
+     CListBox::SetHorizontalExtent(width);
+     return result;
+    }

+ 54 - 0
HListBox.h

@@ -0,0 +1,54 @@
+#if !defined(AFX_HLISTBOX_H__346C3917_14BC_11D5_A025_006067718D04__INCLUDED_)
+#define AFX_HLISTBOX_H__346C3917_14BC_11D5_A025_006067718D04__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+// HListBox.h : header file
+//
+
+/////////////////////////////////////////////////////////////////////////////
+// CHListBox window
+
+class CHListBox : public CListBox
+{
+// Construction
+public:
+	CHListBox();
+
+// Attributes
+public:
+
+// Operations
+public:
+    int AddString(LPCTSTR s);
+    int InsertString(int i, LPCTSTR s);
+    void ResetContent();
+    int DeleteString(int i);
+
+// Overrides
+	// ClassWizard generated virtual function overrides
+	//{{AFX_VIRTUAL(CHListBox)
+	//}}AFX_VIRTUAL
+
+// Implementation
+public:
+	virtual ~CHListBox();
+
+	// Generated message map functions
+protected:
+        void updateWidth(LPCTSTR s);
+	int width;
+	//{{AFX_MSG(CHListBox)
+		// NOTE - the ClassWizard will add and remove member functions here.
+	//}}AFX_MSG
+
+	DECLARE_MESSAGE_MAP()
+};
+
+/////////////////////////////////////////////////////////////////////////////
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_HLISTBOX_H__346C3917_14BC_11D5_A025_006067718D04__INCLUDED_)