I thought I was on the right track with being able to turn off INSERT mode in a TextBox so characters typed would overwrite by using ----
GetKeyboardState and SetKeyboardState
I can read the INS key toggle but it seems I cannot change it even from the keyboard.
I need to make sure it is off to create a masked edit function.
Any thoughts?
Thanks
I forgot to mention that the
SetKeyboardState
works for setting the SHIFT key
I did a couple of searches in POFF's and the PB Forum. Looks like you should handle the overwrite via code in WM_CHAR. FireFly make this easy because it handles all of the subclassing already. Use code like the following in the WM_CHAR message of your text box.
Function FORM1_TEXT1_WM_CHAR ( _
ControlIndex As Long, _ ' index in Control Array
hWndForm As Dword, _ ' handle of Form
hWndControl As Dword, _ ' handle of Control
chCharCode As Long, _ ' character code
lKeyData As Long _ ' key data
) As Long
Local strAllowedChars As String
Local nKeyPos As Long
strAllowedChars = "abc"
'[textbox overwrite mode similarly to
' http://www.powerbasic.com/support/forums/Forum4/HTML/005589.html ]
If InStr(strAllowedChars, Chr$(chCharCode)) Then
' get selected string
nKeyPos = SendMessage(hWndControl, %EM_GETSEL, 0, 0)
nKeyPos = LoWrd(nKeyPos) ' start idx is in the low-order word
' select current single char
SendMessage hWndControl, %EM_SETSEL, nKeyPos, nKeyPos + 1
' clear it
SendMessage hWndControl, %WM_CLEAR, 0, 0
' insert in place of cleared char
SendMessage hWndControl, %EM_SETSEL, nKeyPos, nKeyPos
Else
' discard the 'illegal' character
Function = 1 : Exit Function
End If
End Function
Paul,
Thanks -- again for the great support.
This is not exactly intuitive but it certainly is simple.
The "wonders" of Microsoft Windows.
Thanks