private void UpdateBand(CommandBar commandBar)
        {
            if (this.IsHandleCreated)
            {
                this.BeginUpdate();

                for (int i = 0; i < this.commandBars.Count; i++)
                {
                    NativeMethods.REBARBANDINFO rbbi = new NativeMethods.REBARBANDINFO();
                    rbbi.cbSize = Marshal.SizeOf(typeof(NativeMethods.REBARBANDINFO));
                    rbbi.fMask  = NativeMethods.RBBIM_STYLE | NativeMethods.RBBIM_ID | NativeMethods.RBBIM_TEXT | NativeMethods.RBBIM_STYLE | NativeMethods.RBBIM_CHILD | NativeMethods.RBBIM_SIZE | NativeMethods.RBBIM_CHILDSIZE | NativeMethods.RBBIM_IDEALSIZE;
                    NativeMethods.SendMessage(this.Handle, NativeMethods.RB_GETBANDINFO, i, ref rbbi);

                    if (commandBar.Handle == rbbi.hwndChild)
                    {
                        if ((rbbi.cyMinChild != commandBar.Height) || (rbbi.cx != commandBar.Width) || (rbbi.cxIdeal != commandBar.Width))
                        {
                            rbbi.cyMinChild = commandBar.Height;
                            rbbi.cx         = commandBar.Width;
                            rbbi.cxIdeal    = commandBar.Width;
                            NativeMethods.SendMessage(this.Handle, NativeMethods.RB_SETBANDINFO, i, ref rbbi);
                        }
                    }
                }

                this.UpdateSize();

                this.EndUpdate();
            }
        }
        private NativeMethods.REBARBANDINFO CreateBandInfo(int index)
        {
            CommandBar commandBar = this.commandBars[index];

            NativeMethods.REBARBANDINFO rbbi = new NativeMethods.REBARBANDINFO();
            rbbi.cbSize   = Marshal.SizeOf(typeof(NativeMethods.REBARBANDINFO));
            rbbi.fMask    = 0;
            rbbi.clrFore  = 0;
            rbbi.clrBack  = 0;
            rbbi.iImage   = 0;
            rbbi.hbmBack  = IntPtr.Zero;
            rbbi.lParam   = 0;
            rbbi.cxHeader = 0;

            rbbi.fMask |= NativeMethods.RBBIM_ID;
            rbbi.wID    = 0xEB00 + index;

            if ((commandBar.Text != null) && (commandBar.Text.Length != 0))
            {
                rbbi.fMask |= NativeMethods.RBBIM_TEXT;
                rbbi.lpText = Marshal.StringToHGlobalUni(commandBar.Text);
                rbbi.cch    = (commandBar.Text == null) ? 0 : commandBar.Text.Length;
            }

            rbbi.fMask  |= NativeMethods.RBBIM_STYLE;
            rbbi.fStyle  = NativeMethods.RBBS_CHILDEDGE | NativeMethods.RBBS_FIXEDBMP | NativeMethods.RBBS_GRIPPERALWAYS;
            rbbi.fStyle |= NativeMethods.RBBS_BREAK;
            rbbi.fStyle |= NativeMethods.RBBS_USECHEVRON;

            rbbi.fMask    |= NativeMethods.RBBIM_CHILD;
            rbbi.hwndChild = commandBar.Handle;

            rbbi.fMask     |= NativeMethods.RBBIM_CHILDSIZE;
            rbbi.cyMinChild = commandBar.Height;
            rbbi.cxMinChild = 0;
            rbbi.cyChild    = 0;
            rbbi.cyMaxChild = commandBar.Height;
            rbbi.cyIntegral = commandBar.Height;

            rbbi.fMask |= NativeMethods.RBBIM_SIZE;
            rbbi.cx     = commandBar.Width;

            rbbi.fMask  |= NativeMethods.RBBIM_IDEALSIZE;
            rbbi.cxIdeal = commandBar.Width;

            return(rbbi);
        }
        protected override void OnHandleCreated(EventArgs e)
        {
            base.OnHandleCreated(e);

            this.ReleaseBands();

            this.BeginUpdate();

            for (int i = 0; i < this.commandBars.Count; i++)
            {
                NativeMethods.REBARBANDINFO bandInfo = this.CreateBandInfo(i);
                NativeMethods.SendMessage(this.Handle, NativeMethods.RB_INSERTBAND, i, ref bandInfo);
            }

            this.UpdateSize();

            this.EndUpdate();

            this.CaptureBands();
        }
