BExplorer.Shell.ShellView.OnHandleCreated C# (CSharp) Method

OnHandleCreated() protected method

protected OnHandleCreated ( EventArgs e ) : void
e EventArgs
return void
    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;
    }
ShellView