January 29, 2000

Show a custom popup menu for a TextBox without subclassing

Elsewhere in the TipBank we show how you can display a custom popup menu on a TextBox control by subclassing the WM_CONTEXTMENU message that Windows sends the control when the user right-clicks on it. If you don’t like to resort to subclassing for such an easy job, you can use

Undo changes in a TextBox control

The TextBox control supports the capability to undo changes, but there is no property or method that exposes this feature. You can achieve the same goal with a a set of messages. Private Declare Function SendMessage Lib “user32” Alias “SendMessageA” (ByVal _ hwnd As Long, ByVal wMsg As Long, ByVal

The number of lines in a multiline TextBox control

You can quickly determine how many lines of text are contained in a multiline TextBox control whose Scrollbars property is set to 3-Both – that is, when the TextBox behaves like a programmer’s editor – by counting the number of CR-LF characters in the Text property. You can do that

The first visible line in a multiline TextBox control

To determine the index of the first visible line in a multiline TextBox control you only need to send it the EM_GETFIRSTVISIBLELINE message: Private Declare Function SendMessage Lib “user32” Alias “SendMessageA” (ByVal _ hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _ lParam As Any) As LongConst

Create TextBox with dithered background

If your video display has 256 colors or less and you assign a dithered color to the BackColor property of a TextBox control, you’ll find that the background color under the text inside the TextBox is displayed in a different (solid) color. To work around this issue, you must trap

Recalculate the Download Time in DreamWeaver 2

By default, DreamWeaver 2 assumes that your page will be downloaded with a 28.8 KB per second modem. The estimated download time appears in the status bar. If you are creating an intranet site that runs over a local area network, you can assume that browsers are connecting much faster

Be Aware Of The Signed Byte

Java lets you cast an integer into a byte and vice versa. While this provides power and flexibility, we should be aware that Java’s byte data type is signed, meaning that the leftmost bit (the 8th bit) of a byte is reserved for the sign of the data it holds

Validate Dates With Java

We can use java.text.DateFormat to validate dates. DateFormat is an abstract class for date/time formatting subclasses. It provides parsing methods for conversion of text into date. If the conversion cannot be carried out because of invalidity of the date, a java.text.ParseException is thrown. This is how we can know if

StringTokenizer and the Missing Token

If we have a comma delimited string like “token0,token1,token2,,token4” that has some token(s) missing, and we try to use java.util.StringTokenizer to place each delimited token in a slot of an array A such that: A[0]=”token0″; A[1]=”token1″; A[2]=”token2″; A[3]=””; A[4]=”token4″; we might write code like: String s = “token0,token1,token2,,token4”; java.util.StringTokenizer stringTokenizer=

No more posts to show