I am doing some POST input editing on a TextBox. I put some code in the <name>_EN_KILLFOCUS event but I am having a problem.
1) I want to pop up a YES/NO message box to re-input the field (return focus to the same field) or simply go where the focus change was headed before doing my edit check. How do I know where the next focus was headed without any hard code to simply force the next focus? It seems after the MSGBOX closes focus ALWAYS returns to the same field.
2) When the main form is destroyed (stop the program) and the focus is in a TextBox with a post input edit the <name>_EN_KILLFOCUS event fires. I suppose that is true since the focus is lost but is there a way to detect that the form is being destroyed so I can skip the post input edit?
Thanks
Try the following:
Global gEditCheckFlag As Long
'------------------------------------------------------------------------------------------------------------------------
Function FORM1_TEXT1_EN_KILLFOCUS ( _
ControlIndex As Long, _ ' index in Control Array
hWndForm As Dword, _ ' handle of Form
hWndControl As Dword, _ ' handle of Control
idTextControl As Long _ ' identifier of text control
) As Long
If gEditCheckFlag Then Exit Function
gEditCheckFlag = %TRUE
Local lResult As Long
lResult = MessageBox(hWndForm, ByCopy "Save Changes?", ByCopy "Confirm", _
%MB_YESNO Or %MB_DEFBUTTON1 Or %MB_ICONQUESTION)
Select Case lResult
Case %IDYES
'move to the next field
SetFocus GetNextDlgTabItem(hWndForm, hWndControl, 0)
Case %IDNO
End Select
gEditCheckFlag = %FALSE
End Function
'------------------------------------------------------------------------------------------------------------------------
Function FORM1_WM_CLOSE ( _
hWndForm As Dword _ ' handle of Form
) As Long
gEditCheckFlag = %TRUE
End Function