Exemplo n.º 4
0
		private NativeMethods.REBARBANDINFO CreateBandInfo(int index)
		{
			CommandBar commandBar = this.commandBars[index];

			NativeMethods.REBARBANDINFO rbbi = new NativeMethods.REBARBANDINFO();
			rbbi.cbSize = Marshal.SizeOf(typeof(NativeMethods.REBARBANDINFO));
			rbbi.fMask = 0;
			rbbi.clrFore = 0;
			rbbi.clrBack = 0;
			rbbi.iImage = 0;
			rbbi.hbmBack = IntPtr.Zero;
			rbbi.lParam = 0;
			rbbi.cxHeader = 0;

			rbbi.fMask |= NativeMethods.RBBIM_ID;
			rbbi.wID = 0xEB00 + index;

			if ((commandBar.Text != null) && (commandBar.Text.Length != 0))
			{
				rbbi.fMask |= NativeMethods.RBBIM_TEXT;
				rbbi.lpText = Marshal.StringToHGlobalUni(commandBar.Text);
				rbbi.cch = (commandBar.Text == null) ? 0 : commandBar.Text.Length;
			}

			rbbi.fMask |= NativeMethods.RBBIM_STYLE;
			rbbi.fStyle = NativeMethods.RBBS_CHILDEDGE | NativeMethods.RBBS_FIXEDBMP | NativeMethods.RBBS_GRIPPERALWAYS;
			rbbi.fStyle |= NativeMethods.RBBS_BREAK;
			rbbi.fStyle |= NativeMethods.RBBS_USECHEVRON;

			rbbi.fMask |= NativeMethods.RBBIM_CHILD;
			rbbi.hwndChild = commandBar.Handle; 

			rbbi.fMask |= NativeMethods.RBBIM_CHILDSIZE;
			rbbi.cyMinChild = commandBar.Height;
			rbbi.cxMinChild = 0;
			rbbi.cyChild = 0;
			rbbi.cyMaxChild = commandBar.Height; 
			rbbi.cyIntegral = commandBar.Height;
		
			rbbi.fMask |= NativeMethods.RBBIM_SIZE;
			rbbi.cx = commandBar.Width;

			rbbi.fMask |= NativeMethods.RBBIM_IDEALSIZE;
			rbbi.cxIdeal = commandBar.Width;

			return rbbi;				
		}
Exemplo n.º 5
0
		private void UpdateBand(CommandBar commandBar)
		{
			if (this.IsHandleCreated)
			{
				this.BeginUpdate();

				for (int i = 0; i < this.commandBars.Count; i++)
				{
					NativeMethods.REBARBANDINFO rbbi = new NativeMethods.REBARBANDINFO();
					rbbi.cbSize = Marshal.SizeOf(typeof(NativeMethods.REBARBANDINFO));
					rbbi.fMask = NativeMethods.RBBIM_STYLE | NativeMethods.RBBIM_ID | NativeMethods.RBBIM_TEXT | NativeMethods.RBBIM_STYLE | NativeMethods.RBBIM_CHILD | NativeMethods.RBBIM_SIZE | NativeMethods.RBBIM_CHILDSIZE | NativeMethods.RBBIM_IDEALSIZE;
					NativeMethods.SendMessage(this.Handle, NativeMethods.RB_GETBANDINFO, i, ref rbbi);

					if (commandBar.Handle == rbbi.hwndChild)
					{
						if ((rbbi.cyMinChild != commandBar.Height) || (rbbi.cx != commandBar.Width) || (rbbi.cxIdeal != commandBar.Width))
						{
							rbbi.cyMinChild = commandBar.Height;
							rbbi.cx = commandBar.Width;
 							rbbi.cxIdeal = commandBar.Width;
							NativeMethods.SendMessage(this.Handle, NativeMethods.RB_SETBANDINFO, i, ref rbbi);
						}
					}
				}

				this.UpdateSize();

				this.EndUpdate();
			}
		}