Beispiel #1
0
        // will ensure that the toolTip window was created
        public void CreateToolTipHandle()
        {
            if (tipWindow == null || tipWindow.Handle == IntPtr.Zero)
            {
                var icc = new ComCtl32.INITCOMMONCONTROLSEX
                {
                    dwICC = ComCtl32.ICC.TAB_CLASSES
                };
                ComCtl32.InitCommonControlsEx(ref icc);

                var cparams = new CreateParams
                {
                    Parent    = dataGrid.Handle,
                    ClassName = NativeMethods.TOOLTIPS_CLASS,
                    Style     = NativeMethods.TTS_ALWAYSTIP
                };
                tipWindow = new NativeWindow();
                tipWindow.CreateHandle(cparams);

                User32.SendMessageW(tipWindow, User32.WindowMessage.TTM_SETMAXTIPWIDTH, IntPtr.Zero, (IntPtr)SystemInformation.MaxWindowTrackSize.Width);
                User32.SetWindowPos(
                    new HandleRef(tipWindow, tipWindow.Handle),
                    User32.HWND_NOTOPMOST,
                    flags: User32.SWP.NOSIZE | User32.SWP.NOMOVE | User32.SWP.NOACTIVATE);
                User32.SendMessageW(tipWindow, User32.WindowMessage.TTM_SETDELAYTIME, (IntPtr)ComCtl32.TTDT.INITIAL, (IntPtr)0);
            }
        }
Beispiel #2
0
            bool EnsureCreated()
            {
                if (Handle == IntPtr.Zero)
                {
                    if (!_parent.IsHandleCreated)
                    {
                        return(false);
                    }

                    CreateParams cparams = new CreateParams
                    {
                        Caption    = string.Empty,
                        Style      = (int)(User32.WS.VISIBLE | User32.WS.CHILD),
                        ClassStyle = (int)User32.CS.DBLCLKS,
                        X          = 0,
                        Y          = 0,
                        Width      = 0,
                        Height     = 0,
                        Parent     = _parent.Handle
                    };

                    CreateHandle(cparams);

                    var icc = new ComCtl32.INITCOMMONCONTROLSEX
                    {
                        dwICC = ComCtl32.ICC.TAB_CLASSES
                    };
                    ComCtl32.InitCommonControlsEx(ref icc);

                    cparams = new CreateParams
                    {
                        Parent    = Handle,
                        ClassName = ComCtl32.WindowClasses.TOOLTIPS_CLASS,
                        Style     = (int)ComCtl32.TTS.ALWAYSTIP
                    };
                    _tipWindow = new NativeWindow();
                    _tipWindow.CreateHandle(cparams);

                    User32.SendMessageW(_tipWindow, (User32.WM)ComCtl32.TTM.SETMAXTIPWIDTH, 0, SystemInformation.MaxWindowTrackSize.Width);
                    User32.SetWindowPos(
                        new HandleRef(_tipWindow, _tipWindow.Handle),
                        User32.HWND_TOP,
                        flags: User32.SWP.NOSIZE | User32.SWP.NOMOVE | User32.SWP.NOACTIVATE);
                    User32.SendMessageW(_tipWindow, (User32.WM)ComCtl32.TTM.SETDELAYTIME, (nint)ComCtl32.TTDT.INITIAL, 0);
                }

                return(true);
            }
