如何在MFC中禁用CListCtrl的水平ScrollBar? [英] How to disable the horizontal ScrollBar of a CListCtrl in MFC?

查看:181
本文介绍了如何在MFC中禁用CListCtrl的水平ScrollBar?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在MFC项目中有一个CListCtrl控件,我不希望随时显示水平ScrollBar.但是垂直显示需要正常显示.我使用VS2010,有什么解决方案吗?

I have a CListCtrl control in my MFC project, I don't want the horizontal ScrollBar to be shown at any time. But the vertical one needs to be shown normally. I used VS2010, any solutions?

推荐答案

您可以通过派生List控件并执行以下操作来做到这一点:

You can do that by deriving your List control and having something like this:

void CListCtrlEx::OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp) 
{
    ModifyStyle( WS_HSCROLL, 0 );

    CListCtrl::OnNcCalcSize(bCalcValidRects, lpncsp);
}

或者,如果您不想派生List控件,则可以执行以下操作:

Or if you don't want to derive your List control, you can do this:

if ( Style & WS_HSCROLL )
{
    Style &= ~WS_HSCROLL;
    ::SetWindowLong(m_list.GetSafeHwnd(),GWL_STYLE,Style);
}

这篇关于如何在MFC中禁用CListCtrl的水平ScrollBar?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