Change File Type 96 r3

by Jack Mathews

Well, I think that the title makes this app pretty self explanatory.  Basically, its a Windows 95 Shell Extension that takes advantage of the Windows 95 Shell, including obtaining shell icons and reading the registry for File Types.  

WHAT'S NEW?  Check the version history at the bottom of the document.

Installation and Uninstallation

	First, of course, you must run the Setup program.  This creates the file "FILETYPE.DLL" in your Windows System folder.  It then registers the shell extension and its uninstallation in the registry..  You can delete setup then if you like.  The uninstall can be found under Add/Remove Programs in the Control Panel.  You don't need the setup file to uninstall and every remnant (files and registry entries) of the program will be removed the next time you start Windows.

Key features

•	Keeps the position of your files on your desktop or in your folder
•	Allows you to display file extensions on the context menu
•	Allows you to convert unregistered file types (like FILE_ID.DIZ) to text files quickly
•	Can choose from a drop-down list of file types as well as extensions
•	Looks like it "belongs" in Windows 95 -- file type icons are displayed next to file types and the whole program is layed out similar to a property sheet
•	You can change which character is underlined for each menu item -- for people who REALLY want to customize their system!
•	Doesn't work on NT 4.0 yet (Wait, that's a BAD thing....  Oh well, at least you know it before you tried to install)
•	Next release will work on NT 4.0!

Usage

After you install Change File Type 96, it adds "Change File Type" to the right-click menu of any type of file (except shortcuts) like so:

When you click "Change File Type", a dialog box similar to this will pop up:

	NEW: The '...' box under the close box is for accessing options...  They are explained below
	
	This box should be pretty easy to figure out.  However, I will explain it anyways.  The icon and name at the top are the icon and name for the selected file.  The "From:" field contains the file extension and the file type.  The "To:" field contains the same.  You can either type in an extension (and it will tell you the file type as you type it in) or you can select the File Type on the right and have the extension pop up on the left.  If there are more than one extension for a single type (i.e. WinZip registers ARC, ARJ, GZ, Z, ZIP, et cetera all under the type "WinZip File"), you can use the up-down arrows to go between the different extensions.
	If a file type is too long in either the From or To fields, float over the type name and a ToolTip will extend the text past the end of the window.
	OK will obviously rename the file and let you go on your merry way, Cancel will leave the file alone, and Apply lets you rename the file then update the icon, display name and the "From" fields.
	Change File Type also keeps the icon in the same place when you rename it.  That means when you rename a file in a folder, it won't move to the end of the list or if you rename a file on your desktop it keeps its position.  I haven't seen any others that do this.
	Regarding this:.  You may see this little gem (its an hourglass) instead of file icons if you hit the drop-down list very soon after starting the program.  That is because it takes time to process all the icons for each file type, so I made that a second thread (running in the background).  When you come across an icon it hasn't yet processed, you get the hourglass.  As you move over the list items, the hourglasses will disappear and be replaced by the real icons. 

	This is the options box.  It should speak for itself, but I'll explain this, too.  The first box "Allow for conversion to text for unregistered file types", will allow you to quickly convert any unregistered type to text.  It will add a context menu item "Convert to text".  For instance, FILE_ID.DIZ files can be quickly double-clickable by activating this option and using it.  The two suboptions change the behavior of this option.  The first button would make the FILE_ID.DIZ a text file named FILE_ID.  The second button would make the file a text file but keep the display name as FILE_ID.DIZ.  By the way, after doing this, you can hit "Undo Rename" from the edit menu to change the file back.
	"Show the file extension on the pull down menu".  This is a handy option I saw in a program similar to this.  This will add an option "Extension: (EXT)" to the context menu.  Clicking it will bring up the normal Change File Type window.
	"Disable Window Animation" is one that, sigh :-), was demanded by users that got really annoyed or had slow computers.  Window animations are still enabled by default, though.
	The "Underlined Letters" section was suggested to me by a very clever person that wanted to change the shortcut key.  Basically, you use the left/right buttons to move the underscore left and right.  This will change the shortcut keys on the context menus.  Simple and effective.

