October 30, 1998

Application Design and Passwords

Question: How do you protect an application with a password and store it in the application’s exe-file? Answer: You’d have to hard code the password in. Then in the FormCreate method of your main form, you’d do something like this: procedure TForm1.FormCreate(Sender: TObject);var pwrd : String; PassOK : Boolean;begin Counter

SQL Joins with Paradox

Question: I’m developing a program that lists all of a shop’s clients and the items that they purchased. The problem is that if some clients haven’t bought anything, they don’t appear. I would like to perform a left join (like in Access) with Paradox. However, I don’t know Paradox and

Creating Radio Buttons Using the AWT

The way you create a set of radio buttons is significantly different between Swing and the AWT. With Swing, you instantiate the buttons and add them to a group object rather than passing the group object as a parameter when you instantiate the buttons. To create radio buttons using the

Creating Radio Buttons Using Swing

Radio buttons behave in the same mutually exclusive way in Swing and the AWT. However, the way that you create a set of radio buttons differs significantly between Swing and the AWT. To create a set of radio buttons in Swing, you must instantiate the buttons, instantiate a ButtonGroup object,

Creating Hidden Buttons with Swing

Using Swing, you can easily create hidden buttons similar to the Back button used in Netscape Communicator 4. Hidden buttons look like normal graphic elements on the screen until you float over them with the mouse. This code was tested using JDK1.1.6 and Swing 1.0.3 under Win95: import java.awt.*;import java.awt.event.*;import

Infrastructure Functions Should Trust Their Users

Infrastructure functions that are used extensively should adopt the “trust the programmer” policy by not performing additional error checking. This policy is widely used in C/C++ standard libraries. For example, it would be safer if strcpy() examined its arguments and made sure they are not null pointers. However, if it

An Object Size May Never Be Zero

An empty class doesn’t have any data members or member functions. You’d think that the size of an object of such a class would be zero. However, the Standard states that a complete object shall never have a zero value. For example: class Empty {};Empty e; // e occupies at

Koenig Lookup

Andrew Koenig devised an algorithm for resolving namespace members’ lookup. This algorithm is used in all standard-conforming compilers to handle cases like the following: namespace MINE { class C {}; void func(C); } MINE::C c; // global object of type MINE::Cvoid main() { func( c ); // OK, MINE::f called

Wide Character Literals

A string literal is a sequence of one or more characters enclosed in double quotes: cout

No more posts to show