September 11, 1998

Be Cautious with Local Static Variables in a Member Function

The object model of C++ ensures that each object instance gets its own copy of data members (except for static ones). On the other hand, all instances of a base class, as well as instances of classes derived from it, share a single copy of the member functions of the

Exceptions are Always Passed by Value

The exception handling (EH) mechanism disables the possibility of passing a thrown exception by reference or through a pointer. This is due to the way this mechanism is implemented: when an exception is thrown, the mechanism first searches for an appropriate handler in the current scope. If such handler does

Enhancing Performance of Legacy Software

When you port pure C code to a C++ compiler, you may discover slight performance degradation. This is not a fault in the programming language or the compiler, but a matter of compiler tuning. All you have to do to gain the same (or better) performance as you would get

Use Toolbar-Style Title Bars

To make a form use a small toolbar-style title bar, set the form’s WS_EX_TOOLWINDOW extended style: Declare Function GetWindowLong Lib “user32” _ Alias “GetWindowLongA” ( _ ByVal hwnd As Long, _ ByVal nIndex As Long) As LongDeclare Function SetWindowLong Lib “user32” _ Alias “SetWindowLongA” ( _ ByVal hwnd As Long,

Use a Struct Instead of a Long Argument List

Functions having a long list of arguments such as: void retrieve(const string& title, const string& author, int ISBN, int year, bool& inStore); can become a maintenance problem, since their argument list is likely to be changed in the future. For example, a URL with a book cover image may be

Implement a Binary Tree

A binary search tree can be useful when you have to traverse a lot of data in sorted order. As this CBinarySearchTree class demonstrates, you can implement binary search trees easily using objects and recursion (both data recursion and procedural recursion): ‘class properties:Private LeftBranch As CBinarySearchTreePrivate RightBranch As CBinarySearchTreePrivate NodeData

Modify a Toolbar’s Image List Control

Have you ever tried to create tools on a toolbar using an image list, only to find that you must detach the toolbar from the list and reset all the toolbar button properties every time you want to add to the image list? Annoying, isn’t it? Before adding anything to

Speed up Selecting Items in a MultiSelect List Box

Try this routine to select or deselect all items in a list box. Add a list box to your form with the MultiSelect property set to Simple or Extended, and add items to the list box: Sub ToggleSelectAll (lst As ListBox, ByVal bState As Integer) Dim i As Integer lst.Visible

Keeping Things Fresh

Sometimes you might need a browser to keep reloading the latest version of a page automatically. A good example of this is a page that displays an image from a Webcam. You might think that you’d have to resort to JavaScript or VBScript code to achieve this but the good

No more posts to show