[英]Prevent Visual Studio automatically changes the configuration platform every time Solution is opened
[英]Visual studio automation: Enumerate opened windows upon solution loading
在使用宏加載解決方案時,如何枚舉打開的代碼窗口(即,用於編輯文檔的窗口)?
您可能知道,MSVS會記住已打開的文檔,即,在加載解決方案時,IDE將加載以前打開的文件。 我想做的是在加載解決方案時對那些窗口執行一些操作。
我試圖在SolutionEvents_Opened處理程序中訪問這些窗口。 但是沒有運氣-似乎提到的窗口在調用SolutionEvents_Opened時不可用。 DTE.Documents為空,DTE.Windows.Items不包含它們。
我需要一些代碼,例如:
Private Sub SolutionEvents_Opened() Handles SolutionEvents.Opened
Dim window As Window = DTE.Documents.Item(?).Windows // one of the opened windows
...
End Sub
我發現枚舉窗口的一種方法是在DocumentEvents.DocumentOpened事件上,但是它總是觸發它,而不僅是在加載解決方案的過程中。 根據我的經驗,SolutionEvents.Opened似乎不會被解雇,否則可以在其中更改靜態變量。
這也許可以幫助解釋它。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.