Restoring windows in [Design] mode when solution is opened #423
Unanswered
RobertvanderHulst
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
For our custom language (X#) we also support the Windows Forms Editor.
When a user closes a solution that has a window in design mode (which you can recognize with Form1 [Design] for example, then when re-opening the solution the windows in design mode are not reopened properly.
You do see the document tabs with "Form1 [Design]" and "Form2 [Design]" but the contents of these tabs is not properly shown.
You see an error message such as this one:
We have now added an event handler to our solution that runs from the Toolkits OnAfterBackgroundSolutionLoadComplete event and inside that event handler we enumerate the document windows with
var documents = await VS.Windows.GetAllDocumentWindowsAsync();
and then detect the windows that are in design mode by inspecting their captions.
For the windows in design mode we get the filename by querying for __VSFPROPID.VSFPROPID_pszMkDocument and we close these with
await doc.CloseFrameAsync(FrameCloseOption.SaveIfDirty);
Afterward we open all the windows that were closed by us again specifying that we want to open them in Design mode.
We have a helper method that takes care of that.
VsShellUtilities.OpenDocument(ServiceProvider.GlobalProvider, file, VSConstants.LOGVIEWID_Designer, out _, out _, out _);
This works and looks great, if and when the current selected document is a 'normal' source code document.
When the selected document is in design mode then the enumeration of the documents does not return all the windows that are open in design mode.
I have 2 questions:
Beta Was this translation helpful? Give feedback.
All reactions