Click here to Skip to main content
16,006,065 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: CListView; getting rid of spurious horizontal scrollbar Pin
Mark Salsbery27-Jan-07 11:49
Mark Salsbery27-Jan-07 11:49 
GeneralRe: CListView; getting rid of spurious horizontal scrollbar Pin
Joe Woodbury27-Jan-07 12:32
professionalJoe Woodbury27-Jan-07 12:32 
GeneralRe: CListView; getting rid of spurious horizontal scrollbar Pin
Joe Woodbury27-Jan-07 13:01
professionalJoe Woodbury27-Jan-07 13:01 
GeneralRe: CListView; getting rid of spurious horizontal scrollbar Pin
Mark Salsbery27-Jan-07 15:35
Mark Salsbery27-Jan-07 15:35 
GeneralRe: CListView; getting rid of spurious horizontal scrollbar Pin
Joe Woodbury27-Jan-07 17:41
professionalJoe Woodbury27-Jan-07 17:41 
GeneralRe: CListView; getting rid of spurious horizontal scrollbar Pin
Mark Salsbery28-Jan-07 6:54
Mark Salsbery28-Jan-07 6:54 
GeneralRe: CListView; getting rid of spurious horizontal scrollbar Pin
Joe Woodbury28-Jan-07 12:02
professionalJoe Woodbury28-Jan-07 12:02 
GeneralRe: CListView; getting rid of spurious horizontal scrollbar [modified] Pin
Mark Salsbery28-Jan-07 13:20
Mark Salsbery28-Jan-07 13:20 
OK, with the following code I never see any horizontal scrollbar (Windows XP Pro, SP2).

This is a simple dialog with only a listview control - nothing else. Border is resizing.
I used a dialog because it was quick to toss together in VC++.
#include "stdafx.h"
#include "MFCTester.h"
#include "TestListViewDialog.h"
#include ".\testlistviewdialog.h"
 
 
// CTestListViewDialog dialog
 
IMPLEMENT_DYNAMIC(CTestListViewDialog, CDialog)
CTestListViewDialog::CTestListViewDialog(CWnd* pParent /*=NULL*/)
   : CDialog(CTestListViewDialog::IDD, pParent)
{
}
 
CTestListViewDialog::~CTestListViewDialog()
{
}
 
void CTestListViewDialog::DoDataExchange(CDataExchange* pDX)
{
   CDialog::DoDataExchange(pDX);
   DDX_Control(pDX, IDC_LIST1, m_ListCtrl);
}
 
 
BEGIN_MESSAGE_MAP(CTestListViewDialog, CDialog)
   ON_WM_SIZING()
   ON_WM_SIZE()
   ON_WM_ERASEBKGND()
END_MESSAGE_MAP()
 
 
// CTestListViewDialog message handlers
 
BOOL CTestListViewDialog::OnInitDialog()
{
   CDialog::OnInitDialog();
 
   UpdateData(FALSE);
 
   m_ListCtrl.InsertColumn(0, _T("Column 1"));
   m_ListCtrl.InsertColumn(1, _T("Column 2"));
 
   m_ListCtrl.SetExtendedStyle(m_ListCtrl.GetExtendedStyle() | LVS_EX_GRIDLINES);
 
   FitListViewToDialog();
 
   return TRUE;
}
 
void CTestListViewDialog::OnSizing(UINT fwSide, LPRECT pRect)
{
   CDialog::OnSizing(fwSide, pRect);
 
   if (pRect->right - pRect->left < 320)
      pRect->right = pRect->left + 320;
 
   if (pRect->bottom - pRect->top < 240)
      pRect->bottom = pRect->top + 240;
 
}
 
void CTestListViewDialog::OnSize(UINT nType, int cx, int cy)
{
   CDialog::OnSize(nType, cx, cy);
 
   if (cx > 0 && cy > 0)
   {
      FitListViewToDialog();
   }
}
 
void CTestListViewDialog::FitListViewToDialog()
{
   if (::IsWindow(m_ListCtrl))
   {
      CRect ClientRect;
      GetClientRect(&ClientRect);
 
      m_ListCtrl.MoveWindow(0, 0, ClientRect.Width(), ClientRect.Height(), TRUE);
 
      m_ListCtrl.SetColumnWidth(0, ClientRect.Width() / 2);
      m_ListCtrl.SetColumnWidth(1, LVSCW_AUTOSIZE_USEHEADER);
   }
}
 
BOOL CTestListViewDialog::OnEraseBkgnd(CDC* pDC)
{
   //return CDialog::OnEraseBkgnd(pDC);
   return TRUE;
}




-- modified at 19:29 Sunday 28th January, 2007

Added OnEraseBkgnd()
Added gridlines to check for flicker






-- modified at 19:38 Sunday 28th January, 2007
GeneralRe: CListView; getting rid of spurious horizontal scrollbar Pin
Mark Salsbery28-Jan-07 13:33
Mark Salsbery28-Jan-07 13:33 
GeneralRe: CListView; getting rid of spurious horizontal scrollbar Pin
Joe Woodbury28-Jan-07 16:44
professionalJoe Woodbury28-Jan-07 16:44 
QuestionRe: CListView; getting rid of spurious horizontal scrollbar Pin
Mark Salsbery29-Jan-07 6:28
Mark Salsbery29-Jan-07 6:28 
AnswerRe: CListView; getting rid of spurious horizontal scrollbar Pin
Joe Woodbury29-Jan-07 6:33
professionalJoe Woodbury29-Jan-07 6:33 
GeneralRe: CListView; getting rid of spurious horizontal scrollbar Pin
Mark Salsbery29-Jan-07 6:58
Mark Salsbery29-Jan-07 6:58 
GeneralRe: CListView; getting rid of spurious horizontal scrollbar Pin
Joe Woodbury29-Jan-07 7:04
professionalJoe Woodbury29-Jan-07 7:04 
GeneralRe: CListView; getting rid of spurious horizontal scrollbar Pin
Mark Salsbery29-Jan-07 7:50
Mark Salsbery29-Jan-07 7:50 
GeneralRe: CListView; getting rid of spurious horizontal scrollbar Pin
Joe Woodbury29-Jan-07 8:13
professionalJoe Woodbury29-Jan-07 8:13 
GeneralRe: CListView; getting rid of spurious horizontal scrollbar Pin
Mark Salsbery29-Jan-07 8:34
Mark Salsbery29-Jan-07 8:34 
QuestionNeed to send info??? Pin
Larsson26-Jan-07 12:26
Larsson26-Jan-07 12:26 
AnswerRe: Need to send info??? Pin
Ravi Bhavnani26-Jan-07 13:04
professionalRavi Bhavnani26-Jan-07 13:04 
GeneralRe: Need to send info??? Pin
Larsson26-Jan-07 13:17
Larsson26-Jan-07 13:17 
GeneralRe: Need to send info??? Pin
Ravi Bhavnani26-Jan-07 13:24
professionalRavi Bhavnani26-Jan-07 13:24 
GeneralRe: Need to send info??? Pin
Larsson26-Jan-07 13:18
Larsson26-Jan-07 13:18 
GeneralRe: Need to send info??? Pin
Ravi Bhavnani26-Jan-07 13:28
professionalRavi Bhavnani26-Jan-07 13:28 
Questionwin32 api Pin
asp.netProgrammer26-Jan-07 10:01
asp.netProgrammer26-Jan-07 10:01 
AnswerRe: win32 api Pin
Chris Losinger26-Jan-07 10:11
professionalChris Losinger26-Jan-07 10:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.