This is Freeware?  What's the catch?

	There is no catch.  I made this as a learning tool for myself and as a utility.  Just thought I'd give a little back to the Internet community.  I would appreciate feedback and if you want to send me money :-) 

So what's your E-Mail address?

jack@opportunist.com

What's the version history?

Release 3: (June 22, 1996)
•	I've been doing contract work, which is why there aren't many functional enhancements
•	Put in my new email address in all of the program and documentation
•	Made my email address clickable in the main screen, and will copy to the clipboard if you have an older web browser or Netscape messed up your URL.DLL (as it is apt to do)
•	Abridged a portion of this document so that the program could be mentioned in PC World.  That's right -- PC World.
•	Moved the programmer's section to the bottom
•	Actually used the 'bullets' feature in Wordpad instead of dashes in the version history
•	Minor mistakes in the documentation were fixed

Release 2: (May 2, 1996)
•	Lets you Undo the operation from Windows 95's Edit/Undo Rename
•	Added options button
•	Added context menus for "Extension" and "Convert to text"
•	Let Users disable window animations
•	Fixed a bug that would eventually crash explorer
•	Sped up acquisition of file icons

Release 1: (Unknown)
•	First Public Release

Hope you enjoy the program!

Programmer's Paradise
Skip it if you could care less about how I did this

	For all you programmers out there, this is what I did for the major parts of the program:
1) The flip effect - EMail me for the Zoom functions
2) Obtaining file-type information: First, I used the RegEnumKeys function to get all the extensions and types and dumped them into two linked-lists.  (By the way, since global variables in DLLs are global for every instance of it, I dumped all this seemingly "global" data into a class and I use SetProp in the WM_INITDIALOG to tell it to refer to this variable.)  Then I started a thread (using _beginthread) to hop through the linked lists and use SHGetFileInfo to get the selected and unselected states of the icons from the shell using the SHCFE_USEFILEATTRIBUTES flag so that no files are actually used.
3) The icon in the upper left is an owner-draw button and I use SHGetFileInfo for the icon and the display name next to it.
4) In the from field, the file type is from the SHGetFileInfo, in the To field, its from the registry (or "<ext> File" if its an unregistered extension
5) How I made an owner draw combo box with an edit field: (BTW, I had to do this so that if the user typed in an unregistered extension, it would display "<ext> File".  Easy.  In the WM_INITDIALOG, I used MoveWindow to move the Edit field over 16 pixels (and down 2).  Then I subclassed the window (using SetWindowLong with GWL_WNDPROC) and whenever the combo box receives a WM_PAINT message, it runs the old paint procedure and the sends a custom message back to the parent for it to repaint the icon.  It also repaints when the user enters an extension.
6) Tooltips don't behave properly with the upgraded Internet Explorer 3.0.  I will fix this!  The tooltips.  This was actually a VERY arduous process.  I knew I had to subclass it.  You see, under normal circumstances, the tooltip won't display if the mouse is over the tip.  I just thought that filtering the WM_MOUSEMOVE would solve.  Then, it would pop up and immediately disappear.  After nearly tossing the monitor out the window, I went into Spy++.  After about 10 minutes of filtering the messages, I found the culprit.  It was a timer: number 3 to be precise.  So what I had to do was abort the Window procedure if I got a WM_TIMER with a wParam of 3 if the mouse is over the tip, and then hide the tip on a mouse click.  Whew.
7) Lastly is how I made the window flip from the center of the icon you clicked instead of where the mouse was:  Well, I used good old Spy++ for this as well as remembering one thing: since this is DLL loaded in-process by Explorer, not only can you crash Explorer, but you can use any of its windows.  So all I did was get the parent Window, used FindWindowEx to find the first child window with the "SHELLDLL_DefView" class, and then the first child of THAT with the "SysListView32" Class.  From there I used standard ListView macros to find the currently selected file and get the icon's bounding rectangle.  If any of this fails (like it does with the Microsoft Office Shortcut Bar), the flip effect relies on the mouse position.

If you have any more questions or suggestions on anything (including programming), E-Mail me.  My address is above this section.