private void ResizeForm(object sender, EventArgs e) { ResizePane(); if (ToolbarHost != null) { ToolbarHost.BorderChanged(); } }
private void FormLoad(object sender, EventArgs e) { if (this.DesignMode) { return; } if (null == containedForm) { // Handle the case that the class was constructed with the parameterless // constructor, so no container control is created. // In this case we have to create a new control that will contain all the // controls contained by this form and use it to create the window pane. Control paneControl = new UserControl(); while (this.Controls.Count > 0) { Control ctl = this.Controls[0]; ctl.Parent = paneControl; } containedForm = new WindowPaneAdapter(this, paneControl); controlSize = this.ClientSize; } System.Drawing.Size mySize = this.ClientSize; // Check if this window has a toolbar. if (null != toolbarCommandId) { Guid toolbarCommandSet = toolbarCommandId.Guid; IVsToolWindowToolbarHost2 toolBarHost2 = (IVsToolWindowToolbarHost2)ToolbarHost; NativeMethods.ThrowOnFailure( toolBarHost2.AddToolbar2(toolbarLocation, ref toolbarCommandSet, (uint)toolbarCommandId.ID, toolbarDropTarget)); NativeMethods.ThrowOnFailure(ToolbarHost.Show(0)); NativeMethods.ThrowOnFailure(ToolbarHost.ForceUpdateUI()); } // Now we have to resize the form to make room for the toolbar. mySize.Width = controlSize.Width + toolbarRect.left + toolbarRect.right; mySize.Height = controlSize.Height + toolbarRect.top + toolbarRect.bottom; this.ClientSize = mySize; // Find the coordinate of the main pane. int x = toolbarRect.left; int y = toolbarRect.top; int width = mySize.Width - toolbarRect.left - toolbarRect.right; int height = mySize.Height - toolbarRect.top - toolbarRect.bottom; // Make sure that the pane is created. containedForm.Create(x, y, height, width); // Set the focus to the control containedForm.Focus(); // Install the handler for the resize. this.Resize += new EventHandler(ResizeForm); }
bool IMessageFilter.PreFilterMessage(ref Message m) { if (null != ToolbarHost) { int lResult; int hr = ToolbarHost.ProcessMouseActivationModal(m.HWnd, (uint)m.Msg, (uint)m.WParam, (int)m.LParam, out lResult); // Check for errors. if (NativeMethods.Failed(hr)) { return(false); } // ProcessMouseActivationModal returns S_FALSE to stop the message processing, but this // function have to return true in this case. return(hr == NativeMethods.S_FALSE); } return(false); }