Exemplo n.º 1
0
        public void RefreshBG()
        {
            if (Config.Skin.UseRebarBGColor)
            {
                // Save the default color and set the new one
                if (DefaultRebarCOLORREF == -1)
                {
                    DefaultRebarCOLORREF = (int)PInvoke.SendMessage(Handle, RB.GETBKCOLOR, IntPtr.Zero, IntPtr.Zero);
                }
                int c = QTUtility2.MakeCOLORREF(Config.Skin.RebarColor);
                PInvoke.SendMessage(Handle, RB.SETBKCOLOR, IntPtr.Zero, (IntPtr)c);
            }
            else if (DefaultRebarCOLORREF != -1)
            {
                // Restore the default BG color
                PInvoke.SendMessage(Handle, RB.SETBKCOLOR, IntPtr.Zero, (IntPtr)DefaultRebarCOLORREF);
                DefaultRebarCOLORREF = -1;
            }

            // Refresh the rebar
            IntPtr hWnd = PInvoke.GetWindowLongPtr(Handle, -8);

            if (hWnd != IntPtr.Zero)
            {
                PInvoke.RedrawWindow(hWnd, IntPtr.Zero, IntPtr.Zero, 0x289);
            }
            if (Config.Skin.UseRebarImage)
            {
                CreateRebarImage();
            }
        }
Exemplo n.º 2
0
        public void RefreshBG(bool fRebarBGCanceled)
        {
            if (fRebarBGCanceled && QTUtility.DefaultRebarCOLORREF != -1)
            {
                // Restore the default BG color
                PInvoke.SendMessage(Handle, RB.SETBKCOLOR, IntPtr.Zero, (IntPtr)QTUtility.DefaultRebarCOLORREF);
            }
            else if (QTUtility.CheckConfig(Settings.ToolbarBGColor))
            {
                // Save the default color and set the new one
                if (QTUtility.DefaultRebarCOLORREF == -1)
                {
                    QTUtility.DefaultRebarCOLORREF = (int)PInvoke.SendMessage(Handle, RB.GETBKCOLOR, IntPtr.Zero, IntPtr.Zero);
                }
                int c = QTUtility2.MakeCOLORREF(QTUtility.RebarBGColor);
                PInvoke.SendMessage(Handle, RB.SETBKCOLOR, IntPtr.Zero, (IntPtr)c);
            }
            // Refresh the rebar
            IntPtr hWnd = PInvoke.GetWindowLongPtr(Handle, -8);

            if (hWnd != IntPtr.Zero)
            {
                PInvoke.RedrawWindow(hWnd, IntPtr.Zero, IntPtr.Zero, 0x289);
            }
            if (QTUtility.CheckConfig(Settings.RebarImage))
            {
                CreateRebarImage();
            }
        }
Exemplo n.º 3
0
        public RebarController(QTTabBarClass tabbar, IntPtr hwndReBar, IOleCommandTarget bandObjectSite)
        {
            this.tabbar         = tabbar;
            this.bandObjectSite = bandObjectSite;
            ExplorerHandle      = PInvoke.GetAncestor(hwndReBar, 2);
            Handle          = hwndReBar;
            rebarController = new NativeWindowController(hwndReBar);
            rebarController.MessageCaptured += MessageCaptured;

            if (QTUtility.CheckConfig(Settings.ToolbarBGColor))
            {
                if (QTUtility.DefaultRebarCOLORREF == -1)
                {
                    QTUtility.DefaultRebarCOLORREF = (int)PInvoke.SendMessage(Handle, RB.GETBKCOLOR, IntPtr.Zero, IntPtr.Zero);
                }
                int num2 = QTUtility2.MakeCOLORREF(QTUtility.RebarBGColor);
                PInvoke.SendMessage(Handle, RB.SETBKCOLOR, IntPtr.Zero, (IntPtr)num2);
            }

            EnsureMenuBarIsCorrect();
        }
