This sample demonstrates binding events, raising events programmatically, unbinding events, and retrieving events for _SCREEN system variable, or the main Visual FoxPro window. In the sample, you can manually raise a bound event for _SCREEN by selecting an event from the combo box or invoke the same events and their respective handlers by using the mouse.
For more information about _SCREEN, see _SCREEN System Variable.
To respond to Visual FoxPro events, use the BINDEVENT( ) function. In this sample, the BINDEVENT( ) function is called in the custom InitBindEvent method and binds several _SCREEN events to the form's methods. When one of the _SCREEN events fires, the associated handler method is called:
BINDEVENT(_SCREEN,"Resize",ThisForm,"screenresize") BINDEVENT(_SCREEN,"Mousedown",ThisForm,"screenmousedown") BINDEVENT(_SCREEN,"Mouseup",ThisForm,"screenmouseup") BINDEVENT(_SCREEN,"Rightclick",ThisForm,"screenrightclick") BINDEVENT(_SCREEN,"Dblclick",ThisForm,"screendblclick")
Raising Events Programmatically
To raise events programmatically, use the RAISEEVENT( ) function. In this sample, when the combo box is selected, the InteractiveChange event uses the returned value to programmatically raise the specified event.
To unbind event handlers, use the UNBINDEVENTS( ) function. In this sample, the custom UnbindHandlers method unbinds events for _SCREEN.
For more information, see UNBINDEVENTS() Function.
Retrieve Event Bindings
To retrieve existing event bindings into an array, use the AEVENTS( ) function. In this sample, the custom ScreenDblClick method, which is bound to the _SCREENВ DblClick event, uses the AEVENTS( ) function to report the number of event bindings: