March 11, 2000

Suppress Max and Min buttons in MDI forms

Unlike regular forms, forms don’t expose the MinButton and MaxButton properties and these buttons are always displayed. You can suppress these buttons using the following code: Private Declare Function SetWindowLong Lib “user32” Alias “SetWindowLongA” _ (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As LongPrivate Declare

A simple way to control a common dialog’s position

The CommonDialog control doesn’t provide any direct way to decide where a common dialog appears on the screen. In all cases, in fact, the control tries to display the common dialog centered on its owner form. This behavior suggests a simple way to affect the approximate position of the common

The fastest way to append contents to a TextBox control

The most intuitive way to append a string to the current contents of a TextBox is through the & string operator, as in: Text1.Text = Text1.Text & “more text” However, you can reach the same result about 4 times faster with the following method: Text1.SelStart = Len(Text1.Text)Text1.SelText = “more text”

Implement password-protected TextBox that are really secure

As explained in another tip in this TipBank, users can peek at the contents of password-protected TextBox controls with a simple Spy-like program, or even with a VB program plus some API functions. The problem is that such TextBox controls react to the WM_GETTEXT message and the GetWindowText API function

Provide a short description of the menu item being highlighted

Visual Basic lacks of the capability to display a short description of the menu command being highlighted with the mouse or the keyboard, a feature that all professional applications should have. To add menu descriptions to your program, you must subclass the form and trap the WM_MENUSELECT message. When this

Prevent an iconized window from being restored

When the user clicks on an iconized (minimized) form in the taskbar, Windows sends that form a WM_QUERYOPEN message, and inspects the value returned to the operating system. If this value is zero, the operation is canceled.Using subclassing you can therefore determine when a form is about to be restored,

Providing an Alternative Image for the Non-Java Viewer

You’ve taken the trouble to write a Java applet, so you naturally want everyone to see it. Unfortunately, there are some viewers that still don’t have a Java-capable browser or their OS doesn’t support Java. When they attempt to load your page, all they will see a gray box. To

Strange Behavior of the JPasswordField

The JPasswordField included in Swing exhibits a strange behavior?it moves the caret to the right as far as the width of the character you already typed. The problem is that the component doesn’t show that character, but only an asterisk (*). This, added to the fact that the field has