March 19, 1999

Use Unadvertised Controls

When you open VB5’s Components list, you’ll see many controls and libraries not available for your development. Some are controls you downloaded from Web pages; others come from who knows where. If you’ve ever tried adding an unknown control to your IDE, you probably saw an icon added to your

Overloading Operators for enum Types

For some enum types, it may be useful to define overloaded operators, such as ++ and –, that can iterate through the enumerator values: #include using namespace std;enum Days {Mon, Tue, Wed, Thur, Fri, Sat, Sun};Days& operator++(Days& d, int) // int denotes postfix++{ if (d == Sun) return d =

Const and Reference Data Members Must be Initialized

A class may have const and reference data members. These members must be explicitly initialized by a member-initialization list: class Allocator{private: const int chunk_size; const string & serialization_path; // file into which an object can be serialized public: Allocator(int size, const string& path) : chunk_size(size), serialization_path (path){}};

Activate Single Control on All Tabs

A single object, employing a single set of event routines, may be used across all pages in the SSTab control. Draw the object on the form that contains the SSTab and drag it on any page on SSTab. The object appears in the same location on all pages and can

Delegate Generic Event Handling

It can be useful to create generic controls of similar properties. For example, if a project has 10 textboxes on different forms that need to accept numeric input only, instead of repeating the same code in every textbox, you can create a class called clsGeneric and declare the control using

Easily Determine Whether a Recordset is Empty

Use this quick and dirty routine to help find empty recordsets: Public Function IsEmptyRecordset(rs As Recordset) As Boolean IsEmptyRecordset = ((rs.BOF = True) And (rs.EOF = True))End Function

Remove Unwanted Characters

When working with or fixing Access databases and Excel spreadsheets created by users at my company, I often have to use their strings from the table or spreadsheet to save the resultant fixed file. The problem is that the strings they use often contain illegal file-name characters. This function strips

Executing a File Selected in Filelistbox

Question: I am trying to work out the coding to execute a file that I select in my filelistbox in Delphi 4. Can you help me? Answer: You can refer to the online help for ShellExecute, or for a more robust methodology, use CreateProcess. Here’s a wrapper for that: procedure

Shared Database Session

Question: Is there a way to share a database session between calling application and DLL? Not having such a sharing (DLL with DataSet components) increases the number of SQL server clients. Answer: You could try instantiating the Session from within the DLL and then create a function that returns a

No more posts to show