如何删除选区边框上的ListViewItem

如何删除选区边框上的ListViewItem

本文介绍了如何删除选区边框上的ListViewItem的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用SetWindowTheme和SendMessage函数做一个.NET的ListView看起来像一个vista风格列表视图,但.NET控件仍然有围绕所选项目的虚线选框:

在浏览器列表视图选择的项目没有在他们周围的边框。我怎样才能删除它?

Windows资源管理器:

编辑:解决方法:

 公共静态INT MAKELONG(INT wLow,INT wHigh)
{
    INT低=(int)的LOWORD(wLow);
    短期高= LOWORD(wHigh);
    INT产品= 0x00010000在*(INT)高;
    INT MAKELONG =(int)的(低|产品);
    返回MAKELONG;
}

SendMessage消息(olv.Handle,WM_CHANGEUISTATE,Program.MAKELONG(UIS_SET,UISF_HIDEFOCUS),0);
 

解决方案

Telanors解决方案,为我工作。这里有一个稍微自足的版本。

 使用系统;
使用了System.Runtime.InteropServices;
使用System.Windows.Forms的;

公共类MyListView:ListView控件
{
    [的DllImport(user32.dll中,字符集= CharSet.Auto)
    静态外部的IntPtr SendMessage函数(IntPtr的的HWND,INT消息,INT的wParam,lParam的INT);

    私人const int的WM_CHANGEUISTATE = 0x127;
    私人const int的UIS_SET = 1;
    私人const int的UISF_HIDEFOCUS =为0x1;

    公共MyListView()
    {
        this.View = View.Details;
        this.FullRowSelect = TRUE;

        //删除围绕重点项目丑陋的虚线
        SendMessage消息(this.Handle,WM_CHANGEUISTATE,MAKELONG(UIS_SET,UISF_HIDEFOCUS),0);
    }

    私人诠释MAKELONG(INT wLow,INT wHigh)
    {
        INT低=(int)的IntLoWord(wLow);
        短期高= IntLoWord(wHigh);
        INT产品= 0x10000的*(INT)高;
        INT mkLong =(int)的(低|产品);
        返回mkLong;
    }

    私的短IntLoWord(INT字)
    {
        返回(短)(字放; short.MaxValue);
    }
}
 

I'm using SetWindowTheme and SendMessage to make a .net listview look like a vista style listview, but the .net control still has a dotted selection border around the selected item:

Selected items in the explorer listview don't have that border around them. How can I remove it?

Windows Explorer:

Edit: Solution:

public static int MAKELONG(int wLow, int wHigh)
{
    int low = (int)LOWORD(wLow);
    short high = LOWORD(wHigh);
    int product = 0x00010000 * (int)high;
    int makeLong = (int)(low | product);
    return makeLong;
}

SendMessage(olv.Handle, WM_CHANGEUISTATE, Program.MAKELONG(UIS_SET, UISF_HIDEFOCUS), 0);
解决方案

Telanors solution worked for me. Here's a slightly more self-contained version.

using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;

public class MyListView : ListView
{
    [DllImport("user32.dll", CharSet = CharSet.Auto)]
    static extern IntPtr SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);

    private const int WM_CHANGEUISTATE = 0x127;
    private const int UIS_SET = 1;
    private const int UISF_HIDEFOCUS = 0x1;

    public MyListView()
    {
        this.View = View.Details;
        this.FullRowSelect = true;

        // removes the ugly dotted line around focused item
        SendMessage(this.Handle, WM_CHANGEUISTATE, MakeLong(UIS_SET, UISF_HIDEFOCUS), 0);
    }

    private int MakeLong(int wLow, int wHigh)
    {
        int low = (int)IntLoWord(wLow);
        short high = IntLoWord(wHigh);
        int product = 0x10000 * (int)high;
        int mkLong = (int)(low | product);
        return mkLong;
    }

    private short IntLoWord(int word)
    {
        return (short)(word & short.MaxValue);
    }
}

这篇关于如何删除选区边框上的ListViewItem的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 00:20