protected void UpdateChild() { if (Created) { REBARBANDINFO rbBand = new REBARBANDINFO(); rbBand.cbSize = (uint)Marshal.SizeOf(rbBand); rbBand.fMask = (uint)RebarBandInfoConstants.RBBIM_CHILD; if (_child == null) { rbBand.hwndChild = IntPtr.Zero; } else { rbBand.hwndChild = _child.Handle; } if (User32Dll.SendMessage(_bands.Rebar.RebarHwnd, (int)WindowsMessages.RB_SETBANDINFOA, BandIndex, ref rbBand) == 0) { int LastErr = Marshal.GetHRForLastWin32Error(); try { Marshal.ThrowExceptionForHR(LastErr); } catch (Exception ex) { Console.WriteLine(LastErr + " " + ex.Message); if (_throwExceptions) { throw(new Exception("Error Updating Child.", ex)); } } } UpdateMinimums(); } }
public static REBARBANDINFO Instantiate() { REBARBANDINFO info = new REBARBANDINFO(); info.cbSize = Marshal.SizeOf(info); return(info); }
private void RealizeBands() { ReleaseBands(); BeginUpdate(); for (int i = 0; i < bands.Count; i++) { REBARBANDINFO bandInfo = GetBandInfo(i, null); WindowsAPI.SendMessage(Handle, (int)RebarMessages.RB_INSERTBANDW, i, ref bandInfo); } UpdateSize(); EndUpdate(); CaptureBands(); if (bands.Count == 0 && addPlaceHolderToolBar) { if (designerInTransaction == false) { // If the designer is engage in a transaction // don't add the place holder toolbar here, defer the // addition to the PaintBackground routine so that // we avoid some painting problems addPlaceHolderToolBar = false; AddPlaceHolder(); } } }
protected void UpdateStyles() { if (Created) { REBARBANDINFO rbBand = new REBARBANDINFO(); rbBand.cbSize = (uint)Marshal.SizeOf(rbBand); rbBand.fMask = (uint)RebarBandInfoConstants.RBBIM_STYLE; rbBand.fStyle = (uint)Style; if (User32Dll.SendMessage(_bands.Rebar.RebarHwnd, (int)WindowsMessages.RB_SETBANDINFOA, BandIndex, ref rbBand) == 0) { int LastErr = Marshal.GetHRForLastWin32Error(); try { Marshal.ThrowExceptionForHR(LastErr); } catch (Exception ex) { Console.WriteLine(LastErr + " " + ex.Message); if (_throwExceptions) { throw(new Exception("Error Updating Styles.", ex)); } } } } }
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); StringBuilder lpClassName = new StringBuilder(260); PInvoke.GetClassName(structure.hwndChild, lpClassName, lpClassName.Capacity); if ((lpClassName.ToString() == "ToolbarWindow32") && (structure.wID == 1)) { PInvoke.SendMessage(hwndRebar, 0x423, (IntPtr)i, fShow ? ((IntPtr)1) : IntPtr.Zero); return; } } } }
REBARBANDINFO GetRebarInfo(int index) { REBARBANDINFO rbbi = new REBARBANDINFO(); rbbi.cbSize = Marshal.SizeOf(typeof(REBARBANDINFO)); rbbi.fMask = (int)(RebarInfoMask.RBBIM_ID|RebarInfoMask.RBBIM_IDEALSIZE); WindowsAPI.SendMessage(Handle, (int)RebarMessages.RB_GETBANDINFOW, index, ref rbbi); return rbbi; }
REBARBANDINFO GetBandInfo(int index) { Control band = bands[index]; REBARBANDINFO rbbi = new REBARBANDINFO(); rbbi.cbSize = Marshal.SizeOf(typeof(REBARBANDINFO)); if (!IsCommonCtrl6()) { rbbi.fMask = (int)RebarInfoMask.RBBIM_COLORS; rbbi.clrBack = (int)ColorUtil.RGB(ColorUtil.VSNetControlColor.R, ColorUtil.VSNetControlColor.G, ColorUtil.VSNetControlColor.B); rbbi.clrFore = (int)ColorUtil.RGB(255, 0, 255); } rbbi.iImage = 0; rbbi.hbmBack = IntPtr.Zero; rbbi.lParam = 0; rbbi.cxHeader = 0; rbbi.fMask |= (int)RebarInfoMask.RBBIM_ID; rbbi.wID = index; if ((band.Text != null) && (band.Text != string.Empty)) { rbbi.fMask |= (int)RebarInfoMask.RBBIM_TEXT; rbbi.lpText = Marshal.StringToHGlobalAnsi(band.Text); rbbi.cch = (band.Text == null) ? 0 : band.Text.Length; } rbbi.fMask |= (int)RebarInfoMask.RBBIM_STYLE; rbbi.fStyle = (int)(RebarStylesEx.RBBS_CHILDEDGE | RebarStylesEx.RBBS_FIXEDBMP | RebarStylesEx.RBBS_GRIPPERALWAYS); ToolBarEx tb = (ToolBarEx)band; if (tb.UseNewRow == true) { rbbi.fStyle |= (int)(RebarStylesEx.RBBS_BREAK); } rbbi.fStyle |= (band is IChevron) ? (int)RebarStylesEx.RBBS_USECHEVRON : 0; rbbi.fMask |= (int)(RebarInfoMask.RBBIM_CHILD); rbbi.hwndChild = band.Handle; rbbi.fMask |= (int)(RebarInfoMask.RBBIM_CHILDSIZE); rbbi.cyMinChild = band.Height; rbbi.cxMinChild = 0; rbbi.cyChild = 0; rbbi.cyMaxChild = 0; rbbi.cyIntegral = 0; rbbi.fMask |= (int)(RebarInfoMask.RBBIM_SIZE); rbbi.cx = band.Width; rbbi.fMask |= (int)(RebarInfoMask.RBBIM_IDEALSIZE); rbbi.cxIdeal = band.Width; return(rbbi); }
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)); }
internal void AddPlaceHolder() { placeHolderAdded = true; // Add place holder toolBar for designer support if (placeHolderToolBar == null) { placeHolderToolBar = new ToolBarEx(); placeHolderToolBar.m_parent = this; } REBARBANDINFO bandInfo = GetBandInfo(0, placeHolderToolBar); int result = WindowsAPI.SendMessage(Handle, (int)RebarMessages.RB_INSERTBANDW, 0, ref bandInfo); }
void RealizeBands() { ReleaseBands(); BeginUpdate(); for (int i = 0; i < bands.Count; i++) { REBARBANDINFO bandInfo = GetBandInfo(i); WindowsAPI.SendMessage(Handle, (int)RebarMessages.RB_INSERTBANDW, i, ref bandInfo); } UpdateSize(); EndUpdate(); CaptureBands(); }
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; } } }
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) { PInvoke.SendMessage(Handle, RB.SHOWBAND, (IntPtr)i, show ? ((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; } } } }
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)); }
void UpdateBand(int index) { if (!IsHandleCreated) return; BeginUpdate(); // Make sure we get the right index according to the band position in the rebar // and not to the index in the toolbar collections which can or cannot match the order // in the rebar control int actualIndex = GetBandActualIndex(index); REBARBANDINFO rbbi = GetBandInfo(actualIndex); ToolBarEx tb = (ToolBarEx)bands[actualIndex]; int idealSize = tb.GetIdealSize(); rbbi.cxIdeal = idealSize; WindowsAPI.SendMessage(Handle, (int)RebarMessages.RB_SETBANDINFOW, index, ref rbbi); UpdateSize(); EndUpdate(); }
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(); }
protected void UpdateColors() { if (Created) { REBARBANDINFO rbBand = new REBARBANDINFO(); rbBand.cbSize = (uint)Marshal.SizeOf(rbBand); rbBand.fMask = (uint)RebarBandInfoConstants.RBBIM_COLORS; if (_useCoolbarColors) { rbBand.clrBack = new COLORREF(); rbBand.clrBack._ColorDWORD = (uint)ColorConstants.CLR_DEFAULT; rbBand.clrFore = new COLORREF(); rbBand.clrFore._ColorDWORD = (uint)ColorConstants.CLR_DEFAULT; } else { rbBand.clrBack = new COLORREF(_backColor); rbBand.clrFore = new COLORREF(_foreColor); } if (User32Dll.SendMessage(_bands.Rebar.RebarHwnd, (int)WindowsMessages.RB_SETBANDINFOA, BandIndex, ref rbBand) == 0) { int LastErr = Marshal.GetHRForLastWin32Error(); try { Marshal.ThrowExceptionForHR(LastErr); } catch (Exception ex) { Console.WriteLine(LastErr + " " + ex.Message); if (_throwExceptions) { throw(new Exception("Error Updating Foreground and Background Colors.", ex)); } } } } }
protected void UpdateMinimums() { //return; if (Created) { REBARBANDINFO rbBand = new REBARBANDINFO(); rbBand.cbSize = (uint)Marshal.SizeOf(rbBand); rbBand.fMask = (uint)(RebarBandInfoConstants.RBBIM_CHILDSIZE); if (_header != -1) { rbBand.fMask |= (uint)RebarBandInfoConstants.RBBIM_HEADERSIZE; } rbBand.cxMinChild = (uint)_minWidth; rbBand.cyMinChild = (uint)_minHeight; rbBand.cyIntegral = (uint)_integral; //1; rbBand.cyChild = (uint)_minHeight; rbBand.cyMaxChild = 300; rbBand.cxIdeal = (uint)_idealWidth; rbBand.cxHeader = (uint)_header; if (User32Dll.SendMessage(_bands.Rebar.RebarHwnd, (int)WindowsMessages.RB_SETBANDINFOA, BandIndex, ref rbBand) == 0) { int LastErr = Marshal.GetHRForLastWin32Error(); try { Marshal.ThrowExceptionForHR(LastErr); } catch (Exception ex) { Console.WriteLine(LastErr + " " + ex.Message); if (_throwExceptions) { throw(new Exception("Error Updating Minimums.", ex)); } } } } }
private bool MessageCaptured(ref Message m) { // Make sure the menu bar obeys the Explorer setting. // Was this really so hard, Microsoft? if (m.Msg == RB.SETBANDINFO) { REBARBANDINFO pInfo = (REBARBANDINFO)Marshal.PtrToStructure(m.LParam, typeof(REBARBANDINFO)); if ((PInvoke.GetClassName(pInfo.hwndChild) == "ToolbarWindow32") && (pInfo.wID == 1)) { if (MenuBarShown) { pInfo.fStyle &= ~RBBS.HIDDEN; } else { pInfo.fStyle |= RBBS.HIDDEN; } Marshal.StructureToPtr(pInfo, m.LParam, false); } return(false); } if (m.Msg == WM.ERASEBKGND && (QTUtility.CheckConfig(Settings.ToolbarBGColor) || QTUtility.CheckConfig(Settings.RebarImage))) { bool fFilled = false; using (Graphics graphics = Graphics.FromHdc(m.WParam)) { RECT rect; PInvoke.GetWindowRect(Handle, out rect); Rectangle rectangle = new Rectangle(0, 0, rect.Width, rect.Height); // Fill the Rebar background color if (QTUtility.CheckConfig(Settings.ToolbarBGColor)) { using (SolidBrush brush = new SolidBrush(QTUtility.RebarBGColor)) { graphics.FillRectangle(brush, rectangle); fFilled = true; } } // Draw the Rebar image if (VisualStyleRenderer.IsSupported && QTUtility.CheckConfig(Settings.RebarImage) && QTUtility.Path_RebarImage.Length > 0) { if (bmpRebar == null) { CreateRebarImage(); } if (bmpRebar != null) { switch (((QTUtility.ConfigValues[11] & 0x60) | (QTUtility.ConfigValues[13] & 1))) { case 1: { // Stretch on each band if (!fFilled) { rebarController.DefWndProc(ref m); } int bandCount = (int)PInvoke.SendMessage(rebarController.Handle, RB.GETBANDCOUNT, IntPtr.Zero, IntPtr.Zero); graphics.PixelOffsetMode = PixelOffsetMode.HighQuality; RECT rectBand = new RECT(); RECT rectMargin = new RECT(); // Draw the bitmap on each band for (int i = 0; i < bandCount; i++) { if (PInvoke.SendMessage(rebarController.Handle, RB.GETRECT, (IntPtr)i, ref rectBand) == IntPtr.Zero) { continue; } PInvoke.SendMessage(rebarController.Handle, RB.GETBANDBORDERS, (IntPtr)i, ref rectMargin); rectBand.left -= !QTUtility.IsXP ? 4 : rectMargin.left; rectBand.top -= rectMargin.top; rectBand.right += rectMargin.right; rectBand.bottom += rectMargin.bottom; graphics.DrawImage(bmpRebar, rectBand.ToRectangle()); } break; } case 0x20: { // Real size if (!fFilled) { rebarController.DefWndProc(ref m); } Rectangle destRect = new Rectangle(Point.Empty, bmpRebar.Size); graphics.DrawImage(bmpRebar, destRect, destRect, GraphicsUnit.Pixel); break; } case 0x40: // Tile textureBrushRebar = textureBrushRebar ?? new TextureBrush(bmpRebar); graphics.FillRectangle(textureBrushRebar, rectangle); break; default: // Full size graphics.PixelOffsetMode = PixelOffsetMode.HighQuality; graphics.DrawImage(bmpRebar, rectangle); break; } fFilled = true; } } } if (fFilled) { m.Result = (IntPtr)1; return(true); } } return(false); }
internal void RemovePlaceHolder() { placeHolderAdded = false; REBARBANDINFO bandInfo = GetBandInfo(0, placeHolderToolBar); int result = WindowsAPI.SendMessage(Handle, (int)RebarMessages.RB_DELETEBAND, 0, 0); }
private void UpdateChildByHandle( IntPtr handle ){ if ( Created ) { REBARBANDINFO rbBand = new REBARBANDINFO(); rbBand.cbSize = (uint)Marshal.SizeOf( rbBand ); rbBand.fMask = (uint)win32.RBBIM_CHILD; if ( handle.Equals( IntPtr.Zero ) ) { rbBand.hwndChild = IntPtr.Zero; } else { rbBand.hwndChild = handle; } if ( win32.SendMessage( _bands.Rebar.RebarHwnd, (int)win32.RB_SETBANDINFOA, BandIndex, ref rbBand ) == 0 ) { int LastErr = Marshal.GetHRForLastWin32Error(); try { Marshal.ThrowExceptionForHR( LastErr ); } catch ( Exception ex ) { Console.WriteLine( LastErr + " " + ex.Message ); if ( _throwExceptions ) throw (new Exception( "Error Updating Child.", ex )); } } UpdateMinimums(); } }
protected void UpdateColors() { if ( Created ) { REBARBANDINFO rbBand = new REBARBANDINFO(); rbBand.cbSize = (uint)Marshal.SizeOf( rbBand ); rbBand.fMask = (uint)win32.RBBIM_COLORS; if ( _useCoolbarColors ) { rbBand.clrBack = new COLORREF(); rbBand.clrBack._ColorDWORD = (uint)win32.CLR_DEFAULT; rbBand.clrFore = new COLORREF(); rbBand.clrFore._ColorDWORD = (uint)win32.CLR_DEFAULT; } else { rbBand.clrBack = new COLORREF( _backColor ); rbBand.clrFore = new COLORREF( _foreColor ); } if ( win32.SendMessage( _bands.Rebar.RebarHwnd, (int)win32.RB_SETBANDINFOA, BandIndex, ref rbBand ) == 0 ) { int LastErr = Marshal.GetHRForLastWin32Error(); try { Marshal.ThrowExceptionForHR( LastErr ); } catch ( Exception ex ) { Console.WriteLine( LastErr + " " + ex.Message ); if ( _throwExceptions ) throw (new Exception( "Error Updating Foreground and Background Colors.", ex )); } } } }
internal void CreateBand() { if (!Created && _bands != null && _bands.Rebar.Rebar != null) { if (_child != null) { _child.Parent = _bands.Rebar; } REBARBANDINFO rbBand = new REBARBANDINFO(); rbBand.cbSize = (uint)Marshal.SizeOf(rbBand); rbBand.fMask = (uint)(RebarBandInfoConstants.RBBIM_STYLE | RebarBandInfoConstants.RBBIM_ID | RebarBandInfoConstants.RBBIM_TEXT ); //| RebarBandInfoConstants.RBBIM_HEADERSIZE); if (!_useCoolbarColors) { rbBand.fMask |= (uint)RebarBandInfoConstants.RBBIM_COLORS; } if (_child != null) //Add ChildSize stuff at some point { rbBand.fMask |= (uint)RebarBandInfoConstants.RBBIM_CHILD; } rbBand.fMask |= (uint)RebarBandInfoConstants.RBBIM_CHILDSIZE; if (_image >= 0) { rbBand.fMask |= (uint)RebarBandInfoConstants.RBBIM_IMAGE; } if (_backgroundImage != null) { rbBand.fMask |= (uint)RebarBandInfoConstants.RBBIM_BACKGROUND; } rbBand.clrFore = new COLORREF(ForeColor); rbBand.clrBack = new COLORREF(BackColor); rbBand.fStyle = (uint)Style; if (_backgroundImage != null) { rbBand.hbmBack = _pictureHandle; } rbBand.lpText = _caption; if (_child != null) { rbBand.hwndChild = _child.Handle; rbBand.cxMinChild = (uint)_minWidth; rbBand.cyMinChild = (uint)_minHeight; rbBand.cyIntegral = (uint)_integral; //0; rbBand.cyChild = (uint)_minHeight; rbBand.cyMaxChild = 40; rbBand.cxIdeal = (uint)_idealWidth; rbBand.cx = (uint)_initalWidth; rbBand.fMask = rbBand.fMask | (uint)RebarBandInfoConstants.RBBIM_SIZE; } if (_showIcon) { rbBand.iImage = _image; } rbBand.wID = (uint)_id; rbBand.cxHeader = (uint)_header; if (User32Dll.SendMessage(_bands.Rebar.RebarHwnd, (int)WindowsMessages.RB_INSERTBANDA, -1, ref rbBand) == 0) { int LastErr = Marshal.GetHRForLastWin32Error(); try { Marshal.ThrowExceptionForHR(LastErr); } catch (Exception ex) { Console.WriteLine(LastErr + " " + ex.Message); if (_throwExceptions) { throw(new Exception("Error Creating Band.", ex)); } } } else { _created = true; } } }
protected void UpdateIcon() { if ( Created ) { REBARBANDINFO rbBand = new REBARBANDINFO(); rbBand.cbSize = (uint)Marshal.SizeOf( rbBand ); rbBand.fMask = (uint)win32.RBBIM_IMAGE; if ( _showIcon ) { rbBand.iImage = _image; } else { rbBand.iImage = -1; } if ( win32.SendMessage( _bands.Rebar.RebarHwnd, (int)win32.RB_SETBANDINFOA, BandIndex, ref rbBand ) == 0 ) { int LastErr = Marshal.GetHRForLastWin32Error(); try { Marshal.ThrowExceptionForHR( LastErr ); } catch ( Exception ex ) { Console.WriteLine( LastErr + " " + ex.Message ); if ( _throwExceptions ) throw (new Exception( "Error Updating Icon.", ex )); } } } }
protected void UpdateMinimums() { //return; if ( Created ) { REBARBANDINFO rbBand = new REBARBANDINFO(); rbBand.cbSize = (uint)Marshal.SizeOf( rbBand ); rbBand.fMask = (uint)(win32.RBBIM_CHILDSIZE); if ( _header != -1 ) rbBand.fMask |= (uint)win32.RBBIM_HEADERSIZE; rbBand.cxMinChild = (uint)_minWidth; rbBand.cyMinChild = (uint)_minHeight; rbBand.cyIntegral = (uint)_integral;//1; rbBand.cyChild = (uint)_minHeight; rbBand.cyMaxChild = (uint)_maxHeight; rbBand.cxIdeal = (uint)_idealWidth; rbBand.cxHeader = (uint)_header; if ( win32.SendMessage( _bands.Rebar.RebarHwnd, (int)win32.RB_SETBANDINFOA, BandIndex, ref rbBand ) == 0 ) { int LastErr = Marshal.GetHRForLastWin32Error(); try { Marshal.ThrowExceptionForHR( LastErr ); } catch ( Exception ex ) { Console.WriteLine( LastErr + " " + ex.Message ); if ( _throwExceptions ) throw (new Exception( "Error Updating Minimums.", ex )); } } } }
public static extern void SendMessage(IntPtr hWnd, int msg, int wParam, ref REBARBANDINFO lParam);
protected void UpdateStyles() { if ( Created ) { REBARBANDINFO rbBand = new REBARBANDINFO(); rbBand.cbSize = (uint)Marshal.SizeOf( rbBand ); rbBand.fMask = (uint)win32.RBBIM_STYLE; rbBand.fStyle = (uint)Style; if ( win32.SendMessage( _bands.Rebar.RebarHwnd, (int)win32.RB_SETBANDINFOA, BandIndex, ref rbBand ) == 0 ) { int LastErr = Marshal.GetHRForLastWin32Error(); try { Marshal.ThrowExceptionForHR( LastErr ); } catch ( Exception ex ) { Console.WriteLine( LastErr + " " + ex.Message ); if ( _throwExceptions ) throw (new Exception( "Error Updating Styles.", ex )); } } } }
internal void CreateBand() { if ( !Created && _bands != null && _bands.Rebar.NativeRebar != null ) { if ( _child != null ) _child.Parent = _bands.Rebar; REBARBANDINFO rbBand = new REBARBANDINFO(); rbBand.cbSize = (uint)Marshal.SizeOf( rbBand ); rbBand.fMask = (uint)(win32.RBBIM_STYLE | win32.RBBIM_ID | win32.RBBIM_TEXT );//| RebarBandInfoConstants.RBBIM_HEADERSIZE); if ( !_useCoolbarColors ) rbBand.fMask |= (uint)win32.RBBIM_COLORS; if ( _child != null ) //Add ChildSize stuff at some point { rbBand.fMask |= (uint)win32.RBBIM_CHILD; } rbBand.fMask |= (uint)win32.RBBIM_CHILDSIZE; if ( _image >= 0 ) rbBand.fMask |= (uint)win32.RBBIM_IMAGE; if ( _backgroundImage != null ) { rbBand.fMask |= (uint)win32.RBBIM_BACKGROUND; } rbBand.cx = (uint)_bandSize; rbBand.fMask |= (uint)win32.RBBIM_SIZE; rbBand.fMask |= (uint)win32.RBBIM_IDEALSIZE; rbBand.clrFore = new COLORREF( ForeColor ); rbBand.clrBack = new COLORREF( BackColor ); rbBand.fStyle = (uint)Style; if ( _backgroundImage != null ) { rbBand.hbmBack = _pictureHandle; } rbBand.lpText = _caption; if ( _child != null ) { rbBand.hwndChild = _child.Handle; rbBand.cxMinChild = (uint)_minWidth; rbBand.cyMinChild = (uint)_minHeight; rbBand.cyIntegral = (uint)_integral;//0; rbBand.cyChild = (uint)_minHeight; rbBand.cyMaxChild = (uint)_maxHeight; rbBand.cxIdeal = (uint)_idealWidth; } if ( _showIcon ) { rbBand.iImage = _image; } rbBand.wID = (uint)_id; rbBand.cxHeader = (uint)_header; if ( win32.SendMessage( _bands.Rebar.RebarHwnd, (int)win32.RB_INSERTBANDA, -1, ref rbBand ) == 0 ) { int LastErr = Marshal.GetHRForLastWin32Error(); try { Marshal.ThrowExceptionForHR( LastErr ); } catch ( Exception ex ) { Console.WriteLine( LastErr + " " + ex.Message ); if ( _throwExceptions ) throw (new Exception( "Error Creating Band.", ex )); } } else { _created = true; } } }
// TODO-Linux: Implement if needed public static int SendMessage(IntPtr hWnd, int msg, int wParam, ref REBARBANDINFO lParam) { Console.WriteLine("Warning using unimplemented method SendMessage"); return 0; }
private bool RebarMessageCaptured(ref Message m) { // Make sure the menu bar obeys the Explorer setting. // Was this really so hard, Microsoft? if (m.Msg == RB.SETBANDINFO) { REBARBANDINFO pInfo = (REBARBANDINFO)Marshal.PtrToStructure(m.LParam, typeof(REBARBANDINFO)); if ((PInvoke.GetClassName(pInfo.hwndChild) == "ToolbarWindow32") && (pInfo.wID == 1)) { if (MenuHasFocus || MenuBarShown) { pInfo.fStyle &= ~RBBS.HIDDEN; } else { pInfo.fStyle |= RBBS.HIDDEN; } Marshal.StructureToPtr(pInfo, m.LParam, false); } return(false); } if (m.Msg == WM.ERASEBKGND && (Config.Skin.UseRebarBGColor || Config.Skin.UseRebarImage)) { bool fFilled = false; using (Graphics graphics = Graphics.FromHdc(m.WParam)) { RECT rect; PInvoke.GetWindowRect(Handle, out rect); Rectangle rectRebar = new Rectangle(0, 0, rect.Width, rect.Height); // Fill the Rebar background color if (Config.Skin.UseRebarBGColor) { using (SolidBrush brush = new SolidBrush(Config.Skin.RebarColor)) { graphics.FillRectangle(brush, rectRebar); fFilled = true; } } else if (Config.Skin.RebarStretchMode == StretchMode.Real) { rebarController.DefWndProc(ref m); } // Draw the Rebar image if (VisualStyleRenderer.IsSupported && Config.Skin.UseRebarImage && Config.Skin.RebarImageFile.Length > 0) { if (bmpRebar == null) { CreateRebarImage(); } if (bmpRebar != null) { List <Rectangle> rectTargets = new List <Rectangle>(); if (Config.Skin.RebarImageSeperateBars) { int bandCount = (int)PInvoke.SendMessage(rebarController.Handle, RB.GETBANDCOUNT, IntPtr.Zero, IntPtr.Zero); graphics.PixelOffsetMode = PixelOffsetMode.HighQuality; RECT rectBand = new RECT(); RECT rectMargin = new RECT(); for (int i = 0; i < bandCount; i++) { if (PInvoke.SendMessage(rebarController.Handle, RB.GETRECT, (IntPtr)i, ref rectBand) == IntPtr.Zero) { continue; } PInvoke.SendMessage(rebarController.Handle, RB.GETBANDBORDERS, (IntPtr)i, ref rectMargin); rectBand.left -= !QTUtility.IsXP ? 4 : rectMargin.left; rectBand.top -= rectMargin.top; rectBand.right += rectMargin.right; rectBand.bottom += rectMargin.bottom; rectTargets.Add(rectBand.ToRectangle()); } } else { rectTargets.Add(rectRebar); } foreach (Rectangle destRect in rectTargets) { switch (Config.Skin.RebarStretchMode) { case StretchMode.Real: Rectangle rectDest2 = new Rectangle(new Point(0, 0), destRect.Size); Rectangle rectBmp = new Rectangle(new Point(0, 0), bmpRebar.Size); rectBmp.Intersect(rectDest2); rectDest2.Intersect(rectBmp); rectDest2.Offset(destRect.Location); graphics.DrawImage(bmpRebar, rectDest2, rectBmp, GraphicsUnit.Pixel); break; case StretchMode.Tile: textureBrushRebar = textureBrushRebar ?? new TextureBrush(bmpRebar); textureBrushRebar.TranslateTransform(destRect.X, destRect.Y); graphics.FillRectangle(textureBrushRebar, destRect); textureBrushRebar.ResetTransform(); break; default: // Full // todo: make this a function graphics.PixelOffsetMode = PixelOffsetMode.HighQuality; Padding margin = Config.Skin.RebarSizeMargin; int left = margin.Left; int top = margin.Top; int right = margin.Right; int bottom = margin.Bottom; int vertical = margin.Vertical; int horizontal = margin.Horizontal; int width = bmpRebar.Width; int height = bmpRebar.Height; Rectangle[] dstRects = new Rectangle[] { new Rectangle(destRect.X, destRect.Y, left, top), new Rectangle(destRect.X + left, destRect.Y, destRect.Width - horizontal, top), new Rectangle(destRect.Right - right, destRect.Y, right, top), new Rectangle(destRect.X, destRect.Y + top, left, destRect.Height - vertical), new Rectangle(destRect.X + left, destRect.Y + top, destRect.Width - horizontal, destRect.Height - vertical), new Rectangle(destRect.Right - right, destRect.Y + top, right, destRect.Height - vertical), new Rectangle(destRect.X, destRect.Bottom - bottom, left, bottom), new Rectangle(destRect.X + left, destRect.Bottom - bottom, destRect.Width - horizontal, bottom), new Rectangle(destRect.Right - right, destRect.Bottom - bottom, right, bottom) }; Rectangle[] srcRects = new Rectangle[] { new Rectangle(0, 0, left, top), new Rectangle(left, 0, width - horizontal, top), new Rectangle(width - right, 0, right, top), new Rectangle(0, top, left, height - vertical), new Rectangle(left, top, width - horizontal, height - vertical), new Rectangle(width - right, top, right, height - vertical), new Rectangle(0, height - bottom, left, bottom), new Rectangle(left, height - bottom, width - horizontal, bottom), new Rectangle(width - right, height - bottom, right, bottom), }; for (int i = 0; i < 9; i++) { graphics.DrawImage(bmpRebar, dstRects[i], srcRects[i], GraphicsUnit.Pixel); } break; } } fFilled = true; } } } if (fFilled) { m.Result = (IntPtr)1; return(true); } } return(false); }