DISABLE/ENABLE EVENTS
This
commands/function prevents re-entry while processing the events of a control or
window allowing the use of other controls/functions that generate messages of
re-called of events
Syntax:
-
DISABLE [ CONTROL ] EVENT ControlName OF FormName
-
ENABLE [ CONTROL ] EVENT ControlName OF FormName
-
StopControlEventProcedure ( cControlName, cFormName, lStop )
-
DISABLE [ WINDOW ] EVENT OF FormName
-
ENABLE [ WINDOW ] EVENT OF FormName
-
StopWindowEventProcedure ( cFormName,
lStop )
Complementary Functions:
-
GetLastActiveFormIndex () --> Return nFormIndex
-
GetLastActiveControlIndex () --> Return nControlIndex
-
GetFormNameByIndex ( nFormIndex ) ---> Return cFormName
-
GetControlNameByIndex ( nControlIndex ) ---> Return cControlName
Example:
#include "hmg.ch"
FUNCTION Main
DEFINE WINDOW Form_1;
AT 0,0;
WIDTH 400;
HEIGHT 300;
ON GOTFOCUS Form_ONGOTFOCUS();
MAIN
@ 50, 50 BUTTON Button_1 CAPTION
"Click" ACTION MsgInfo ("Hello")
@ 100, 50 BUTTON Button_2 CAPTION
"Minimize" ACTION Form_1.Minimize
@ 150, 50 TIMEPICKER TimePicker_1 ON
GOTFOCUS Control_ONGOTFOCUS ()
END WINDOW
CENTER WINDOW Form_1
ACTIVATE WINDOW Form_1
RETURN
PROCEDURE Form_ONGOTFOCUS
LOCAL i := GetLastActiveControlIndex
()
DISABLE WINDOW EVENT OF Form_1
MsgInfo ("ON
GOTFOCUS: Form_1 " + IIF (i > 0," - Last
Control Focused: "+
GetControlNameByIndex(i), ""))
ENABLE WINDOW EVENT OF Form_1
RETURN
PROCEDURE Control_ONGOTFOCUS
LOCAL i := GetLastActiveFormIndex
()
DISABLE WINDOW EVENT OF Form_1 // -->
StopWindowEventProcedure ("Form_1",
.T.)
DISABLE CONTROL EVENT TimePicker_1 OF
Form_1 // -->
StopControlEventProcedure
("TimePicker_1", "Form_1", .T.)
MsgInfo
("ON GOTFOCUS: TimePicker_1" + IIF (i >
0," - Last Form Focused: "+ GetFormNameByIndex(i), ""))
ENABLE CONTROL EVENT TimePicker_1 OF
Form_1 // -->
StopControlEventProcedure
("TimePicker_1", "Form_1", .F.)
ENABLE WINDOW EVENT OF Form_1 // -->
StopWindowEventProcedure ("Form_1",
.F.)
RETURN