Navigation:  Functions >


Print this Topic    Previous pageReturn to chapter overviewNext page


Detours the events of a window or control to the method of another object.








) Æ lSuccess


<oWindow>The window or control, by which the events is to be detoured.
Data Type:Object


<oMethodOwner>The object to which the events is to be detoured.
Data Type:Object


<symMethod>The name of the method that is to be called in <oMethodOwner> and in which the detoured events is processed.
Data Type:Symbol

Return Value

lSuccessA logical value that indicates whether the detour was activated.
TRUEThe detour was activated.
FALSEThe detour could not be activated.
Data Type:Logic


The classes Window and control of CA-Visual Objects possess a general EventHandler that is called whenever Microsoft Windows sends a message (event) to the Window/Control. This EventHandler is implemented by the method Dispatch() and ensures for the fact that the arriving events is passed on or processed to subordinated EventHandler. Unfortunately not all messages of Microsoft Windows arrive in the method Dispatch(). Some are intercepted already before, by the class library, and are not passed on. In some cases one would like to react however nevertheless to this messages or another object is to the messages to react. For exactly these tasks the function bRegisterByEventHandler() serves. It detours the messages for a Window/Control to another object over before the method Dispatch() of the Window/Control is called. Thus the object receives the possibility to process the message. The method <symMethod> in the object <oMethodOwner> must have the following format:


<symMethod>(oEvent) class <classname>


If the method the arriving message to be processed or the message is not to be passed on to the window/control, the method must return the value NIL. Otherwise the value must be returned that is defined for the appropriate message. Which values that are, can be determined by the SDK of Microsoft Windows.


The function bRegisterByEventHandler() can be detoured also for a Window/Control on different objects. In this case the methods are called in the order in which they were registered by the function. As soon as a method returns a value unequally to NIL, the following registered methods are not called any longer.


The following sample detours the messages of a bBrowser on the method BrowserEventHandler() in its owner. In the method the KEYDOWN events are intercepted and a message is shown if the key RETURN were pressed. So that the events are passed on to the bBrowser, the method returns always the value NIL.


CLASS dtwSample INHERIT DataWindow

 PROTECT oBrowser AS bBrowser


METHOD Init(oOwner) CLASS dtwSample


 oBrowser := bBrowser{oOwner,;


                                          Point{0, 0},;

                                          Dimension{300, 250}}



 // detours the events of the bBrowser on the window





METHOD Destroy() CLASS dtwSample

 // unregister the detour

 bUnregisterByEventHandler(SELF:oBrowser, SELF)



METHOD BrowserEventHandler(oEvent) CLASS dtwSample

 // in this method all events of the bBrowser arrives

 IF oEvent:uMsg=WM_KEYDOWN

         IF InList(oEvent:WParam, KEYRETURN, KEYENTER)


                                         "RETURN key was pressed.",;






See Also


bSample - SensitiveSearch


Page url: