[Add-In] IDE Code-Pane Tabs for MDI/SDI (No sub-classing/hooking)
Background
I'm not much of Add-In user, but my liking for a tabbed interface of open code windows has meant that CodeHelp has been a permanent fixture of my IDE for a few years now. Just recently, I thought I'd develop an Add-In of my own, and wondered if I could improve on the CodeHelp offering. Whether I have or not, will be a matter of personal opinion, as I only focussed on the things that I wanted to change, without regard for any features that I, personally, do not use.
Things I like about CodeHelp's tabstrip:
1) It's always available, whether in Design, Run or Break mode
2) You can re-order the tabs to your liking (although it's a bit clunky-feeling)
Things I don't like:
1) It has lots of sub-classing and hooking, which gives me stability concerns
2) You can't close a tab without activating it first
3) You can't re-order the tabs without first activating the tab you are moving
4) Sometimes the active tab gets out of sync with the active code pane
About my Tab-Strip
I tried, of course, to retain everything from my 'positive' list, whilst eliminating those that (to me) are negatives. I suspect that other users may have quite different lists, such as keyboard shortcut access, and so on. If so, I'd like to hear from you in the replies. Maybe I can then incorporate those features. Or maybe you can modify the code as you see fit...
Anyway, this add-in, as the title says, can be used in both MDI and SDI modes, and contains no sub-classing or hooking. Instead, it uses a simple polling mechanism which does two tests, every 125ms, essentially asking:
1) Has the active window changed?
2) Has the number of IDE windows changed?
If either of those is true, things get taken a step further and all of the windows are enumerated, and the tab-strip is updated if there are any recently-closed or newly-opened code/designers windows. All-in-all, this should be pretty IDE-safe, and is actually less process-intensive than testing Window messages as they come by. It is only a tab-strip after all, and just doesn't require the level of 'state-awareness' that hooking/sub-classing might afford.
So, here it is:
What Else?
I have commented out all the logging code, but if you need/want to turn this on, there is a hidden listbox in frmTabStripOptions (just resize the form to see it)
Oh, yes, the UserControl is perfectly re-usable outside of this Add-In, if you like it and want such a thing.
Known Issues
MDI Only
None, yet, but I'm sure somebody will find one!
SDI Only
Window captions for Forms are not in the format 'Project - Component' but, instead, show the caption property for the form. As such, any caption re-naming is not picked up as part of the polling process. This could be addressed, but just doesn't seem worthwhile, at least not to me.
Both
Because the Tab-Strip is hosted by a regular Office toolbar, it is possible to drop another toolbar on top of it. Not sure anything can be done to prevent this behaviour.
When pressing F5, all designer windows are immediately closed (normal behaviour), but the same is not true (at least not consistently) for the Object Browser, which seems to sometimes remain open and sometimes get closed. As such, the tabstrip might occasionally show a tab for a non-existent Object Browser window, depending on when the IDE chooses to destroy it (if at all), and whether or not it was the active window when F5 was pressed.
UPDATE: 1st Feb 2021
New version available, with the following improvements:
TabStrip now handles 'overflow' via two scroller buttons, at either end. Mouse-down for continuous scroll, or right-click to jump to either end. (You can still Ctrl-Mouse-down to sroll the control, as an alternative)
Menu options available upon right-click of tab, to bulk-close windows (all to right, all to left, all but this one, all designers, all)
Option to maintain VBW file, which will restore tab order when a project is next re-opened. Note that this ony works when a project is launched with the IDE (for example, when a vbp file is double-clicked), because there is no reliable way (via the built-in events) of determining when a project has fully loaded.
TabStrip is less 'intrusive' when closing and opening projects (all re-draws and updates are suspended when it is observed that there are many window changes, all at once)
An options form is available from the IDE's 'Add-ins' menu, to cover other behavioural aspects of the TabStrip
UPDATE: 3rd Feb 2021
The 'Ensure tab is visible' setting behaved a bit over-zealously in certain situations! Fixed that and a couple of other obscure bugs that nobody would ever have encountered.
Last edited by ColinE66; Feb 3rd, 2021 at 12:09 PM.
If you don't know where you're going, any road will take you there...