// P4ListBox.cpp : implementation file // #include "stdafx.h" #include "P4win.h" // CP4ListBox IMPLEMENT_DYNAMIC(CP4ListBox, CListBox) CP4ListBox::CP4ListBox() { width_ = 0; m_RightClkCallback = NULL; } CP4ListBox::~CP4ListBox() { } BEGIN_MESSAGE_MAP(CP4ListBox, CListBox) ON_WM_RBUTTONUP( ) END_MESSAGE_MAP() ////////////////////////////////////////////////////////////////////// // Public methods ////////////////////////////////////////////////////////////////////// int CP4ListBox::AddString(LPCTSTR s) { int result = CListBox::AddString(s); if (result < 0) { return result; } update_width(s); return result; } int CP4ListBox::InsertString(int i, LPCTSTR s) { int result = CListBox::InsertString(i, s); if (result < 0) { return result; } update_width(s); return result; } void CP4ListBox::ResetContent() { CListBox::ResetContent(); width_ = 0; } int CP4ListBox::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++) { CString s; CListBox::GetText(i, s); CSize sz = dc.GetTextExtent(s); sz.cx += 3*::GetSystemMetrics(SM_CXBORDER) + 20; if (sz.cx > width_) { width_ = sz.cx; } } CListBox::SetHorizontalExtent(width_); return result; } int CP4ListBox::get_width() const { return width_; } ////////////////////////////////////////////////////////////////////// // Private methods ////////////////////////////////////////////////////////////////////// void CP4ListBox::update_width(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) + 20; if (sz.cx > width_) { width_ = sz.cx; CListBox::SetHorizontalExtent(width_); } } void CP4ListBox::OnRButtonUp( UINT flags, CPoint pt ) { if (m_RightClkCallback) (m_RightClkCallback)(flags, pt); }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 11099 | brkarpala | Integrate p4win from //guest/perforce_software/p4win/...@8562 | ||
//guest/perforce_software/p4win/gui/P4ListBox.cpp | |||||
#1 | 8562 | Matt Attaway |
These feet never stop running. Initial commit of the P4Win source code. To the best of our knowledge this compiles and runs using the 2013.3 P4 API and VS 2010. Expect a few changes as we refine the build process. Please post any build issues to the forums. |