[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...
Save all the tabs and when the project is reopened they will be restored.
In options, you can limit the maximum width of the tab so that if there are very long names, it will not take up much space.
back buttons forward, or some simple way to navigate if you have many windows open.
I will use it for a longer time to test if I see more bugs and improvements.
greetings very good job
Last edited by yokesee; Jan 28th, 2021 at 06:26 PM.
Re: [Add-In] IDE Code-Pane Tabs for MDI/SDI (No sub-classing/hooking)
Originally Posted by yokesee
when loading the add-ins I get the following error:
Ah, my error-trapping on add-in connection picked up the infamous 'Method ~ of Object ~' error. It's supposed to ignore that error but I forgot to trap it in a more locale-neutral way. I've fixed that now.
Originally Posted by yokesee
improvements:
add a popup menu right click with:
close all
close all tabs on the right
close all except the active
Save all the tabs and when the project is reopened they will be restored.
Yes, they're already on my To-do list. I just forgot to mention them in my opening post.
Originally Posted by yokesee
In options, you can limit the maximum width of the tab so that if there are very long names, it will not take up much space.
Good idea...
Originally Posted by yokesee
back buttons forward, or some simple way to navigate if you have many windows open.
Already on the list, but for now you can Ctrl-drag the whole TabStrip to do this...
If you don't know where you're going, any road will take you there...
Re: [Add-In] IDE Code-Pane Tabs for MDI/SDI (No sub-classing/hooking)
Love it. Thanks for sharing.
One thing: Doesn't seem to remember the Form(Design) tabs when reloading.
May be intentional and not really a biggee since just dblclicking the form adds it to the tabstrip.
Re: [Add-In] IDE Code-Pane Tabs for MDI/SDI (No sub-classing/hooking)
Originally Posted by VBClassic04
Love it. Thanks for sharing.
One thing: Doesn't seem to remember the Form(Design) tabs when reloading.
May be intentional and not really a biggee since just dblclicking the form adds it to the tabstrip.
No, it doesn't at the moment. The next version will restore all the tabs, in their correct order, and all the open windows. Working on it as I type.
If you don't know where you're going, any road will take you there...
Re: [Add-In] IDE Code-Pane Tabs for MDI/SDI (No sub-classing/hooking)
Hi germano, Can you please elaborate? If you have an add-in that deletes the vbw file, then my add-in won't work? Are you saying that you'd prefer that it writes to a different file?
If you don't know where you're going, any road will take you there...
Commit 75a94d1 fixed tab-strip height when large icons toolbars setting is ON to auto-size to toolbar's full height. Tab icons became 32x32 pixels wide in this mode to match toolbar icons.
Blends with IDE by using current Window theme system icon font, not just Tahoma 8 pt as in initial implementation. Fixes right-click context menu not showing when right-clicking again while context menu is already shown.
There is a known bug with closing MDI child windows through context menu while current project is running. (Tab-strip becomes hatched because missing explicit error handler on the menu click event handler probably.)
There is a precompiled TabStripAddIn.dll binary in releases section of the repository.
Re: [Add-In] IDE Code-Pane Tabs for MDI/SDI (No sub-classing/hooking)
In fact, the simplest VB6 project is to develop a new interface. Because it provides the perfect way for plug-ins to operate.
Even if we minimize the original fertilizer, we can also control it by clicking on the menu.
It's just that it was windows more than 20 years ago, and it was a product in 1998.
There are a lot of problems with control.
The simplest thing is. Operation of hook vba6.dll
But if you repeat the same code, many of them will not execute the function.call
Re: [Add-In] IDE Code-Pane Tabs for MDI/SDI (No sub-classing/hooking)
I have downloaded the project from github, and there's a problem with Connect.dsr, the line delimiter is LF, like in Unix instead of CR LF like in Windows, is the only file with that problem
Re: [Add-In] IDE Code-Pane Tabs for MDI/SDI (No sub-classing/hooking)
Originally Posted by gilman
I have downloaded the project from github, and there's a problem with Connect.dsr, the line delimiter is LF, like in Unix instead of CR LF like in Windows, is the only file with that problem
The file is actually named Connect.Dsr with capital D.
This sucks big time as .gitattributes filemasks for end-of-line conversions are case-sensitive. Ouch!
Commit 75a94d1 fixed tab-strip height when large icons toolbars setting is ON to auto-size to toolbar's full height. Tab icons became 32x32 pixels wide in this mode to match toolbar icons.
</wqw>
Thanks for picking this up and running with it, wqweto.
If you don't know where you're going, any road will take you there...
Re: [Add-In] IDE Code-Pane Tabs for MDI/SDI (No sub-classing/hooking)
If you ever encounter this issue and nobody is around to update it, I successfully use WinHex to fix this. It has a 'Replace Hex Values' option under the Search menu, and you replace 0A with 0D0A in all the text-based files (.frm, .vbp, .ctl, .cls, .dsr) but not binary files (.frx, .ctx, .tlb, .res, etc). Choose 'Yes' when asked if you want to move the data (No will overwrite the next byte and corrupt the file)
Re: [Add-In] IDE Code-Pane Tabs for MDI/SDI (No sub-classing/hooking)
@wqweto - NOTE: GitHub mangling EOL chars again, so you must open Connect.Dsr and change EOL from Unix to Windows.
In Notepad ++ :
Edit > EOL Conversion > Windows CRLF
Re: [Add-In] IDE Code-Pane Tabs for MDI/SDI (No sub-classing/hooking)
Originally Posted by fafalone
I recently posted a utility to automatically correct the line breaks...
EDIT: CONGRATS ON YOUR 5,000th POST fafalone !!!
Thank you! It's going to be very useful moving forward, because github has 90% of the VB6 codes marked as "Visual Basic"...
I'm not sure if it is the author not selecting the right box or if it is just flat-out prejudism and racism and sexism against VB6.
I thought we were moving into a brave new world, but it seems github or the knuckleheads who post the projects just lazily select "Visual Basic" when they upload it?
Asking for a friend who actually cares about such trivial matters...
Last edited by taishan; Dec 15th, 2023 at 10:20 PM.