added some development tools
[windows-sources.git] / developer / VSSDK / VisualStudioIntegration / Common / Source / CSharp / LanguageService100 / EditorView.cs
blobb670e0aebbff971c4440ba5321ae199a4de00c07
1 using Microsoft.VisualStudio.OLE.Interop;
2 using Microsoft.VisualStudio.Shell.Interop;
3 using Microsoft.VisualStudio.TextManager.Interop;
4 using Microsoft.VisualStudio.Shell;
5 using System;
6 using System.Collections;
7 using System.Runtime.InteropServices;
8 using System.Windows.Forms;
9 using IOleServiceProvider = Microsoft.VisualStudio.OLE.Interop.IServiceProvider;
10 using IServiceProvider = System.IServiceProvider;
11 using ShellConstants = Microsoft.VisualStudio.Shell.Interop.Constants;
12 using OleConstants = Microsoft.VisualStudio.OLE.Interop.Constants;
13 using System.Diagnostics;
14 using System.ComponentModel.Design;
16 namespace Microsoft.VisualStudio.Package {
18 /// <include file='doc\EditorView.uex' path='docs/doc[@for="SimpleEditorView"]/*' />
19 /// <summary>
20 /// This class View provides an abstract base class for simple editor views
21 /// that follow the VS simple embedding model.
22 /// </summary>
23 [CLSCompliant(false)]
24 [System.Runtime.InteropServices.ComVisible(true)]
25 public abstract class SimpleEditorView : IOleCommandTarget, IVsWindowPane, IVsToolboxUser, IVsStatusbarUser, IVsWindowPaneCommit, IOleComponent // for idle processing.
26 //IServiceProvider,
27 //IVsMultiViewDocumentView,
28 //IVsFindTarget,
29 //IVsWindowFrameNotify,
30 //IVsCodeWindow,
31 //IVsBroadcastMessageEvents,
32 //IVsDocOutlineProvider,
33 //IVsDebuggerEvents,
34 // ??? VxDTE::IExtensibleObject,
35 //IVsBackForwardNavigation
36 // ??? public ISelectionContainer,
39 IServiceProvider site;
40 OleMenuCommandService commandService;
41 IVsTextLines buffer;
42 IOleComponentManager componentManager;
43 uint componentID;
45 /// <include file='doc\EditorView.uex' path='docs/doc[@for="SimpleEditorView.Site;"]/*' />
46 protected IServiceProvider Site {
47 get { return this.site; }
48 set {
49 this.site = value;
50 IOleCommandTarget parentTarget = null;
51 if (null != site) {
52 parentTarget = site.GetService(typeof(IMenuCommandService)) as IOleCommandTarget;
53 if (null == parentTarget) {
54 parentTarget = site.GetService(typeof(IOleCommandTarget)) as IOleCommandTarget;
57 if (null == commandService) {
58 if (null != parentTarget) {
59 commandService = new OleMenuCommandService(site, parentTarget);
60 } else {
61 commandService = new OleMenuCommandService(site);
63 } else {
64 commandService.ParentTarget = parentTarget;
68 protected IMenuCommandService MenuCommandService {
69 get { return commandService; }
71 /// <include file='doc\EditorView.uex' path='docs/doc[@for="SimpleEditorView.Buffer;"]/*' />
72 protected IVsTextLines Buffer {
73 get { return this.buffer; }
74 set { this.buffer = value; }
76 /// <include file='doc\EditorView.uex' path='docs/doc[@for="SimpleEditorView.ComponentManager;"]/*' />
77 protected IOleComponentManager ComponentManager {
78 get { return this.componentManager; }
79 set { this.componentManager = value; }
81 /// <include file='doc\EditorView.uex' path='docs/doc[@for="SimpleEditorView.ComponentId;"]/*' />
82 protected uint ComponentId {
83 get { return this.componentID; }
84 set { this.componentID = value; }
87 /// <include file='doc\EditorView.uex' path='docs/doc[@for="SimpleEditorView.SimpleEditorView"]/*' />
88 protected SimpleEditorView(IVsTextLines buffer) {
89 this.buffer = buffer;
92 #region IOleCommandTarget methods
93 /// <include file='doc\EditorView.uex' path='docs/doc[@for="SimpleEditorView.IOleCommandTarget.QueryStatus"]/*' />
94 /// <internalonly/>
95 /// <summary>
96 /// IOleCommandTarget implementation
97 /// </summary>
98 public virtual int QueryStatus(ref Guid guidCmdGroup, uint cmds, OLECMD[] prgCmds, IntPtr pCmdText) {
99 if (null == commandService) {
100 return (int)OleConstants.OLECMDERR_E_NOTSUPPORTED;
102 return ((IOleCommandTarget)commandService).QueryStatus(ref guidCmdGroup, cmds, prgCmds, pCmdText);
105 /// <include file='doc\EditorView.uex' path='docs/doc[@for="SimpleEditorView.IOleCommandTarget.Exec"]/*' />
106 /// <internalonly/>
107 public virtual int Exec(ref Guid guidCmdGroup, uint id, uint options, IntPtr pvaIn, IntPtr pvaOut) {
108 if (null == commandService) {
109 return (int)OleConstants.OLECMDERR_E_NOTSUPPORTED;
111 return ((IOleCommandTarget)commandService).Exec(ref guidCmdGroup, id, options, pvaIn, pvaOut);
113 #endregion
116 #region IVsWindowPane methods
118 /// <include file='doc\EditorView.uex' path='docs/doc[@for="SimpleEditorView.ClosePane"]/*' />
119 public virtual int ClosePane() {
120 return this.componentManager.FRevokeComponent(this.componentID);
122 /// <include file='doc\EditorView.uex' path='docs/doc[@for="SimpleEditorView.CreatePaneWindow"]/*' />
123 public abstract int CreatePaneWindow(IntPtr hwndParent, int x, int y, int cx, int cy, out IntPtr hwnd);
124 /// <include file='doc\EditorView.uex' path='docs/doc[@for="SimpleEditorView.GetDefaultSize"]/*' />
125 public virtual int GetDefaultSize(SIZE[] size) {
126 size[0].cx = 100;
127 size[0].cy = 100;
128 return NativeMethods.S_OK;
130 /// <include file='doc\EditorView.uex' path='docs/doc[@for="SimpleEditorView.LoadViewState"]/*' />
131 public virtual int LoadViewState(Microsoft.VisualStudio.OLE.Interop.IStream stream) {
132 return NativeMethods.S_OK;
134 /// <include file='doc\EditorView.uex' path='docs/doc[@for="SimpleEditorView.SaveViewState"]/*' />
135 public virtual int SaveViewState(Microsoft.VisualStudio.OLE.Interop.IStream stream) {
136 return NativeMethods.S_OK;
138 /// <include file='doc\EditorView.uex' path='docs/doc[@for="SimpleEditorView.SetSite"]/*' />
139 public virtual int SetSite(Microsoft.VisualStudio.OLE.Interop.IServiceProvider site) {
140 this.site = new ServiceProvider(site);
142 if (this.buffer != null) {
143 // register our independent view with the IVsTextManager so that it knows
144 // the user is working with a view over the text buffer. this will trigger
145 // the text buffer to prompt the user whether to reload the file if it is
146 // edited outside of the development Environment.
147 IVsTextManager textManager = (IVsTextManager)this.site.GetService(typeof(SVsTextManager));
148 int hr = 0;
149 if (textManager != null) {
150 IVsWindowPane windowPane = (IVsWindowPane)this;
151 hr = textManager.RegisterIndependentView(this, this.buffer);
152 if (!NativeMethods.Succeeded(hr))
153 Debug.Assert(false, "RegisterIndependentView failed");
157 //register with ComponentManager for Idle processing
158 this.componentManager = (IOleComponentManager)this.site.GetService(typeof(SOleComponentManager));
159 if (componentID == 0) {
160 OLECRINFO[] crinfo = new OLECRINFO[1];
162 crinfo[0].cbSize = (uint)Marshal.SizeOf(typeof(OLECRINFO));
163 crinfo[0].grfcrf = (uint)_OLECRF.olecrfNeedIdleTime | (uint)_OLECRF.olecrfNeedPeriodicIdleTime | (uint)_OLECRF.olecrfNeedAllActiveNotifs | (uint)_OLECRF.olecrfNeedSpecActiveNotifs;
164 crinfo[0].grfcadvf = (uint)_OLECADVF.olecadvfModal | (uint)_OLECADVF.olecadvfRedrawOff | (uint)_OLECADVF.olecadvfWarningsOff;
165 crinfo[0].uIdleTimeInterval = 1000;
166 int hr = this.componentManager.FRegisterComponent(this, crinfo, out this.componentID);
167 if (!NativeMethods.Succeeded(hr))
168 Debug.Assert(false, "FRegisterComponent failed");
170 return NativeMethods.S_OK;
172 /// <include file='doc\EditorView.uex' path='docs/doc[@for="SimpleEditorView.TranslateAccelerator"]/*' />
173 public virtual int TranslateAccelerator(MSG[] msg) {
174 return (int)NativeMethods.S_FALSE;
176 #endregion
178 #region IVsToolboxUser methods
179 /// <include file='doc\EditorView.uex' path='docs/doc[@for="SimpleEditorView.IsSupported"]/*' />
180 public virtual int IsSupported(Microsoft.VisualStudio.OLE.Interop.IDataObject data) {
181 return (int)NativeMethods.S_FALSE;
183 /// <include file='doc\EditorView.uex' path='docs/doc[@for="SimpleEditorView.ItemPicked"]/*' />
184 public virtual int ItemPicked(Microsoft.VisualStudio.OLE.Interop.IDataObject data) {
185 return NativeMethods.S_OK;
187 #endregion
189 #region IVsStatusbarUser methods
190 /// <include file='doc\EditorView.uex' path='docs/doc[@for="SimpleEditorView.SetInfo"]/*' />
191 public virtual int SetInfo() {
192 return NativeMethods.S_OK;
194 #endregion
196 #region IVsWindowPaneCommit methods
197 /// <include file='doc\EditorView.uex' path='docs/doc[@for="SimpleEditorView.CommitPendingEdit"]/*' />
198 public virtual int CommitPendingEdit(out int fCommitFailed) {
199 fCommitFailed = 0;
200 return NativeMethods.S_OK;
202 #endregion
204 #region IOleComponent Methods
205 /// <include file='doc\EditorView.uex' path='docs/doc[@for="SimpleEditorView.FDoIdle"]/*' />
206 public virtual int FDoIdle(uint grfidlef) {
207 return 0;
209 /// <include file='doc\EditorView.uex' path='docs/doc[@for="SimpleEditorView.Terminate"]/*' />
210 public virtual void Terminate() {
212 /// <include file='doc\EditorView.uex' path='docs/doc[@for="SimpleEditorView.FPreTranslateMessage"]/*' />
213 public virtual int FPreTranslateMessage(MSG[] msg) {
214 return 0;
216 /// <include file='doc\EditorView.uex' path='docs/doc[@for="SimpleEditorView.OnEnterState"]/*' />
217 public virtual void OnEnterState(uint uStateID, int fEnter) {
219 /// <include file='doc\EditorView.uex' path='docs/doc[@for="SimpleEditorView.OnAppActivate"]/*' />
220 public virtual void OnAppActivate(int fActive, uint dwOtherThreadID) {
222 /// <include file='doc\EditorView.uex' path='docs/doc[@for="SimpleEditorView.OnLoseActivation"]/*' />
223 public virtual void OnLoseActivation() {
225 /// <include file='doc\EditorView.uex' path='docs/doc[@for="SimpleEditorView.OnActivationChange"]/*' />
226 public virtual void OnActivationChange(Microsoft.VisualStudio.OLE.Interop.IOleComponent pic, int fSameComponent, OLECRINFO[] pcrinfo, int fHostIsActivating, OLECHOSTINFO[] pchostinfo, uint dwReserved) {
228 /// <include file='doc\EditorView.uex' path='docs/doc[@for="SimpleEditorView.FContinueMessageLoop"]/*' />
229 public virtual int FContinueMessageLoop(uint uReason, IntPtr pvLoopData, MSG[] pMsgPeeked) {
230 return 1;
232 /// <include file='doc\EditorView.uex' path='docs/doc[@for="SimpleEditorView.FQueryTerminate"]/*' />
233 public virtual int FQueryTerminate(int fPromptUser) {
234 return 1;
236 /// <include file='doc\EditorView.uex' path='docs/doc[@for="SimpleEditorView.HwndGetWindow"]/*' />
237 public virtual IntPtr HwndGetWindow(uint dwWhich, uint dwReserved) {
238 return IntPtr.Zero;
240 /// <include file='doc\EditorView.uex' path='docs/doc[@for="SimpleEditorView.FReserved1"]/*' />
241 public virtual int FReserved1(uint reserved, uint message, IntPtr wParam, IntPtr lParam) {
242 return 1;
244 #endregion
247 #if CUT
249 /// <include file='doc\EditorView.uex' path='docs/doc[@for="OleEditorView"]/*' />
250 /// <summary>
251 /// This class View provides an abstract base class for custom editor views that
252 /// support Ole Inplace activation (ActiveX controls).
253 /// </summary>
254 [CLSCompliant(false)]
255 [System.Runtime.InteropServices.ComVisible(true)]
256 public abstract class OleEditorView : SimpleEditorView, IOleCommandTarget, IVsWindowPane, IVsToolboxUser, IVsStatusbarUser, IOleObject, IOleInPlaceActiveObject, IOleInPlaceObject, IOleInPlaceComponent
257 //IServiceProvider,
258 //IOleDocumentView,
259 //IOleDocument,
260 //IOleInPlaceUIWindow,
261 //IVsMultiViewDocumentView,
262 //IVsFindTarget,
263 //IVsWindowFrameNotify,
264 //IVsCodeWindow,
265 //IVsWindowPaneCommit,
266 //IVsBroadcastMessageEvents,
267 //IVsDocOutlineProvider,
268 //IVsDebuggerEvents,
269 // ??? VxDTE::IExtensibleObject,
270 //IVsBackForwardNavigation
271 // ??? public IVsTextLinesEvents,
272 // ??? public ISelectionContainer,
273 // ??? public IVsTextBufferDataEvents,
275 internal EventSinkCollection eventSinks = new EventSinkCollection();
276 /// <include file='doc\EditorView.uex' path='docs/doc[@for="OleEditorView.pCompUIMgr;"]/*' />
277 protected IOleComponentUIManager pCompUIMgr;
278 /// <include file='doc\EditorView.uex' path='docs/doc[@for="OleEditorView.pIPCompSite;"]/*' />
279 protected IOleInPlaceComponentSite pIPCompSite;
280 /// <include file='doc\EditorView.uex' path='docs/doc[@for="OleEditorView.pClientSite;"]/*' />
281 protected IOleClientSite pClientSite;
282 /// <include file='doc\EditorView.uex' path='docs/doc[@for="OleEditorView.monikers"]/*' />
283 protected Hashtable monikers = new Hashtable();
284 /// <include file='doc\EditorView.uex' path='docs/doc[@for="OleEditorView.OleEditorView"]/*' />
285 protected OleEditorView(IVsTextLines buffer) : base(buffer) {
288 #region IOleObject methods
289 /// <include file='doc\EditorView.uex' path='docs/doc[@for="OleEditorView.Advise"]/*' />
290 public virtual void Advise(IAdviseSink sink, out uint cookie) {
291 cookie = eventSinks.Add(sink);
293 /// <include file='doc\EditorView.uex' path='docs/doc[@for="OleEditorView.Close"]/*' />
294 public virtual void Close(uint dwSaveOption) {
296 /// <include file='doc\EditorView.uex' path='docs/doc[@for="OleEditorView.DoVerb"]/*' />
297 public virtual int DoVerb(int iVerb, MSG[] msg, IOleClientSite site, int index, IntPtr hwndParent, RECT[] posRect) {
298 return NativeMethods.S_OK;
300 /// <include file='doc\EditorView.uex' path='docs/doc[@for="OleEditorView.EnumAdvise"]/*' />
301 public virtual void EnumAdvise(out IEnumSTATDATA ppEnumAdvise) {
302 ppEnumAdvise = null;
304 /// <include file='doc\EditorView.uex' path='docs/doc[@for="OleEditorView.EnumVerbs"]/*' />
305 public virtual int EnumVerbs(out IEnumOLEVERB ppEnumVerbs) {
306 ppEnumVerbs = null;
307 return NativeMethods.S_OK;
309 /// <include file='doc\EditorView.uex' path='docs/doc[@for="OleEditorView.GetClientSite"]/*' />
310 public virtual void GetClientSite(out IOleClientSite site) {
311 site = this.pClientSite;
313 /// <include file='doc\EditorView.uex' path='docs/doc[@for="OleEditorView.GetClipboardData"]/*' />
314 public virtual void GetClipboardData(uint reserved, out Microsoft.VisualStudio.OLE.Interop.IDataObject obj) {
315 obj = null;
317 /// <include file='doc\EditorView.uex' path='docs/doc[@for="OleEditorView.GetExtent"]/*' />
318 public virtual void GetExtent(uint dwDrawAspect, SIZEL[] size) {
320 /// <include file='doc\EditorView.uex' path='docs/doc[@for="OleEditorView.GetMiscStatus"]/*' />
321 public virtual int GetMiscStatus(uint dwAspect, out uint status) {
322 status = 0;
323 return NativeMethods.S_OK;
325 /// <include file='doc\EditorView.uex' path='docs/doc[@for="OleEditorView.GetMoniker"]/*' />
326 public virtual void GetMoniker(uint iAssign, uint whichMoniker, out IMoniker moniker) {
327 object key = (object)whichMoniker;
329 moniker = (IMoniker)monikers[key];
331 /// <include file='doc\EditorView.uex' path='docs/doc[@for="OleEditorView.GetUserClassID"]/*' />
332 public virtual void GetUserClassID(out Guid pClsid) {
333 pClsid = this.GetType().GUID;
335 /// <include file='doc\EditorView.uex' path='docs/doc[@for="OleEditorView.GetUserType"]/*' />
336 public virtual int GetUserType(uint formOfType, IntPtr userType) {
337 return NativeMethods.S_OK;
339 /// <include file='doc\EditorView.uex' path='docs/doc[@for="OleEditorView.InitFromData"]/*' />
340 public virtual int InitFromData(Microsoft.VisualStudio.OLE.Interop.IDataObject data, int fCreation, uint reserved) {
341 return NativeMethods.S_OK;
343 /// <include file='doc\EditorView.uex' path='docs/doc[@for="OleEditorView.IsUpToDate"]/*' />
344 public virtual int IsUpToDate() {
345 return NativeMethods.S_OK;
347 /// <include file='doc\EditorView.uex' path='docs/doc[@for="OleEditorView.SetClientSite"]/*' />
348 public virtual void SetClientSite(IOleClientSite site) {
349 this.pClientSite = site;
351 /// <include file='doc\EditorView.uex' path='docs/doc[@for="OleEditorView.SetColorScheme"]/*' />
352 public virtual void SetColorScheme(LOGPALETTE[] logicalPalette) {
354 /// <include file='doc\EditorView.uex' path='docs/doc[@for="OleEditorView.SetExtent"]/*' />
355 public virtual void SetExtent(uint drawAspect, SIZEL[] size) {
357 /// <include file='doc\EditorView.uex' path='docs/doc[@for="OleEditorView.SetHostNames"]/*' />
358 public virtual void SetHostNames(string containerApp, string containerObj) {
360 /// <include file='doc\EditorView.uex' path='docs/doc[@for="OleEditorView.SetMoniker"]/*' />
361 public virtual void SetMoniker(uint whichMoniker, IMoniker moniker) {
362 object key = (object)whichMoniker;
364 if (monikers.Contains(key)) monikers.Remove(key);
366 monikers.Add(key, moniker);
368 /// <include file='doc\EditorView.uex' path='docs/doc[@for="OleEditorView.Unadvise"]/*' />
369 public virtual void Unadvise(uint dwCookie) {
370 eventSinks.RemoveAt(dwCookie);
372 /// <include file='doc\EditorView.uex' path='docs/doc[@for="OleEditorView.Update"]/*' />
373 public virtual int Update() {
374 return NativeMethods.S_OK;
376 #endregion
379 #region IOleInPlaceActiveObject
380 /// <include file='doc\EditorView.uex' path='docs/doc[@for="OleEditorView.EnableModeless"]/*' />
381 public virtual void EnableModeless(int fEnable) {
383 /// <include file='doc\EditorView.uex' path='docs/doc[@for="OleEditorView.OnDocWindowActivate"]/*' />
384 public virtual void OnDocWindowActivate(int fActivate) {
386 /// <include file='doc\EditorView.uex' path='docs/doc[@for="OleEditorView.OnFrameWindowActivate"]/*' />
387 public virtual void OnFrameWindowActivate(int fActivate) {
389 /// <include file='doc\EditorView.uex' path='docs/doc[@for="OleEditorView.ResizeBorder"]/*' />
390 public virtual void ResizeBorder(RECT[] border, ref Guid iid, IOleInPlaceUIWindow window, int fFrameWindow) {
392 #endregion
396 #region IOleInPlaceObject methods
397 /// <include file='doc\EditorView.uex' path='docs/doc[@for="OleEditorView.ContextSensitiveHelp"]/*' />
398 public virtual void ContextSensitiveHelp(int fEnterHelp) {
400 /// <include file='doc\EditorView.uex' path='docs/doc[@for="OleEditorView.GetWindow"]/*' />
401 public virtual void GetWindow(out IntPtr hwnd) {
402 hwnd = IntPtr.Zero;
404 /// <include file='doc\EditorView.uex' path='docs/doc[@for="OleEditorView.InPlaceDeactivate"]/*' />
405 public virtual void InPlaceDeactivate() {
407 /// <include file='doc\EditorView.uex' path='docs/doc[@for="OleEditorView.ReactivateAndUndo"]/*' />
408 public virtual void ReactivateAndUndo() {
410 /// <include file='doc\EditorView.uex' path='docs/doc[@for="OleEditorView.SetObjectRects"]/*' />
411 public virtual void SetObjectRects(RECT[] posRect, RECT[] clipRect) {
413 /// <include file='doc\EditorView.uex' path='docs/doc[@for="OleEditorView.UIDeactivate"]/*' />
414 public virtual void UIDeactivate() {
416 #endregion
418 #region IOleInPlaceComponent methods
421 /// <include file='doc\EditorView.uex' path='docs/doc[@for="OleEditorView.FQueryClose"]/*' />
422 public virtual int FQueryClose(int fPromptUser) {
423 return 0;
425 /// <include file='doc\EditorView.uex' path='docs/doc[@for="OleEditorView.GetCntrContextMenu"]/*' />
426 public virtual int GetCntrContextMenu(uint dwRoleActiveObject, ref Guid clsidActiveObject, int nMenuIdActiveObject, POINTS[] pos, out Guid clsidCntr, OLEMENUID[] menuid, out uint pgrf) {
427 clsidCntr = Guid.Empty;
428 pgrf = 0;
429 return NativeMethods.S_OK;
431 /// <include file='doc\EditorView.uex' path='docs/doc[@for="OleEditorView.GetCntrHelp"]/*' />
432 public virtual int GetCntrHelp(ref uint pdwRole, ref Guid pclsid, POINT posMouse, uint dwHelpCmd, string pszHelpFileIn, out string pwsHelpFileOut, uint dwDataIn, out uint dwDataOut) {
433 pwsHelpFileOut = pszHelpFileIn;
434 dwDataOut = dwDataIn;
435 return NativeMethods.S_OK;
437 /// <include file='doc\EditorView.uex' path='docs/doc[@for="OleEditorView.GetCntrMessage"]/*' />
438 public virtual int GetCntrMessage(ref uint pdwRolw, ref Guid clsid, string titleIn, string textIn, string helpFileIn, out string titleOut, out string textOut, out string helpFileOut, ref uint dwHelpContextId, OLEMSGBUTTON[] msgbutton, OLEMSGDEFBUTTON[] msgdefbutton, OLEMSGICON[] msgicon, ref int sysAlert) {
439 titleOut = titleIn;
440 textOut = textIn;
441 helpFileOut = helpFileIn;
442 return NativeMethods.S_OK;
444 void IOleInPlaceComponent.OnEnterState(uint dwStateId, int fEnter) {
445 ((IOleComponent)this).OnEnterState(dwStateId, fEnter);
447 /// <include file='doc\EditorView.uex' path='docs/doc[@for="OleEditorView.OnWindowActivate"]/*' />
448 public virtual int OnWindowActivate(uint windowType, int fActivate) {
449 return NativeMethods.S_OK;
451 /// <include file='doc\EditorView.uex' path='docs/doc[@for="OleEditorView.TranslateCntrAccelerator"]/*' />
452 public virtual int TranslateCntrAccelerator(MSG[] msg) {
453 return NativeMethods.S_OK;
455 /// <include file='doc\EditorView.uex' path='docs/doc[@for="OleEditorView.UseComponentUIManager"]/*' />
456 public virtual int UseComponentUIManager(uint dwCompRole, out uint pgrfCompFlags, IOleComponentUIManager pCompUIMgr, IOleInPlaceComponentSite pIPCompSite) {
457 pgrfCompFlags = 0;
458 this.pCompUIMgr = pCompUIMgr;
459 this.pIPCompSite = pIPCompSite;
460 return NativeMethods.S_OK;
462 #endregion
464 #endif
465 /// <include file='doc\EditorView.uex' path='docs/doc[@for="EditorControl"]/*' />
466 /// <summary>
467 /// This class wraps a managed WinForm control and uses that as the editor window.
468 /// </summary>
469 [CLSCompliant(false)]
470 [System.Runtime.InteropServices.ComVisible(true)]
471 public class EditorControl : SimpleEditorView {
472 Control control;
474 /// <include file='doc\EditorView.uex' path='docs/doc[@for="EditorControl.EditorControl"]/*' />
475 public EditorControl(IServiceProvider site, IVsTextLines buffer, Control ctrl) : base(buffer) {
476 this.control = ctrl;
477 this.Site = site;
480 /// <include file='doc\EditorView.uex' path='docs/doc[@for="EditorControl.Control;"]/*' />
481 protected Control Control {
482 get { return this.control; }
483 set { this.control = value; }
486 /// <include file='doc\EditorView.uex' path='docs/doc[@for="EditorControl.ClosePane"]/*' />
487 public override int ClosePane() {
488 if (control != null) {
489 control.Dispose();
490 control = null;
493 return base.ClosePane();
495 /// <include file='doc\EditorView.uex' path='docs/doc[@for="EditorControl.CreatePaneWindow"]/*' />
496 public override int CreatePaneWindow(IntPtr hwndParent, int x, int y, int cx, int cy, out IntPtr hwnd) {
497 control.SuspendLayout();
498 control.Left = x;
499 control.Top = y;
500 control.Width = cx;
501 control.Height = cy;
502 control.ResumeLayout();
503 control.CreateControl();
505 //For some reason VS throws debug asserts if WS_MAXIMIZEBOX is set
506 //so we'll just turn off this window style here.
507 int windowStyle = (int)NativeMethods.GetWindowLong(new HandleRef(control, control.Handle), NativeMethods.GWL_STYLE);
508 windowStyle = windowStyle & ~(0x00010000); //WS_MAXIMIZEBOX;
509 NativeMethods.SetWindowLong(this.Control.Handle, NativeMethods.GWL_STYLE, windowStyle);
510 //End of workaround
512 NativeMethods.SetParent(control.Handle, hwndParent);
513 hwnd = control.Handle;
514 return NativeMethods.S_OK;
516 /// <include file='doc\EditorView.uex' path='docs/doc[@for="EditorControl.CommitPendingEdit"]/*' />
517 public override int CommitPendingEdit(out int fCommitFailed) {
518 fCommitFailed = 0;
519 return NativeMethods.S_OK;
521 /// <include file='doc\EditorView.uex' path='docs/doc[@for="EditorControl.FDoIdle"]/*' />
522 public override int FDoIdle(uint grfidlef) {
523 return 0;
525 /// <include file='doc\EditorView.uex' path='docs/doc[@for="EditorControl.OnAppActivate"]/*' />
526 public override void OnAppActivate(int fActive, uint dwOtherThreadID) {
528 /// <include file='doc\EditorView.uex' path='docs/doc[@for="EditorControl.FQueryTerminate"]/*' />
529 public override int FQueryTerminate(int fPromptUser) {
530 return 1;
532 /// <include file='doc\EditorView.uex' path='docs/doc[@for="EditorControl.OnLoseActivation"]/*' />
533 public override void OnLoseActivation() {
535 /// <include file='doc\EditorView.uex' path='docs/doc[@for="EditorControl.HwndGetWindow"]/*' />
536 public override IntPtr HwndGetWindow(uint dwWhich, uint dwReserved) {
537 return control.Handle;