Exemplo n.º 4
0
        public RebarController(QTTabBarClass tabbar, IntPtr hwndReBar, IOleCommandTarget bandObjectSite)
        {
            BandObjectLib.Logging.Add_DEBUG("Constructor.log", "RebarController");
            this.tabbar         = tabbar;
            this.bandObjectSite = bandObjectSite;
            ExplorerHandle      = PInvoke.GetAncestor(hwndReBar, 2);
            Handle          = hwndReBar;
            rebarController = new NativeWindowController(hwndReBar);
            rebarController.MessageCaptured += RebarMessageCaptured;

            REBARBANDINFO structure = new REBARBANDINFO();

            structure.cbSize = Marshal.SizeOf(structure);
            structure.fMask  = RBBIM.CHILD | RBBIM.ID;
            int num = (int)PInvoke.SendMessage(Handle, RB.GETBANDCOUNT, IntPtr.Zero, IntPtr.Zero);

            for (int i = 0; i < num; i++)
            {
                PInvoke.SendMessage(Handle, RB.GETBANDINFO, (IntPtr)i, ref structure);
                if (PInvoke.GetClassName(structure.hwndChild) == "ToolbarWindow32" && structure.wID == 1)
                {
                    menuController = new NativeWindowController(structure.hwndChild);
                    menuController.MessageCaptured += MenuMessageCaptured;
                    break;
                }
            }

            if (Config.Skin.UseRebarBGColor)
            {
                if (DefaultRebarCOLORREF == -1)
                {
                    DefaultRebarCOLORREF = (int)PInvoke.SendMessage(Handle, RB.GETBKCOLOR, IntPtr.Zero, IntPtr.Zero);
                }
                int num2 = QTUtility2.MakeCOLORREF(Config.Skin.RebarColor);
                PInvoke.SendMessage(Handle, RB.SETBKCOLOR, IntPtr.Zero, (IntPtr)num2);
            }

            EnsureMenuBarIsCorrect();
        }
