学习无止境!

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

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

namespace ListViewNav
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

            ShowBorder(listView1.Handle, false);
            ShowBorder(listView2.Handle, false);
            ShowBorder(listView3.Handle, false);
        }

        const int GWL_STYLE = -16;
        const int WS_BORDER = 0x00800000;
        const int SWP_NOSIZE = 0x1;
        const int SWP_NOMOVE = 0x2;
        const int SWP_FRAMECHANGED = 0x20;

        [DllImport("coredll.dll")]
        private static extern int GetWindowLong(IntPtr hWnd, int nIndex);

        [DllImport("coredll.dll")]
        private extern static void SetWindowLong(IntPtr hwnd, int nIndex, int dwNewLong);

        [DllImport("coredll.dll")]
        private static extern bool SetWindowPos(IntPtr hwnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy, int uflags);

        private void ShowBorder(IntPtr handle, bool bShow)
        {
            int style = GetWindowLong(handle, GWL_STYLE);
            if (bShow)
            {
                style |= WS_BORDER;
            }
            else
            {
                style &= ~WS_BORDER;
            }
            SetWindowLong(handle, GWL_STYLE, style);
            SetWindowPos(handle, IntPtr.Zero, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
        }

    }
}

 

 

posted on 2011-12-01 15:54  钻石眼泪  阅读(1202)  评论(0编辑  收藏  举报