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 += 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(); }
public static bool IsToolbarLocked(IntPtr hwndReBar) { if((hwndReBar == IntPtr.Zero) || !PInvoke.IsWindow(hwndReBar)) { return false; } REBARBANDINFO structure = new REBARBANDINFO(); structure.cbSize = Marshal.SizeOf(structure); structure.fMask = 1; IntPtr ptr2 = PInvoke.SendMessage(hwndReBar, 0x405, IntPtr.Zero, ref structure); return ((ptr2 != IntPtr.Zero) && ((structure.fStyle & 0x100) != 0)); }
/// <remarks> 获取第n个带的信息 </remarks> private REBARBANDINFO GetRebarBand(int idx, RBBIM fMask) { REBARBANDINFO info = REBARBANDINFO.Instantiate(); info.fMask = fMask; IntPtr ptr = PInvoke.toIntPtr <REBARBANDINFO>(info, false); PInvoke.SendMessage(ReBarHandle, RB.GETBANDINFO, (IntPtr)idx, ptr); //info = (REBARBANDINFO)Marshal.PtrToStructure(ptr, typeof(REBARBANDINFO)); info = PInvoke.fromIntPtr <REBARBANDINFO>(ptr); PInvoke.freeIntPtr(ptr); return(info); }
/// <remarks> 确定DeskBand是否在前面休息。?? </remarks> // Determines if the DeskBand is preceded by a break. protected bool BandHasBreak() { int n = ActiveRebarCount(); for (int i = 0; i < n; ++i) { REBARBANDINFO info = GetRebarBand(i, RBBIM.STYLE | RBBIM.CHILD); if (info.hwndChild == Handle) { return((info.fStyle & RBBS.BREAK) != 0); } } return(true); }
private REBARBANDINFO GetRebarBand(int idx, int fMask) { REBARBANDINFO info = new REBARBANDINFO(); info.cbSize = Marshal.SizeOf(info); info.fMask = fMask; IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(info)); Marshal.StructureToPtr(info, ptr, false); SendMessage(ReBarHandle, RB.GETBANDINFO, (IntPtr)idx, ptr); info = (REBARBANDINFO)Marshal.PtrToStructure(ptr, typeof(REBARBANDINFO)); Marshal.FreeHGlobal(ptr); return(info); }
public static bool IsToolbarLocked(IntPtr hwndReBar) { if((hwndReBar == IntPtr.Zero) || !PInvoke.IsWindow(hwndReBar)) { return false; } REBARBANDINFO structure = new REBARBANDINFO(); structure.cbSize = Marshal.SizeOf(structure); structure.fMask = 1; IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(structure)); Marshal.StructureToPtr(structure, ptr, false); IntPtr ptr2 = PInvoke.SendMessage(hwndReBar, 0x405, IntPtr.Zero, ptr); structure = (REBARBANDINFO)Marshal.PtrToStructure(ptr, typeof(REBARBANDINFO)); Marshal.FreeHGlobal(ptr); return ((ptr2 != IntPtr.Zero) && ((structure.fStyle & 0x100) != 0)); }
public static void ShowMenuBar(bool fShow, IntPtr hwndRebar) { if((hwndRebar != IntPtr.Zero) && PInvoke.IsWindow(hwndRebar)) { int num = (int)PInvoke.SendMessage(hwndRebar, 0x40c, IntPtr.Zero, IntPtr.Zero); REBARBANDINFO structure = new REBARBANDINFO(); structure.cbSize = Marshal.SizeOf(structure); structure.fMask = 0x110; for(int i = 0; i < num; i++) { IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(structure)); Marshal.StructureToPtr(structure, ptr, false); PInvoke.SendMessage(hwndRebar, 0x405, (IntPtr)i, ptr); structure = (REBARBANDINFO)Marshal.PtrToStructure(ptr, typeof(REBARBANDINFO)); Marshal.FreeHGlobal(ptr); if((PInvoke.GetClassName(structure.hwndChild) == "ToolbarWindow32") && (structure.wID == 1)) { PInvoke.SendMessage(hwndRebar, 0x423, (IntPtr)i, fShow ? ((IntPtr)1) : IntPtr.Zero); return; } } } }
public static void ShowMenuBar(bool fShow, IntPtr hwndRebar) { if((hwndRebar != IntPtr.Zero) && PInvoke.IsWindow(hwndRebar)) { int num = (int)PInvoke.SendMessage(hwndRebar, 0x40c, IntPtr.Zero, IntPtr.Zero); REBARBANDINFO structure = new REBARBANDINFO(); structure.cbSize = Marshal.SizeOf(structure); structure.fMask = 0x110; for(int i = 0; i < num; i++) { PInvoke.SendMessage(hwndRebar, 0x405, (IntPtr)i, ref structure); if((PInvoke.GetClassName(structure.hwndChild) == "ToolbarWindow32") && (structure.wID == 1)) { PInvoke.SendMessage(hwndRebar, 0x423, (IntPtr)i, fShow ? ((IntPtr)1) : IntPtr.Zero); return; } } } }
protected override void WndProc(ref Message m) { if (!Enabled) { base.WndProc(ref m); return; } // When the bars are first loaded, they will always have // RBBS_BREAK set. Catch RB_SETBANDINFO to fix this. if (m.Msg == RB.SETBANDINFO) { if (MonitorSetInfo) { REBARBANDINFO pInfo = (REBARBANDINFO)Marshal.PtrToStructure(m.LParam, typeof(REBARBANDINFO)); if (pInfo.hwndChild == parent.Handle && (pInfo.fMask & RBBIM.STYLE) != 0) { // Ask the bar if we actually want a break. if (parent.ShouldHaveBreak()) { pInfo.fStyle |= RBBS.BREAK; } else { pInfo.fStyle &= ~RBBS.BREAK; } Marshal.StructureToPtr(pInfo, m.LParam, false); } } } // Whenever a band is deleted, the RBBS_BREAKs come back! // Catch RB_DELETEBAND to fix it. else if (m.Msg == RB.DELETEBAND) { int del = (int)m.WParam; // Look for our band int n = parent.ActiveRebarCount(); for (int i = 0; i < n; ++i) { REBARBANDINFO info = parent.GetRebarBand(i, RBBIM.STYLE | RBBIM.CHILD); if (info.hwndChild == parent.Handle) { // Call the WndProc to let the deletion fall // through, with the break status safely saved // in the info variable. base.WndProc(ref m); // If *we're* the one being deleted, no need to do // anything else. if (i == del) { return; } // Otherwise, our style has been messed with. // Set it back to what it was. info.cbSize = Marshal.SizeOf(info); info.fMask = RBBIM.STYLE; IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(info)); Marshal.StructureToPtr(info, ptr, false); bool reset = MonitorSetInfo; MonitorSetInfo = false; PInvoke.SendMessage(parent.ReBarHandle, RB.SETBANDINFO, (IntPtr)i, ptr); MonitorSetInfo = reset; Marshal.FreeHGlobal(ptr); // Return without calling WndProc twice! return; } } } base.WndProc(ref m); }
private REBARBANDINFO GetRebarBand(int idx, int fMask) { REBARBANDINFO info = new REBARBANDINFO(); info.cbSize = Marshal.SizeOf(info); info.fMask = fMask; IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(info)); Marshal.StructureToPtr(info, ptr, false); SendMessage(ReBarHandle, RB.GETBANDINFO, (IntPtr)idx, ptr); info = (REBARBANDINFO)Marshal.PtrToStructure(ptr, typeof(REBARBANDINFO)); Marshal.FreeHGlobal(ptr); return info; }
public void EnsureMenuBarIsCorrect() { bool show = MenuHasFocus || MenuBarShown; 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(structure.hwndChild != menuController.Handle) continue; PInvoke.SendMessage(Handle, RB.SHOWBAND, (IntPtr)i, show ? ((IntPtr)1) : IntPtr.Zero); return; } }
public void EnsureMenuBarIsCorrect() { 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) { PInvoke.SendMessage(Handle, RB.SHOWBAND, (IntPtr)i, MenuBarShown ? ((IntPtr)1) : IntPtr.Zero); return; } } }