Welcome to the SRP Forum! Please refer to the SRP Forum FAQ post if you have any questions regarding how the forum works.

Generic Promoted Event Handler

I have been getting a little more familiar with promoted events, and I have attempted to make a generic promoted event handler that will basically get the current event using the Get_Current_Event() function and forwarding it to the window's commuter module, so I don't have to tie Quick Events to the commuter module. I did the following steps...

1) I created in the system editor a function called MY_PROMOTED_GENERAL_EVENT with the following code: Compile Function My_Promoted_General_Event(CtrlEntId, CtrlClassId, Param1, Param2, Param3, Param4, Param5, Param6) Declare Function Promoted_General_Event, Get_Current_Event Event = Get_Current_Event() Ans = Promoted_General_Event(Event, CtrlEntId, Param1, Param2, Param3, Param4, Param5, Param6) Return Ans 2) I created another function called PROMOTED_GENERAL_EVENT with the following code:

Compile Function Promoted_General_Event(Event, CtrlEntId, Param1, Param2, Param3, Param4, Param5, Param6) Declare Function Get_Repos_Entities, Function, Get_Property Declare Subroutine Msg // Get the design time name of the window in case this is a multi-instance window. Window = @Window[1, "F*"] MDIFrame = Get_Property(@Window, "MDIFRAME") Parent = Get_Property(@Window, "PARENT") If MDIFrame EQ "" then MDIFrame = Parent ; // Dialog boxes won't set the MDIFRAME property so use the PARENT property. // Get the name of the control on the window. Get all reasonable parts of the control name. Control = Field(CtrlEntId, ".", 2, 5) // If there is no control then assume the window is the control. If Control EQ "" then Control = Window AppID = @APPID<1> ;* current application TypeID = "STPROC" ;* OpenInsight Windows ClassID = "" ;* Not Applicable MoreInfo = "" SubList = Get_Repos_Entities(AppID, TypeID, ClassID, "", "", "", "") numEntities = dCount(SubList, @fm) FileName = Window:"_EVENTS" ReposId = AppID:"*":TypeID:"*":ClassID:"*":FileName Locate ReposId In SubList Using @fm Setting Pos Then Ans = Function(@FileName(Event, CtrlEntId, Param1, Param2, Param3, Param4, Param5, Param6)) End Else Ans = 1 End Return Ans 3) After compiling the code I put the following command in the system monitor to copy the object code to the SYSREPOSEVENTEXES table using the appropriate key:
RUN COPY_ROW "SYSOBJ", "$MY_PROMOTED_GENERAL_EVENT*EVY", "SYSREPOSEVENTEXES", "EVY*..OIWIN*", 2, 0

4) Restart Openinsight

5) Recompiled the forms I wanted to test.

The results I got were mixed. It worked as expected for events like GOTFOCUS, LOSTFOCUS, and CLICK, but it did not recognize events such as CREATE, VSCROLL, and CHANGED.

Any thoughts on why only some events fire the general event handler and others do not?

Comments

  • Open UI Workspace utility and select "Design Events..." from the Tools menu. Make sure you set the enforce flag to Yes for these events and restart OI.
  • I should also point out that after you enforce these events, you need to recompile your forms as well. Then restart OI.
  • Oh yeah.... I forgot that part...

    Thanks for straightening that out for me! :-D
Sign In or Register to comment.