Beispiel #3
0
        protected override void OnHandleCreated(EventArgs e)
        {
            base.OnHandleCreated(e);

            System.Windows.Forms.ImageList il = new System.Windows.Forms.ImageList();
            il.ImageSize = new System.Drawing.Size(48, 48);
            System.Windows.Forms.ImageList ils = new System.Windows.Forms.ImageList();
            ils.ImageSize = new System.Drawing.Size(16, 16);
            this.IconSize = 48;
            ComCtl32.INITCOMMONCONTROLSEX icc = new ComCtl32.INITCOMMONCONTROLSEX();
            icc.dwSize = Marshal.SizeOf(typeof(ComCtl32.INITCOMMONCONTROLSEX));
            icc.dwICC  = 1;
            var res = ComCtl32.InitCommonControlsEx(ref icc);

            this.LVHandle = User32.CreateWindowEx(0, "SysListView32", "", User32.WindowStyles.WS_CHILD | User32.WindowStyles.WS_CLIPCHILDREN | User32.WindowStyles.WS_CLIPSIBLINGS | (User32.WindowStyles)User32.LVS_EDITLABELS | (User32.WindowStyles)User32.LVS_OWNERDATA, 0, 0, this.ClientRectangle.Width, this.ClientRectangle.Height, this.Handle, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
            User32.ShowWindow(this.LVHandle, User32.ShowWindowCommands.Show);

            LVCOLUMN column = new LVCOLUMN();

            column.mask     = LVCF.LVCF_FMT | LVCF.LVCF_TEXT | LVCF.LVCF_WIDTH | LVCF.LVCF_SUBITEM;
            column.cx       = 100;
            column.iSubItem = 0;
            column.pszText  = "Name";
            column.fmt      = LVCFMT.LEFT;
            User32.SendMessage(this.LVHandle, MSG.LVM_INSERTCOLUMN, 0, ref column);

            LVCOLUMN column2 = new LVCOLUMN();

            column2.mask     = LVCF.LVCF_FMT | LVCF.LVCF_TEXT | LVCF.LVCF_WIDTH | LVCF.LVCF_SUBITEM;
            column2.cx       = 100;
            column2.iSubItem = 1;
            column2.pszText  = "Type";
            column2.fmt      = LVCFMT.LEFT;
            User32.SendMessage(this.LVHandle, MSG.LVM_INSERTCOLUMN, 1, ref column2);

            LVCOLUMN column3 = new LVCOLUMN();

            column3.mask     = LVCF.LVCF_FMT | LVCF.LVCF_TEXT | LVCF.LVCF_WIDTH | LVCF.LVCF_SUBITEM;
            column3.cx       = 100;
            column3.iSubItem = 2;
            column3.pszText  = "Size";
            column3.fmt      = LVCFMT.LEFT;
            User32.SendMessage(this.LVHandle, MSG.LVM_INSERTCOLUMN, 2, ref column3);

            LVCOLUMN column4 = new LVCOLUMN();

            column4.mask     = LVCF.LVCF_FMT | LVCF.LVCF_TEXT | LVCF.LVCF_WIDTH | LVCF.LVCF_SUBITEM;
            column4.cx       = 100;
            column4.iSubItem = 3;
            column4.pszText  = "Date Modified";
            column4.fmt      = LVCFMT.LEFT;
            User32.SendMessage(this.LVHandle, MSG.LVM_INSERTCOLUMN, 3, ref column4);

            User32.SendMessage(this.LVHandle, MSG.LVM_SETIMAGELIST, 0, il.Handle);
            User32.SendMessage(this.LVHandle, MSG.LVM_SETIMAGELIST, 1, ils.Handle);
            UxTheme.SetWindowTheme(this.LVHandle, "Explorer", 0);

            Navigate((ShellItem)KnownFolders.Desktop);

            User32.SendMessage(this.LVHandle, MSG.LVM_SetExtendedStyle, (int)ListViewExtendedStyles.HeaderInAllViews, (int)ListViewExtendedStyles.HeaderInAllViews);
            //WinAPI.SendMessage(handle, WinAPI.LVM.LVM_SetExtendedStyle, (int)WinAPI.ListViewExtendedStyles.LVS_EX_AUTOAUTOARRANGE, (int)WinAPI.ListViewExtendedStyles.LVS_EX_AUTOAUTOARRANGE);
            User32.SendMessage(this.LVHandle, MSG.LVM_SetExtendedStyle, (int)ListViewExtendedStyles.LVS_EX_DOUBLEBUFFER, (int)ListViewExtendedStyles.LVS_EX_DOUBLEBUFFER);
        }
Beispiel #4
0
    protected override void OnHandleCreated(EventArgs e) {
      base.OnHandleCreated(e);

      Notifications.RegisterChangeNotify(this.Handle, ShellNotifications.CSIDL.CSIDL_DESKTOP, true);
      this._UnvalidateTimer.Interval = 350;
      this._UnvalidateTimer.Tick += _UnvalidateTimer_Tick;
      this._UnvalidateTimer.Stop();

      this._MaintenanceTimer.Interval = 1000 * 15;
      this._MaintenanceTimer.Tick += _MaintenanceTimer_Tick;
      this._MaintenanceTimer.Start();

      this._SearchTimer.Interval = 750;
      this._SearchTimer.Enabled = false;
      this._SearchTimer.Tick += (sender, args) => {
        if (this.Items.Count > 0) {
          this._Smre.Reset();
          this.Items = this.Items.OrderBy(o => o.DisplayName).ToList();
          for (Int32 j = 0; j < this.Items.Count; j++) {
            this.Items[j].ItemIndex = j;
          }
          this._IIListView.SetItemCount(this.Items.Count, 0x2);
          this._Smre.Set();
        }
      };
      this._SearchTimer.Stop();

      this._NavWaitTimer.Tick += (sender, args) => {
        this.BeginInvoke((Action)(() => {
          this._IsDisplayEmptyText = true;
          this._IIListView.ResetEmptyText();
        }));
      };
      this._NavWaitTimer.Stop();

      var icc = new ComCtl32.INITCOMMONCONTROLSEX() { dwSize = Marshal.SizeOf(typeof(ComCtl32.INITCOMMONCONTROLSEX)), dwICC = 1 };
      var res = ComCtl32.InitCommonControlsEx(ref icc);

      this.LVHandle = User32.CreateWindowEx(0, "SysListView32", "", User32.WindowStyles.WS_CHILD | User32.WindowStyles.WS_CLIPCHILDREN | User32.WindowStyles.WS_CLIPSIBLINGS |
                                                                      (User32.WindowStyles)User32.LVS_EDITLABELS | (User32.WindowStyles)User32.LVS_OWNERDATA | (User32.WindowStyles)User32.LVS_SHOWSELALWAYS | (User32.WindowStyles)User32.LVS_AUTOARRANGE,
                                                                       0, 0, this.ClientRectangle.Width, this.ClientRectangle.Height, this.Handle, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);

      User32.ShowWindow(this.LVHandle, User32.ShowWindowCommands.Show);

      this.AddDefaultColumns(true);

      IntPtr headerhandle = User32.SendMessage(this.LVHandle, MSG.LVM_GETHEADER, 0, 0);
      for (Int32 i = 0; i < this.Collumns.Count; i++) {
        this.Collumns[i].SetSplitButton(headerhandle, i);
      }


      this.IsViewSelectionAllowed = false;
      this.View = ShellViewStyle.Medium;

      User32.SendMessage(this.LVHandle, MSG.LVM_SetExtendedStyle, (Int32)ListViewExtendedStyles.HeaderInAllViews, (Int32)ListViewExtendedStyles.HeaderInAllViews);
      User32.SendMessage(this.LVHandle, MSG.LVM_SetExtendedStyle, (Int32)ListViewExtendedStyles.LVS_EX_DOUBLEBUFFER, (Int32)ListViewExtendedStyles.LVS_EX_DOUBLEBUFFER);
      User32.SendMessage(this.LVHandle, MSG.LVM_SetExtendedStyle, (Int32)ListViewExtendedStyles.FullRowSelect, (Int32)ListViewExtendedStyles.FullRowSelect);
      User32.SendMessage(this.LVHandle, MSG.LVM_SetExtendedStyle, (Int32)ListViewExtendedStyles.HeaderDragDrop, (Int32)ListViewExtendedStyles.HeaderDragDrop);
      User32.SendMessage(this.LVHandle, MSG.LVM_SetExtendedStyle, (Int32)ListViewExtendedStyles.LabelTip, (Int32)ListViewExtendedStyles.LabelTip);
      User32.SendMessage(this.LVHandle, MSG.LVM_SetExtendedStyle, (Int32)ListViewExtendedStyles.InfoTip, (Int32)ListViewExtendedStyles.InfoTip);
      User32.SendMessage(this.LVHandle, MSG.LVM_SetExtendedStyle, (Int32)ListViewExtendedStyles.UnderlineHot, (Int32)ListViewExtendedStyles.UnderlineHot);
      User32.SendMessage(this.LVHandle, MSG.LVM_SetExtendedStyle, (Int32)ListViewExtendedStyles.AutosizeColumns, (Int32)ListViewExtendedStyles.AutosizeColumns);

      IntPtr iiListViewPrt = IntPtr.Zero;
      var iid = typeof(IListView).GUID;
      User32.SendMessage(this.LVHandle, 0x10BD, ref iid, out iiListViewPrt);
      this._IIListView = (IListView)Marshal.GetTypedObjectForIUnknown(iiListViewPrt, typeof(IListView));

      this._IIListView.SetSelectionFlags(1, 1);

      this.Focus();
      User32.SetForegroundWindow(this.LVHandle);
      UxTheme.SetWindowTheme(this.LVHandle, "Explorer", 0);
      ShellItem.MessageHandle = this.LVHandle;
      this.IsViewSelectionAllowed = true;
    }