March 13, 1999

Applying CSS Styles Across Your Entire Site

Using Cascading Style Sheets (CSS), you can easily create styles that apply to the entire site. This technique has many advantages over repeating the same style text over and over in each of your pages. Using site-wide styles, you can simply change the master CSS file and it will affect

Hashtable Key Replacement

Most Java programmers know that adding an object to a Hashtable using a key already stored in the Hashtable will cause the previously-added object to be “dropped” from the table and replaced with the newly-added one. However, there is often confusion over precisely when two keys are considered equal. Some

Prefer Initialization to Assignment of Objects

In general, assignment requires the creation and destruction of a temporary object, whereas initialization does not. This is true for not just for strings, but for every object type, so whenever you have the choice–prefer initialization to assignment. Consider this code snippet: string s1 = “Hello “, s2 = “World”,

Simulating Virtual Constructors

A constructor may not be declared virtual. The easiest way to simulate virtual construction is by defining a virtual member function that returns a constructed object of its class type: class Browser{public: virtual Browser* construct() { return new Browser; } //virtual default constructor virtual Browser* clone() { return new Browser(*this);

Member and Non-Member Overloaded Operators

Most of the overloaded operators can be declared either as non-static class members or as non-member functions. In this example, operator == is overloaded as a non-static class member: class Date{//

Create Automatic Hourglass Cursors

If you create an ActiveX control that uses a custom MousePointer property, place the control on a form, and at run time change the Screen.MousePointer property to an hourglass. You’ll see that the mouse pointer reverts to the ActiveX control’s custom cursor while over the control. I discovered this when

Translate Color Values

With the RGB function, VB provides a neat and valuable tool for converting separate Red, Green, and Blue values into a single Long color value.. However, VB won’t let you translate back from its this color value to back to its constituent RGB values. But, you can pick the individual

Extend Intrinsics in UserControl Wrappers

Sometimes you might want to create autoselecting combo boxes, like those in Intuit Quicken or Microsoft Access, where items in the list are selected as you type. Typically, techniques to do this require code in the KeyPress and KeyDown events, which selects the items from the list. I’ll show you

Provide Status Messages for Menus

Subclassing a form lets you give a helpful message whenever a user highlights a menu item. Use the Caption property to identify the menu item, then display the help message in a label (lblStatus), which is on the form: ‘ — Form codePrivate Sub Form_Load() origWndProc = SetWindowLong(hwnd, GWL_WNDPROC, _

No more posts to show