////////////////////////////////////////////////////////////////////////////// // // Event: pfc_messagerouter // // Arguments: // as_message message (event notification) to send // // Returns: integer // 1 = message successfully sent // 0 = no receivers recognized the message // -1 = error // // Description: // This event routes a message (event notification) // to the appropriate object. // Should override the ancestor in w_master. // ////////////////////////////////////////////////////////////////////////////// // // Revision History // // Version // 5.0 Initial version // Techno-Kitten: Extended to send messages to containing controls // ////////////////////////////////////////////////////////////////////////////// // // Copyright © 1996-1997 Sybase, Inc. and its subsidiaries. All rights reserved. // Any distribution of the PowerBuilder Foundation Classes (PFC) // source code by other than Sybase, Inc. and its subsidiaries is prohibited. // ////////////////////////////////////////////////////////////////////////////// graphicobject lgo_Focus, lgo_Parent, lgo_ParentList[] integer li_Index, li_ParentCount=0 // Check argument IF IsNull (as_message) OR Len (Trim (as_message)) = 0 THEN RETURN -1 END IF // Try sending the message to this window, if successful exit event. IF This.TriggerEvent (as_message) = 1 THEN RETURN 1 lgo_Focus = GetFocus() IF IsValid (lgo_Focus) THEN // Try sending message to object that contain the current control (e.g. tabpage, tab, userobject) lgo_Parent = lgo_Focus.GetParent () DO WHILE IsValid (lgo_Parent) AND (lgo_Parent <> This) li_ParentCount ++ lgo_ParentList[li_ParentCount] = lgo_Parent lgo_Parent = lgo_Parent.GetParent () LOOP // Check containers from the top downwards FOR li_Index = li_ParentCount TO 1 STEP -1 IF lgo_ParentList[li_Index].TriggerEvent (as_Message) = 1 THEN RETURN 1 NEXT // Try sending the message to the current control, if successful exit event. IF lgo_Focus.TriggerEvent (as_message) = 1 THEN RETURN 1 END IF // Try sending the message to the last active datawindow, if successful exit event. IF IsValid (idw_active) THEN IF idw_active.TriggerEvent (as_message) = 1 THEN RETURN 1 END IF // No objects recognized the message RETURN 0