Exemplo n.º 5
0
        private bool HandleCustomDraw(ref Message msg)
        {
            // TODO this needs to be cleaned
            if (QTUtility.CheckConfig(Settings.AlternateRowColors) && (ShellBrowser.ViewMode == FVM.DETAILS))
            {
                NMLVCUSTOMDRAW structure  = (NMLVCUSTOMDRAW)Marshal.PtrToStructure(msg.LParam, typeof(NMLVCUSTOMDRAW));
                int            dwItemSpec = 0;
                if ((ulong)structure.nmcd.dwItemSpec < Int32.MaxValue)
                {
                    dwItemSpec = (int)structure.nmcd.dwItemSpec;
                }
                switch (structure.nmcd.dwDrawStage)
                {
                case CDDS.SUBITEM | CDDS.ITEMPREPAINT:
                    iListViewItemState = (int)PInvoke.SendMessage(
                        ListViewController.Handle, LVM.GETITEMSTATE, structure.nmcd.dwItemSpec,
                        (IntPtr)(LVIS.FOCUSED | LVIS.SELECTED | LVIS.DROPHILITED));

                    if (!QTUtility.IsXP)
                    {
                        int num4 = lstColumnFMT[structure.iSubItem];
                        structure.clrTextBk = QTUtility.ShellViewRowCOLORREF_Background;
                        structure.clrText   = QTUtility.ShellViewRowCOLORREF_Text;
                        Marshal.StructureToPtr(structure, msg.LParam, false);
                        bool drawingHotItem = (dwItemSpec == GetHotItem());
                        bool fullRowSel     = !QTUtility.CheckConfig(Settings.ToggleFullRowSelect);

                        msg.Result = (IntPtr)(CDRF.NEWFONT);
                        if (structure.iSubItem == 0 && !drawingHotItem)
                        {
                            if (iListViewItemState == 0 && (num4 & 0x600) != 0)
                            {
                                msg.Result = (IntPtr)(CDRF.NEWFONT | CDRF.NOTIFYPOSTPAINT);
                            }
                            else if (iListViewItemState == LVIS.FOCUSED && !fullRowSel)
                            {
                                msg.Result = (IntPtr)(CDRF.NEWFONT | CDRF.NOTIFYPOSTPAINT);
                            }
                        }

                        if (structure.iSubItem > 0 && (!fullRowSel || !drawingHotItem))
                        {
                            if (!fullRowSel || (iListViewItemState & (LVIS.SELECTED | LVIS.DROPHILITED)) == 0)
                            {
                                using (Graphics graphics = Graphics.FromHdc(structure.nmcd.hdc)) {
                                    if (QTUtility.sbAlternate == null)
                                    {
                                        QTUtility.sbAlternate = new SolidBrush(QTUtility2.MakeColor(QTUtility.ShellViewRowCOLORREF_Background));
                                    }
                                    graphics.FillRectangle(QTUtility.sbAlternate, structure.nmcd.rc.ToRectangle());
                                }
                            }
                        }
                    }
                    else
                    {
                        msg.Result = (IntPtr)(CDRF.NOTIFYPOSTPAINT);
                    }
                    return(true);

                case CDDS.SUBITEM | CDDS.ITEMPOSTPAINT: {
                    RECT rc = structure.nmcd.rc;
                    if (QTUtility.IsXP)
                    {
                        rc = PInvoke.ListView_GetItemRect(ListViewController.Handle, dwItemSpec, structure.iSubItem, 2);
                    }
                    else
                    {
                        rc.left += 0x10;
                    }
                    bool flag3 = false;
                    bool flag4 = false;
                    bool flag5 = QTUtility.CheckConfig(Settings.DetailsGridLines);
                    bool flag6 = QTUtility.CheckConfig(Settings.ToggleFullRowSelect) ^ !QTUtility.IsXP;
                    bool flag7 = false;
                    if (QTUtility.IsXP && QTUtility.fSingleClick)
                    {
                        flag7 = (dwItemSpec == GetHotItem());
                    }
                    LVITEM lvitem = new LVITEM();
                    lvitem.pszText    = Marshal.AllocHGlobal(520);
                    lvitem.cchTextMax = 260;
                    lvitem.iSubItem   = structure.iSubItem;
                    lvitem.iItem      = dwItemSpec;
                    lvitem.mask       = 1;
                    IntPtr ptr3 = Marshal.AllocHGlobal(Marshal.SizeOf(lvitem));
                    Marshal.StructureToPtr(lvitem, ptr3, false);
                    PInvoke.SendMessage(ListViewController.Handle, LVM.GETITEM, IntPtr.Zero, ptr3);
                    if (QTUtility.sbAlternate == null)
                    {
                        QTUtility.sbAlternate = new SolidBrush(QTUtility2.MakeColor(QTUtility.ShellViewRowCOLORREF_Background));
                    }
                    using (Graphics graphics2 = Graphics.FromHdc(structure.nmcd.hdc)) {
                        Rectangle rect = rc.ToRectangle();
                        if (flag5)
                        {
                            rect = new Rectangle(rc.left + 1, rc.top, rc.Width - 1, rc.Height - 1);
                        }
                        graphics2.FillRectangle(QTUtility.sbAlternate, rect);
                        if (QTUtility.IsXP && ((structure.iSubItem == 0) || flag6))
                        {
                            flag4 = (iListViewItemState & 8) == 8;
                            if ((iListViewItemState != 0) && (((iListViewItemState == 1) && fListViewHasFocus) || (iListViewItemState != 1)))
                            {
                                int width;
                                if (flag6)
                                {
                                    width = rc.Width;
                                }
                                else
                                {
                                    width = 8 + ((int)PInvoke.SendMessage(ListViewController.Handle, LVM.GETSTRINGWIDTH, IntPtr.Zero, lvitem.pszText));
                                    if (width > rc.Width)
                                    {
                                        width = rc.Width;
                                    }
                                }
                                Rectangle rectangle2 = new Rectangle(rc.left, rc.top, width, flag5 ? (rc.Height - 1) : rc.Height);
                                if (((iListViewItemState & 2) == 2) || flag4)
                                {
                                    if (flag4)
                                    {
                                        graphics2.FillRectangle(SystemBrushes.Highlight, rectangle2);
                                    }
                                    else if (QTUtility.fSingleClick && flag7)
                                    {
                                        graphics2.FillRectangle(fListViewHasFocus ? SystemBrushes.HotTrack : SystemBrushes.Control, rectangle2);
                                    }
                                    else
                                    {
                                        graphics2.FillRectangle(fListViewHasFocus ? SystemBrushes.Highlight : SystemBrushes.Control, rectangle2);
                                    }
                                    flag3 = true;
                                }
                                if ((fListViewHasFocus && ((iListViewItemState & 1) == 1)) && !flag6)
                                {
                                    ControlPaint.DrawFocusRectangle(graphics2, rectangle2);
                                }
                            }
                        }
                        if (!QTUtility.IsXP && ((iListViewItemState & 1) == 1))
                        {
                            int num6 = rc.Width;
                            if (!flag6)
                            {
                                num6 = 4 + ((int)PInvoke.SendMessage(ListViewController.Handle, LVM.GETSTRINGWIDTH, IntPtr.Zero, lvitem.pszText));
                                if (num6 > rc.Width)
                                {
                                    num6 = rc.Width;
                                }
                            }
                            Rectangle rectangle = new Rectangle(rc.left + 1, rc.top + 1, num6, flag5 ? (rc.Height - 2) : (rc.Height - 1));
                            ControlPaint.DrawFocusRectangle(graphics2, rectangle);
                        }
                    }
                    IntPtr zero    = IntPtr.Zero;
                    IntPtr hgdiobj = IntPtr.Zero;
                    if (QTUtility.IsXP && QTUtility.fSingleClick)
                    {
                        LOGFONT logfont;
                        zero = PInvoke.GetCurrentObject(structure.nmcd.hdc, 6);
                        PInvoke.GetObject(zero, Marshal.SizeOf(typeof(LOGFONT)), out logfont);
                        if ((structure.iSubItem == 0) || flag6)
                        {
                            logfont.lfUnderline = ((QTUtility.iIconUnderLineVal == 3) || flag7) ? ((byte)1) : ((byte)0);
                        }
                        else
                        {
                            logfont.lfUnderline = 0;
                        }
                        hgdiobj = PInvoke.CreateFontIndirect(ref logfont);
                        PInvoke.SelectObject(structure.nmcd.hdc, hgdiobj);
                    }
                    PInvoke.SetBkMode(structure.nmcd.hdc, 1);
                    int dwDTFormat = 0x8824;
                    if (QTUtility.IsRTL ? ((lstColumnFMT[structure.iSubItem] & 1) == 0) : ((lstColumnFMT[structure.iSubItem] & 1) == 1))
                    {
                        if (QTUtility.IsRTL)
                        {
                            dwDTFormat &= -3;
                        }
                        else
                        {
                            dwDTFormat |= 2;
                        }
                        rc.right -= 6;
                    }
                    else if (structure.iSubItem == 0)
                    {
                        rc.left  += 2;
                        rc.right -= 2;
                    }
                    else
                    {
                        rc.left += 6;
                    }
                    if (flag3)
                    {
                        PInvoke.SetTextColor(structure.nmcd.hdc, QTUtility2.MakeCOLORREF((fListViewHasFocus || flag4) ? SystemColors.HighlightText : SystemColors.WindowText));
                    }
                    else
                    {
                        PInvoke.SetTextColor(structure.nmcd.hdc, QTUtility.ShellViewRowCOLORREF_Text);
                    }
                    PInvoke.DrawTextExW(structure.nmcd.hdc, lvitem.pszText, -1, ref rc, dwDTFormat, IntPtr.Zero);
                    Marshal.FreeHGlobal(lvitem.pszText);
                    Marshal.FreeHGlobal(ptr3);
                    msg.Result = IntPtr.Zero;
                    if (zero != IntPtr.Zero)
                    {
                        PInvoke.SelectObject(structure.nmcd.hdc, zero);
                    }
                    if (hgdiobj != IntPtr.Zero)
                    {
                        PInvoke.DeleteObject(hgdiobj);
                    }
                    return(true);
                }

                case CDDS.ITEMPREPAINT:
                    if ((dwItemSpec % 2) == 0)
                    {
                        msg.Result = (IntPtr)0x20;
                        return(true);
                    }
                    msg.Result = IntPtr.Zero;
                    return(false);

                case CDDS.PREPAINT: {
                    HDITEM hditem = new HDITEM();
                    hditem.mask = 4;
                    IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(hditem));
                    Marshal.StructureToPtr(hditem, ptr, false);
                    IntPtr hWnd = PInvoke.SendMessage(ListViewController.Handle, LVM.GETHEADER, IntPtr.Zero, IntPtr.Zero);
                    int    num2 = (int)PInvoke.SendMessage(hWnd, 0x1200, IntPtr.Zero, IntPtr.Zero);
                    if (lstColumnFMT == null)
                    {
                        lstColumnFMT = new List <int>();
                    }
                    else
                    {
                        lstColumnFMT.Clear();
                    }
                    for (int i = 0; i < num2; i++)
                    {
                        PInvoke.SendMessage(hWnd, 0x120b, (IntPtr)i, ptr);
                        hditem = (HDITEM)Marshal.PtrToStructure(ptr, typeof(HDITEM));
                        lstColumnFMT.Add(hditem.fmt);
                    }
                    Marshal.FreeHGlobal(ptr);
                    fListViewHasFocus = ListViewController.Handle == PInvoke.GetFocus();
                    msg.Result        = (IntPtr)0x20;
                    return(true);
                }
                }
            }
            return(false);
        }