internal void OnHandleCreated() { if (_pane == null) { if (_panel == null) { _panel = new Panel(); _panel.Location = new Point(0, 0); _panel.Size = _form.ClientRectangle.Size; _form.Controls.Add(_panel); } _pane = new VSFormContainerPane(_form.Context, this, _panel); IVsWindowPane p = _pane; IntPtr hwnd; Rectangle r = new Rectangle(_form.Location, _form.Size); _form.Location = new Point(0, 0); if (!ErrorHandler.Succeeded(p.CreatePaneWindow(_form.Handle, 0, 0, r.Width, r.Height, out hwnd))) { _pane.Dispose(); _pane = null; return; } _form.Size = r.Size; _panel.Size = _form.ClientSize; IButtonControl cancelButton = _form.CancelButton; IButtonControl acceptButton = _form.AcceptButton; for (int i = 0; i < _form.Controls.Count; i++) { Control cc = _form.Controls[i]; if (cc != _panel) { _panel.Controls.Add(cc); i--; if (cc == cancelButton) _form.CancelButton = cancelButton; if (cc == acceptButton) _form.AcceptButton = acceptButton; } } _form.SizeChanged += new EventHandler(VSForm_SizeChanged); } if (!_loadRegistered) { _loadRegistered = true; _form.Load += new EventHandler(OnLoad); } }
public void Dispose() { if (_activeStack != null) _activeStack.Dispose(); if (_csCookie != 0 && _rPct != null) { _rPct.UnregisterPriorityCommandTarget(_csCookie); _csCookie = 0; } if(_panel != null) RestoreLayout(); if (_pane != null) { _pane.Dispose(); // Unhook _pane = null; } if (_panel != null) { _panel.Dispose(); _panel = null; } _map.Remove(_form); if (_installed) { VSCommandRouting cr = _routers.Pop(); Debug.Assert(cr == this, "Pop routing in the right order"); Application.RemoveMessageFilter(this); if (_routers.Count > 0) _routers.Peek().Enabled = true; } }