可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
Some of us would invariably have to support 'legacy' code using Microsoft's Visual Studio 6.0 IDEs which - although opinions would differ - are generally regarded to be less user friendly compared to the later incarnations of the Visual Studio series of IDEs.
So I'd like to hear about some of your best hidden/poorly documented IDE features (could be for either C++ or VB). As is the usual practice one feature per post, please.
回答1:
Last time I had to use VB6, I wanted to jump out of my skin in anger because the scroll wheel on my mouse, which literally works with every other program in Windows, didn't work. This has something to do with the age of VB6 and how Microsoft has changed scroll wheel functionality over the years.
This guy wrote a program to make it work.
(and it looks like in the years since Microsoft made a fix as well)
回答2:
For VB6, MZ-Tools is a fantastic free add-in. My favorite features are its find feature and its ability to find all callers of a given routine with a click of the button. It has several other features as well, several of which I've found helpful on occasion.
回答3:
Custom Code Templates in VB6
I don't know if this is really a "hidden" feature or not, but always thought it was a nice time-saver.
You can create your own custom templates for classes, modules, forms, etc. and make them available in the IDE. For example, I usually like to use strongly-typed Collection
classes in my VB6 code. So I might want a FooCollection
that holds Foo
objects and nothing else, instead of a plain old Collection
. I don't want to have to reimplement the Collection
interface every time I need a new strongly-typed Collection
, so I created a new class template that contained all the boiler-plate Collection
code. Now whenever I go to add a new class module to my project, my custom TypedCollection
template is available as an option. Then I just rename the newly-added class FooCollection
and replace all occurences of "As Object" with "As Foo" (where Foo is the type of object I want to store in the collection) and I'm done.
Keeping with my custom class template example, here's what you do:
- Open up the IDE and start a new project (I usually just do Standard EXE, because it doesn't really matter what you pick here).
- Add a new class to the project. This will become your template.
- Code your template class. Basically just write any boiler-plate code that you would like to be able to reuse in other projects. This is straight VB code, nothing special.
- When you're finished save your file in your
C:\Program Files\Microsoft Visual Studio\VB6\Template\Classes
folder (Note: the other subfolders, such as Forms
, etc. are for other kinds of templates). The name of the .cls file minus the extension is what will appear in the IDE, so I normally include spaces in the file name for readability.
- The next time you open up your IDE and click
Project->Add Class Module
, your template class will appear in the list of available class templates.
回答4:
You can edit the file C:\Program Files\Microsoft Visual Studio\Common\MSDev98\Bin\AUTOEXP.DAT
to add rules for displaying meaningful values of your custom classes in the Debug Watch Window.
What I mean is this. We have a date structure defined like this:
typedef struct tagMHDATE
{
short int nDay; // Day of the Month 1..31
short int nMonth; // Month of the Year 1..12
short int nYear; // Year
} MHDATE, FAR *LPMHDATE;
If I have this code:
MHDATE today;
GetDate(&today);
...and drop today
in the watch window, I'll see something like this:
today {...}
Now go and add this to the end of AUTOEXP.DAT (it's just a text file)
tagMHDATE=date=<nMonth>/<nDay>/<nYear>
...and now I see this in the Watch window:
today {date=10/8/2008}
回答5:
I'll kick this off a VS C++ feature which has saved me lots of time: appending a ",su" (without the quotes) to a unicode string in the watch window of a debugger enables you to view the value of the string (rather than the memory address of that string)
回答6:
The Erl function in VB6. If you put line numbers in your VB6 code, you can, in your error handler, access the line number at which your error occurred via the return value of the function Erl.
回答7:
There are quite a few tips and tricks here. My favorite one is placing @err,hr
in the Watch window to get error messages.
回答8:
For VC6, get a copy of Visual Assist X by Whole Tomato. It contains a smart (and usable) Intellisense replacement, much richer code coloring, some refactoring support, and many more features. Most definitely worth the investment.
回答9:
Change the "Start in" property on the shortcut that you use to start VB6 to the root of your source code directory. This will save many wasted mouse clicks every time you open a project from within the IDE.
回答10:
CodeShine: VB6 code refactoring add-in (free). Includes refactorings such as Extract Method, Introduce Explaining Variable, Extract Function, Introduce Explaining Variable, Rename, etc
http://www.wsdesigns.com/CodeShine/default.htm
回答11:
Quick macros was always a personal favorite of mine; not really a hidden feature per-se, but very useful, and VC6 was the last version where they were quick enough to be useful (before MS rewrote the macro engine to use .NET).
回答12:
Shift-Alt-Enter to increase the size of the editor window
回答13:
My answer to the question "If you are not satisfied with answers on someone else’s question, should you start your own?" shows how to pre-populate VC++ with all your source paths. It's useful for those of us who build from the command line, but debug using msdev.
回答14:
Not really a VB6 IDE feature, but if you have to fill an unbound listview with a lot of data then making it invisible during the filling process speeds it up by maybe a factor of 10.