I have the need to change a single line TextBox from within the WM_CHAR event. I am using a special Masked Edit routine. For numeric values I redisplay the string with commas but when I enter the field to edit I want to strip the commas before I start to edit. When you loose focus I redisplay with commas again.
I know I could update the TextBox from the SETFOCUS event but my MaskEdit routine only requires a single generic (not control specific) function call in the CHAR event. If it is the first keystroke for the control it figures out the format from the FF TextBox tag. This avoids placing the extra function call in the SETFOCUS.
It seems any FF_CONTROL_SETTEXT does not behave correctly when used in a CHAR event. It appears the control gets updated (if from the same CHAR event you read it with FF_CONTROL_GETTEXT) but the display never reflects the update. It appears that FF somehow has an internal buffer for the control and any changes are ignored after the control gets focus.
Any suggestions (other than don't be lazy and put the extra function call in the SETFOCUS event). When you have hundreds of controls in a project this would make life easier.
Thanks.
Since my MaskEdit setup is a single generic function call I suppose I could try to process the SETFOCUS event for a control at the form level. This would also let me change the background color of the current control when it is in an "active input mode".
Is it possible to catch the SETFOCUS event for a child control from the parent Window (the form).
Thanks.
Quote from: Mark StricklandSince my MaskEdit setup is a single generic function call I suppose I could try to process the SETFOCUS event for a control at the form level. This would also let me change the background color of the current control when it is in an "active input mode".
Is it possible to catch the SETFOCUS event for a child control from the parent Window (the form).
Thanks.
You can deal with the EN_SETFOCUS through the WM_COMMAND notification.
Function FORM1_WM_COMMAND ( _
hWndForm As Dword, _ ' handle of Form
hWndControl As Dword, _ ' handle of Control
wNotifyCode As Long, _ ' notification code
wID As Long _ ' item, control, or accelerator identifer
) As Long
Select Case wNotifyCode
Case %EN_SETFOCUS
' The hwnd of the edit control is hWndControl
FF_Control_SetText hWndControl, "New Text"
End Select
End Function