示例#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);
            }
        }
示例#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);
            }
示例#3
0
        internal override bool Create(IntPtr parentHandle)
        {
            //if(this.ControlId == 0)
            //{
            //    LastControlId +=1;
            //    this.ControlId = LastControlId;
            //}
            if (this.CommonControlType != CommonControls.ICC_UNDEFINED)
            {
                InitCommonControlsEx ccInit = new InitCommonControlsEx(this.CommonControlType);
                ComCtl32.InitCommonControlsEx(ref ccInit);
            }

            this.ParentHandle = parentHandle;
            this.Handle       = User32.CreateWindowEx(0,
                                                      "static", this.Text,
                                                      this.Style, this.Left,
                                                      this.Top,
                                                      this.Width, this.Height, this.ParentHandle,
                                                      (IntPtr)this.ControlId, IntPtr.Zero, IntPtr.Zero);


            return(true);
        }
示例#4
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);
        }