How to give the focus (back) to my Visual Studio tool window - visual-studio

My project is a Visual Studio Extension which has a tool window. The tool window contains a grid control. A line in the grid corresponds to some part of a source code file, XAML file, ASP file or WinForms UI.
When you click in a cell in the grid, I want to find the corresponding think in your project, open it, select it, but afterwards I want the focus to be in the cell where you originally clicked, in the grid, in my tool window.
This used to work, but it is not working in my current version, in particular after selecting text in a XAML file.
To select text in the XAML file, I
start with the ProjectItem
open the corresponding window
activate it with window.Activate()
get the TextDocument object
manipulate the TextDocument.Selection to select text
After that I set the focus back to my tool window, by
casting the ToolWindowPane to IVsWindowFrame
calling the show method IVsWindowFrame.Show()
possibly setting the focus to a specific control in my tool window (but that is not really relevant)
I have made (at least) three significant changes:
I am using Visual Studio 2019
I am using async and await at a lot of places (but still running on the main thread)
My top level control is now a WPF control. Formerly it was WinForms
Maybe Visual Studio 2019 is doing something asynchronous in the XAML window, which was previously synchronous. This might mean that I set the focus back to my tool window, but lose it again immediately.
Is there a better way to force the focus back to my tool window?
Alternatively, is there some event I should wait for, before calling IVsWindowFrame.Show()?

Related

MFC EditBrowse control does not display the folder icon at runtime

I have a dialog type application that includes a MFC EditBrowse Control. This control includes a folder/magnifier icon on the right side where the user is supposed to click to bring up a folder browser pop-up.
That folder/magnifier icon displays properly in the dialog editor within Visual Studio, but at runtime it displays as a plain flat button. It behaves properly otherwise - that is, the browser pop-up pops up and the selected folder is displayed when the user clicks OK.
When run with the debugger a message is displayed in the VS Output Window saying "Can't load bitmap: 4299". That message is displayed after the CDialogEx::OnInitDialog() line within my OnInitDialog().
I've written test programs and they display the icon properly. I've also added additional EditBrowse controls in my original program, but they experience the same problem and just add another line of "can't load bitmap". I've also added other MFC controls and some of them also do not display their icons (or other stuff).
I've managed to affect the problem slightly by making calls to EnableBrowseButton() and EnableFolderBrowswButton() from my OnInitDialog. If I do that, I get an icon that looks like 3 horizontal dots:
which is better, but I'd prefer the folder/magnifier icon.
It's a complicated enough application I'd rather not re-write it from the beginning and furthermore I'd like to understand what is going on. I'm fairly certain this is a result of adding/deleting controls as the app was developed, but don't have a good idea on where to begin tracking down where things went awry.
Thoughts on how to debug this? BTW, this is VS 2010.
CMFCEditBrowseCtrl uses the Visual Manager to load the bitmap from MFC resources.
This resource is loaded in "afxribbon.rc"
Make sure the following these lines are included in the main *.rc file (this is how VS Wizard creates the *.rc file)
#if !defined(_AFXDLL)
#include "afxribbon.rc" // MFC ribbon and control bar resources
#endif
(I guess you can omit the #if/end statement, but it's probably there for a reason)
Alternatively, CMFCEditBrowseCtrl::SetBrowseButtonImage can be used to assign user icon.

Is there a way to copy FormDesign appearance from one button to the next?

So I created a lot of buttons (a-z). Unfortunately, when I reopened the document later, they're all blacked out and I'm having to go through and individually change the buttons appearance one at a time.
Is there a 'format painter' of some kind in visual studio express so that I can just change one's appearance, then copy that over to each next button?
The Windows Forms, WPF and other UI designers in Visual Studio allow you to select multiple controls at once, by Ctrl+Click, Shift+Click or by dragging a selection ("rubber band") rectangle around the relevant controls.
Once you've done that, the properties editor displays those properties that the controls have in common. Changing a property changes it for all of the selected controls.

Add TabPages to Tab Control in Visual Studio 2010 Designer

I'm using Visual Studio 2010 Professional, and created a WTL Project (Dialog). In this dialog, I inserted a Tab Control via the Toolbox. However, after placing it on the dialog window in the Designer/Resource Editor, I just can't add any tabs. There are several issues:
In some video tutorials and the MSDN, it says that the Tab Control starts with two tabs, which switch when clicked. However, the Designer shows five tabs, which don't switch when I click them.
Aforementioned tutorials also suggest to edit the TabPages property in the property pane. However, I can't find such a property in the property pane.
When running the Test Dialog (found in the Format menu), the five tabs are visible, and they are also focused/switched when clicked. However, running the program, there's only the plain Tab Control pane without any tabs (white square).
How can I add a Tab into the Tab Control via the Designer, i.e. not dynamical?
Let's be good stackoverflowers and answer the question properly.
The visual basic tutorials do not show the same dialog resource editor you are using for your WTL project. Although, the video tutorial that is most closely related shows how to add a tab control using this editor; it does so by altering the MFC code. It runs the program to show the result; it does not show the tab inside the resource editor.
Thus, the conclusion is that tabs cannot be added using the dialog editor on its own.

How do I view Visual Studio BuildLog.htm files without cutting and pasting into an external browser

This may or may not be specific to VS2005 (as that is the version I'm referring to for this question).
I find often the case is that I see this in the Output panel inside Visual Studio
2>Build log was saved at "file://c:\\vsdll_example\MyExecRefsDll\Debug\BuildLog.htm"
Now, since that looks and smells like a URL, I would have thought that I could simply left mouse click on it, or left mouse double-click on it, and a browser window of some sort would be displayed. No, that doesn't work. So, to view it, I have to cut and paste the "file://bla/bla/bla" part into an external window.
Is there a way to set up Visual Studio to allow me to browse to that file directly, or view it inside Visual Studio IDE, or something to that effect, without the extra fiddling with cutting and pasting? Or is there some type of keybinding I'm not aware of?
Thanks,
bg
Hold down Control while clicking on the link. It should show up in the editor.

Visual Studio UI Improvement OCD Mode

I am wondering if anyone knows how to pull this off. Here goes.
I have a multi monitor setup, and I maximize Visual Studio to both windows. I create a new vertical document tab control, so that I have one document tab control in each physical screen. This is fine.
Now, I want to be able to make them work as if they were connected. I want to have the designer on one side, and the code related to the displayed designer on the other window.
I'd like it to have the following functionality:
If a item is double clicked on the solution explorer, open designer/code in both tabs.
When a document is selected in either pane, open appropriate file in the other pane.
Make the designer view refresh on edit, or periodically.
Any ideas on how I could pull this off?
Try to check (wait) for VS 2010 (beta now). There should be multi monitor support.

Resources