/////////////////////////////////////////////////////////////////////
// 2xExplorer R7 "Ninja"
// Program upgrade, 18 November 2000


NEWS AT A GLANCE ----------------------------

* Command execution from the addressBar
* Batch file generator with counters
* Trick item selection
* Smart docking toolbars
* Thumbnail bar
* More bookmarks
* Layout manager
* Right dragging and other details...

---------------------------------------------


Comrades,

They say that classic masterpieces are better left alone. What can be done (say) for the ancient architectural marvel known as "Parthenon" that would add value to the package? (a water-proof roof perhaps? :). Such sombre thoughts tormenting my encephalus, I was at a loss trying to figure out what to add on a near-complete package as 2xExplorer. My mood wasn't significantly improved when the notebook I was using packed-in on me, either (read on for the chit-chat). 

Still, thanks to your suggestions and my not-so-chemically-unaided inspirations, I think we've come up with a decent upgrade package here, well worth your download time expense. That's the only expense you're likely to endure, since 2x is still free like the air you breathe. Let me remind you here of my request to REGISTER yourselves if you are regular users, by sending me an e-mail as described in the Help | About box. It's easy as A-B-C and it will get you up-to-date with any future developments on the 2x project --- and will keep my venture kapitalists happy ;). Das Kapital!
(NB. if you have registered yourselves in the past, don't bother repeating for this latest version)

You may have noticed that the 2xExplorer distribution archive now includes a file called "Licence.txt". Except for the standard disclaimers it also mentions the new scheme for user DONATIONS. Now there is a way for you to show your support for 2xExplorer, by making a small (or big :) voluntary donation online. Keep the author happy, show your appreciation for all the hard work he puts into this project! Thank you.

Before I proceed to the description of the new additions and/or improvements, let me elaborate on the code-name of the latest 2xExplorer. Arguably, "Ninja" is a term devoid of all relevance to a software application like 2x. Before you dismiss it as daft though, allow me to remind you that I could have done much worse by baptizing it "Tractatus Logico-Philosophicus" or something. Considering the wealth of possibilities it wasn't an altogether failed decision, innit? <g>


1. COMMAND EXECUTION ----------------------------

It's getting very busy in the Address bar. The newest offering is command execution, like in the old dayz of NC that old hands among you will surely remember. By "command" I refer to any program, be it Win32 or DOS, which is in the search path. There are "two" (read on to see why) commands in the Tools menu to activate this feature, but you don't really need them. All you have to do to run something is to press <Shift-Tab> to activate the address bar as usual, and key-in one of the special '>' or '$' characters at the beginning of the line, so as to let the bar know that your input is not to be confused with a path or visual filter.

This feature is similar to the "Run..." item in the Start menu, but the really kool bit and main benefit is that you can copy items from the active pane onto the command line, e.g. for providing arguments to the program about to be run. Simply use <Ctrl> with the arrow keys to move the focus within the active pane and press <Ctrl+Return> to copy names onto the command line. Just like NC --- those where the dayz, eh? Going one step further, the $L and $R constructs can be used in place of the full pathname of the left and right panes respectively (as used in building batch files). Don't forget to enclose these in quotes (e.g. "$L") in cases where paths contain spaces.

The environment of the launched program is that of the active pane, i.e. the current directory (if any) is where you happen to be browsing. The environment is also affected by the settings in the "autoexec.bat" (now there's a dinosaur!). You may as well patch up the PATH environmental variable if you want 2x to search in some dark corner of your hard disc.

Let me explain why there's the need for two Run commands, a plain "vanilla" and a DOS version. I thought that that jack-of-all-trades, the ShellExecute() API (geek alert! <g>) was good for all one's launching needs, but it wasn't to be. There are some old DOS commands like "dir", "ren" et al., which are not executable programs, but are internal commands of the MS/DOS interpreter "command.com". Hence you can't run these independently --- fooBar all. Moreover, it is these commands that are of more utility in the 2x run bar, since if you wanted just to launch programs you could have used the system Start | Run command, saving me the programming trouble at the same time <g>.

To cut a long story short, if you want to run DOS-related stuff, and especially the internal commands, you'd have to resort to <F10> (or type the '$' prompt character yourselves). This will launch an instance of command.com and pass your command line to the said stone-age interpreter. This is capable of running normal windows applications, too, but it's a tad inefficient, so enter the vanilla run command prompted by the '>' character. This will launch a win32 program directly, and is also capable of dealing with external DOS executables like e.g. XCopy.exe.

You may have noticed that both run commands share capabilities, so why am I causing such a racket? Well, I wasted a couple of days researching the MSDN about this issue so I thought I'd pass something on to you <g>. The DOS version ('$'-prompted) is good for internal DOS commands, plus it will automatically substitute environmental variables like %WINDIR% and stuff. The other one ('>'-prompted) is faster, but it will only handle programs within the PATH variable --- or those that lie in the current directory, of course. The downside for both items is that they won't run programs which lie outside the search PATH, even monsters like "winWord" which the standard Start|Run would find no problemo. So you may need the standard windows item after all! (here you'll find the <WindowsKey+R> shortcut handy). Or if you just hate mikro$oft <g>, you may specify something like "> start winWord" in the 2xExplorer address bar, which WILL locate the program even if it ain't declared in the PATH.

And as if all that was not enough to cause a headache to the bravest among you, here are a couple of variables 2x keeps in the registry to control exactly how to launch programs from the address bar, under the "HKEY_CURRENT_USER\Software\ZabaraKatranemia Plc\2xExplorer\MainFrame Settings" key:

szDosCmdPreample = "command.com /K " (note trailing space; for NT this is 'cmd.exe')
szShellCmdPreample = "" (empty)

If you want to change the behaviour of the '$' or '>' launchers you need to use regEdit to change the respective values, after you exit 2xExplorer. These are the "preambles" that 2x prepends (behind your backs :) to each command you execute, but now I gave away the secret you can play with them to suit your needs. Possible suggestions are using "command.com /C " for DOS commands, which won't leave the window open after the program ends (but don't blame me if you don't manage to read the output!), and using "start " as the normal command preamble, which will overcome the PATH problems mentioned above, but it will delay the launching somewhat, since now the 'start' program will be run first. On the positive side, the '>' executor will automatically close any ensuing MS/DOS window if there's no output generated, but it will be smart enough to let it hang about, if there's something for you to read. Oh-me-gawd, all this has taxed me brain stiff...


2. BATCH FILE GENERATION ------------------------

The general consensus about the GenerateBatch <Ctrl+B> command is that it is best used for mass renaming files, using the $N/$B/$E constructs. A little bit of research in the mass-rename market has revealed that the trickest of such programs support counters, for automatically generating filenames like copy01, copy02, etc.

I regret that all such programs are nowforth redundant since 2x supports smart counters for its batch files. Running the risk of being accused of over-praising my achievements <g>, the way 2x implements counters is amazingly simple and powerful at the same time. With the simplest of constructs, you can specify both the starting value and the formatting of a counter. Some practical examples will help clarify things:

[*] "$1" is the simplest of counters, starting at 1 for the first command line generated, and increasing by 1 for every subsequent line. This will generate names like name1, name2, etc.

[*] "$01" is one level up, starting at one and being incremented by 1, as in the previous example. The difference is that it will prepend a zero if the number is less than two-digits wide (i.e. <10), generating sequences like name01, name02, ..., name11, and so on. If you need more leading zeros just use something like "$001" or higher.

[*] "$0012" will start counting at 12 (if so sir/madam pleases <g>) and will generate fields with 4 digits, adding leading zeros as necessary. Sequences like name0012, name0013, ..., name1234 are likely.

The procedure is very simple, and at any rate much simpler than proving the Taniyama-Shimura conjecture #LOL#. Only the finest "tsipouro" (NB: home made alcohol, "ouzo"-ish albeit stronger) will allow inspirations of that grand calibre.

Naturally, you can use such counters in any context, not just for mass-renaming files (e.g. teaching some youngster elementary arithmetic :). Let me also remind you that since the batch files generated are ultimately executed within a MS/DOS command interpreter, you may also use environmental variables like %WINDIR% in your templates, and/or set your own temporary variables using the "set" command. Not exactly as agile as UNIX scripts, but they're still useful.

Recently I have developed a taste for the "new" (for me at least) "batch" files for a modern era, which use the windows scripting host. These kinds of things really mount a challenge for UNIX scripts, since they are written in "proper" languages like VBS or javaScript. On the downside, they lack the simplicity of old batch (*.bat) files, plus mikro$oft ain't putting a big show about them (poor documentation, too), just in case they scare some granny from buying their internet-centric computers. Anyroad, I'm thinking about adding features in 2x in the future, taking advantage of this scripting functionality. Anybody with any ideas/recommendations on this issue, why don't you give us a shout?


3. EFFICIENT ITEM SELECTION ---------------------

2xExplorer selection engine gets another boost, by a couple of simple ideas. The first is selection refinement. Usually, when you specify a selection pattern in the Mark | SelectGroup dialog, it is meant to be applied to all the items visible in the active pane. By checking the new "Within current selection only" option in the said dialog, it is now possible to select only among the items that are already selected. For example, if you have already selected all your "*.cpp" files and you want to refine your selection to files that begin with (say) 'a', check the option described while specifying the "a*" pattern in the dialog. This will select just the "a*.cpp" files, not any old file whose name would otherwise match the "a*" wildcard.

Even more powerful is the introduction of negative filtering. Until recently you could specify multiple selection filters in 2x (e.g. "*.cpp, *.h") but all the comma-separated elements were considered in the positive sense. From now on you can prepend any sub-string with a minus '-' sign to indicate that you want to exclude this kind of filename from the selection. For instance, the "*.cpp, -a*" filter will select all files having ".cpp" extension but exclude those among them whose names begin with 'a'. (NB: You shouldn't leave any space after the leading minus).

Some clarifications are in order. Any exclusion filter in 2x is considered within some "positive" group. The idea is to exclude files out of some larger group of files, as the previous example demonstrated. On the other hand, it would be nonsensical for the positive/negative filters to correspond to disjoint sets, as e.g. "*.cpp, -*.h"; there are no "*.h" files to be excluded in the "*.cpp" group. The only exception is when you specify only exclusion filters like "-*.ncb, -*.aps", where it is implicitly assumed that the positive set comprises all the files in the pane, i.e. it is equivalent to the filter "*, -*.ncb, -*.aux". This is a quick way to select all but a few files.

To summarise, a filename matches a composite filter if it matches at least one regular (positive) sub-pattern, and at the same time doesn't match any of the negative sub-patterns. The exclusion principle can be used in any place within 2x that multiple wildcard filters are supported, as within FindFiles <Ctrl+F> command, FindInFiles <Ctrl+G>, etc. It can also be used for unselecting files, if you are the kind of person who is attracted to conundrums and/or enjoy the tombRaider series <g>.


4. SMARTER TOOLBARS -----------------------------

Leaving the realm of power-user additions, here's an improvement that will be appreciated by all but Mr.Gate's grandma. The previous RR-t version toolbars were not very flexible. Both the Address and Tree bars would selfishly bogart all the available frame window edge space they happened to be docked on. This arrogance forbade ingenious and space saving toolbar arrangements, that some of you may have attempted.

Fear not, coz I took the said offenders to a toolbar rehabilitation course <g> that eventually taught some manners to their unruly personalities. From now on they will consider other bars that may happen to be docked on the same edge, filling up only the remaining space, leading to a much more civilized organisation. So you can unleash your imagination and drag/drop/dock about bars for a more efficient workspace layout. The most ingenious arrangement will earn a place in history, since I plan to publish a snapshot in the website. So if it's fame that you're after, start dragging!

Big bas****s like the treeBar may be a handful to drag about, especially if you want to switch from having them docked vertically to horizontally (or vice versa), but there's a trick up your sleeve. It may help to force them in a temporary floating position, holding down <Ctrl> (or double-kliking on the titlebar). Once floating, resize them to a small-ish size and finally drag them to their intended destination window edge. You'll find that they'll get much more cooperative.

As you may have guessed, this seemingly simple feature was the hardest to program. Some ready-made dockBar classes in KodeGuru were too risky to adopt, using many undocumented features for my liking. So I started from scratch and created my own C++ class, using the minimum possible number of interventions in the undocumented MFC internals. That should keep the bugs to a minimum.

At any rate, I thought to meself, the development effort for trick sizing dockBars would come handy for hosting image preview thumbnails... What thumbnails? Read on.


5. THOSE THUMBNAILS -----------------------------

#ifdef _GOSSIP_SEGMENT

Chances are that you already know about the thumb control introduced in the windows explorer ever since win98, which shows a preview of many kinds of graphics (and html) files. I was planning to insert this functionality in this version of 2x for some time now, done my research, read the newsgroups and all, and all was clear in my mind. It was just a case of sitting down and writing some code, or so I thought. In fact I was so certain that I had it in the bag that I left it for the end, after I'd dealt with more demanding tasks.

Yeah, right... So where is all this IExtractImage COM stuff I read about? Not only I couldn't find anything in the Visual Studio 6.0 (including header and help files), it seemed that the said interface was not even registered in my win98/SE computer. Damn! I'd spent around 2 weeks developing the docking toolbar framework for accommodating this very thumb control and now I couldn't find its whereabouts. What a waste! I was feeling so gutted, I was contemplating the deletion of all 2xExplorer source code, and smashing the bleedin' computer, too.

Mind you, there was no need for my personal intervention. Adding insult to injury, the notebook computer I was using decided to tie itself in knots, robbing me of the joy of breaking it up meself (this whole affair sounds like some soap-opera, dinnit? --- but that's what happened, trust me). Dell me ARSE! 2000+ pounds sterling pile of pentium III shite. My old trusty 486 never missed a beat in over 3 years I was using it, until it was honorarily dismissed from service. Now this flash piece de kak, run amoc at the rate of 600MHz to its eventual downfall. First the LCD screen started playing up, then the keyboard began to miss every other keystroke, followed by a general GPF in all departments. Dell sucks !!! @:'(*&%&*^%$&***%$$@@@. It's not just their customer support that is ridiculous; their machinery is foul, too. To give you a better idea folks, we're talking about a computer here that I couldn't even switch on when I first took it brand-new out of the box (the whole motherboard had to be changed back then). How could such a small "detail" had been missed by "quality control" in Dell beats me. If I were a strategy advisor over in Dell, I'd take half the personell and open an asbestos removal department. Eff!

Cursing aside, the reality was that I was stuck in a jungle called Greece, with knackered machinery. No chance of calling the repairMan until I got back to base in London --- perhaps a refuse collector would be more appropriate <g>. The "worry" was that if I didn't complete the 2x upgrade while in "holidays", it would be delayed indefinitely due to the workload that expected me back in the UK. Fortunately I managed to save the source code on a floppy disc, so I didn't lose much work. I found some old nail to continue working on, too (thanks bro).

It seemed that the rougher part was already behind, but I was still facing an impasse on the technical front. Poised to discover how the explorer pulled its thumb stunt, I peeked and I poked, digging up the elusive ThumbCtr component. Of course this was a big change of plans, since originally hosting a self-contained OLE control in 2x was out of the question --- this ain't visual basic, Jim <g>. For starters, the executable packed up the lard since the control container framework added about 50kB. A single function call, AfxEnableControlContainer(), was responsible for all this added fat.

To be honest, if it just was for adding 10% more size on 2xExplorer.exe, I wouldn't worry too much and would have left the VB-friendly thumb control in place, despite risking the contempt of peer C++ fellows. But the story wasnae over yet. You see, when I'd tried the thing on windows 2000, no thumbs were available. Summat to do with windowless ActiveX controls caused loads of commotion in the newsgroups, but the verdict was that MFC just don't mix it with these types. It's cases like this that makes one wonder whether MFC has a future, or whether mikrosoft has already pulled the plug, failing to update the framework for such latest COM trix. Philosophy aside, sticking with the thumb control would lose me all the modern 2000-based clients, landing me a slap on the wrist by the investors/stock holders. Dead end, call for the asbestos removal people.

Back to basics then. Thanks to Dennis, a registered 2x benefactor, who has a real job and recent copies of platform SDK delivered to his door, I managed to locate the elusive IExtractImage interface for manual thumb extraction. This involved a bit more work from my part, but you can all reap the benefit in terms of speedier operation. Not to mention that the executable reverted to a sleek size which is now only marginally higher than the previous RR-t version. But as you can tell from all the above, it wasn't a walk in the park. But we enjoy challenges over here, don't we? <g>

Anyroad, in the end order was restored. Now 2x sports this thumbnail control that will show a preview of many graphics files (bmp, jpg, gif, etc.), even office documents and HTML files! --- now I know why mikrosoft ditched the quickView thang from windows 2000. It works like in the standard explorer, i.e. when enabled it will automatically show a preview of the focused file in the active pane, if the item has one. The control is hosted in a dockable/sizing bar like the treeBar. Perhaps most of you will find that it is most convenient when floating, where it's size can be freely customised without affecting the layout of other toolbars. 

#else

[The short version of all the babble above is that now 2xExplorer can show thumbnails for many image files, in a fashion similar to the standard (web-enabled) windows explorer. Note that this feature requires active desktop installed, thus some earlier win95 users may not have these thumbs.]

#endif // _GOSSIP_SEGMENT

Finally, note that 2x unleashes the true potential of this control, which is rather under-used in explorer's web view, limited to a fixed small-ish size. If you experiment with sizing, you'll discover that in 2x you can have it large enough to preview quite large pictures, without any significant performance penalty.

By default 2xExplorer will impose a limit to file sizes whose thumbnails are read to 1MB. If you want to generate thumbnails for larger files (e.g. large bitmaps) you'll have to manually edit the registry after quitting 2xExplorer, and fiddle with a variable called 'nMaxFileSizeThumb' (under the MainFrame Settings key) which controls this limit. If you set this variable to 0, then there won't be any size limit whatsoever. But keep in mind that large files take time to load etc.


6. MISCELLANEOUS IMPROVEMENTS -------------------

MORE BOOKMARKS. The measly one and a half bookmarks of the old version have been chucked for a new menu-based yet effective set of 6 bookmarks. Use <Ctrl+Shift+#> to set at the current folder browsed (where # stands for a number from 0 -> 5). Then use the simpler <Ctrl+#> to go to the folder bookmarked earlier at slot #. EZ. The current framework could easily accommodate up to 10 bookmarks, but I thought that people would have trouble remembering exactly which number corresponded to which folder, so I settled for just the 6 (the whole menu now is stand-alone for easier access, too). I recommend using bookmark #5 to a folder that contains shortcuts to other favorite folders, if you need more bookmarks. By the way, all bookmarks are now shared between the two panes and the old <F10> shortcut has been assigned to a different command.

LAYOUT MANAGER. Why, with all these toolbars and possible arrangements, I thought to meself that this gizmo would come in handy. This new submenu in "View" menu will hold up to 3 different window configurations that include layout info for window size/position, toolbar arrangement (sizes, dock state, etc.), left/right pane widths and view styles (details, large icons, etc.). Hence you may have one layout for (say) previewing images, where the thumb bar will have a prominent role, another for when you want just one pane for minimum screen size, yet another layout for when the window is maximized, but that's the furthest you may go since the infrastructure doesn't support more than 3 saved layouts. Simple keyboard shortcuts <Ctrl+7> to <Ctrl+9> make switching between different layouts a doddle. "Saving" a layout is only marginally harder since you'd just have to keep <Shift> pressed at the same time, in a mechanism similar to the setting of bookmarks mentioned earlier.

COMMAND AND FILTERS HISTORY. With so many things now entered in the address bar, the drop-down portion is not enough for keeping track of items previously typed. 2x retains visual filters and "run" commands entered in the address bar separately, and offers access to these older items using the new <Ctrl+H> and <Ctrl+F10> commands, respectively in the Files and Tools menus. We waste nothing round here.

RIGHT-DRAGGING SUPPORT. My standard defence for the lack of right-dragging in 2x until recently, was that most things can be achieved using normal left-dragging with keyboard modifiers, as explained in "Keyboard.txt". Still I admitted that there are items shown in the popup menu after right-dragging that are not accessible in any other way. What pops to mind is that all singing/all dancing glorified nuisance called WinZip that creeps in all things shell. IMHO winZip is inferior to WinRAR (thanks yoop winrar.com for the free registration and the expenses-paid holidays to Easter Island, for this grey advertising :) by a long way. But being the self-sacrificing individual that I am, I decided to throw in the right dragging support regardless.

QUICK-TOGGLE VISUAL FILTER. I likes this one; pure, simple and effective. This new command provides a menu item, toolbar button and a shortcut <Ctrl+J> to quickly toggle on/off the visual filter that controls which types of files are displayed in a pane. It allowes one to switch quickly between a valid filter (e.g. "*.exe,*.dll" for executable files) and no filter at all. The real boon is that even after you switch filtering off, the last non-trivial filter will be remembered and can be reinstated with a simple click on this toolbar button (or by hitting <Ctrl+J> et al.). You can even change the inactive pane's filter this way, if <Alt> is pressed, as usual. Now let us hope that this feature will help users avoid the pitfalls of the "*.*" versus "*" visual filter.

SWAP PANES COMMAND. Does exactly what it says on the tin. I think that the shortcut <Ctrl+U> was the same in NC. Of course I could be mistaken as I was never a fan of this feature. This one for those who couldn't disagree more <g>.

FREQUENTLY ASKED QUESTIONS. A new item in the Help menu will bring up a list of all the FAQ about 2x. If you have some question, chances are that it will be already included in the faq.txt file, solving your troubles presto. Keep in mind that there's a FAQ page in the website, too, which may be more up-to-date, for you to consult.

RENAME FILES SHORTCUT. This will cause some controversy, but after the "outrage" (behave! :) expressed by many users, I decided to swap the <F2>/<F7> keyboard shortcuts. Now <F2> renames files as in explorer, whereas <F7> creates text files. I regret any inconvenience that this may cause. Let me take this opportunity for giving another free plug for some brilliant piece of software called "Resource Hacker" (http://rpi.net.au/~ajohnson/resourcehacker). The most adventurous among you can use it to change resources and save them back directly in the executable file. One possible use is to change the keyboard shortcuts of 2xExplorer. It ain't a piece de cake, but it can be done --- be careful though. Please don't ask me how to do it... ResHacker comes with a help file that should explain things.

SINGLE CLICK TREE SELECTION. Another hell-raiser this one... Well, I regret all the inconvenience you have endured from this double-oversight of mine (and indeed all this time wasted in the extra click, which will have no doubt risen to millisecond heights by now ;). Let me just remind you youngsters that not too long ago, "mice" were just household pests that startled womenfolk, and us real men had to type our arses for a living in text-based command line "interfaces".

AUTO-SORT ITEMS AFTER REFRESH. The last item in the top-nag list of 2x users. See, I thought that placing all new files e.g. copied in some directory bunched together in the end of the list would be more "revealing". Obviously I was alone in this fantasy <g>. Now View|Options property page sports a check box that controls this exact behaviour in 2x. I guess I'll be the only 2x user to keep this option OFF, but then again I was never your average mainstream bloke :). Keep in mind that auto-sort after every refresh (i.e. after each copy/move/rename/whatever) is bound to be accompanied by some performance penalty.

FLAT TOOLBARS OPTION. I had some free space left in the View | Options property page after the addition of the previous item, so I thought I'd drop this option in. Mind you, I might have just as well left it empty, coz this new flat fashion is definitely disgusting IMHO. Yech! I'll stick with the bubbly stuff meself. By the way, I don't think you can have flat toolbars if you have win95 without some recent (4.x +) version of Internet Explorer.

PROGRESS BAR. You can now get some indication of how long a lengthy operation is going to take until completion, by this crafty progress bar that pops up in the status bar. That should make the long delays of <Alt+F9> and <Ctrl+G> commands a tad more bearable. Between you and me, it's just a gimmick really.


Adding this and that, the source code has crept up to a sizeable 961,919 bytes (at the time of going to press) spread among 66 files. That's 24,031 lines to you, a veritable monster.

Cheers,
Nikos

Packing Heat
(so that you don't have to)


-------------------------

2xExplorer website: http://personal-pages.ps.ic.ac.uk/~umeca74/
