An OCX on a window: properties work, method calls fail, and how to receive its events

Applies to: posted in the sv.clarion.clarion8 group; the thread names no template chain.

Problem

An OCX was added to a window. Setting its properties worked (?Ctl{'a5Local_Port'} = value), but method calls such as ?Ctl{'BraiDConnect(&FLO:BinaIPRecL1,&1)'} did nothing. The OLE class generator produced an .inc and a .clw that the poster could not place, and the OLEG COLEOBJ.TPL did not register. He also needed the OCX's status events.

Solution

  1. Turn on exception reporting to see which command the control did not understand: ?Ctl{Prop:ReportException} = True.
  2. The & in the command text was Clarion's operator, which the OLE control cannot interpret. Build the command as a string before the call:
    E:Retorno=?Ctl{'BraiDConnect(' & clip(FLO:BinaIPRecL1) & ',1)'}
    E:Retorno=?Ctl{'ShowConfig(1)'}
    

Another reply suggested keeping the command in a string variable and passing that: ?olecontrol{olecommand} = 45.
3. For events, register a callback from OCX.CLW. A Winsock example: INCLUDE('OCX.CLW'), then OCXREGISTEREVENTPROC(?Winsock,EventFunc), and in EventFunc read OleControl{PROP:LastEventName} and CASE on it. The help section "OLE (.OCX) Custom Controls", "Callback Functions" was also pointed to.

Caveats

  • The thread does not say where the generated OLE class files belong; a pointer to ClarionLive webinars on wrapping an OCX was given instead.
  • One poster saw odd error codes when such a command was called through EVALUATE.

Today (2026)

Not re-tested. The command-string form and PROP:ReportException are likely unchanged.

Sources: Peter K. (Apr 2013, the question), Graham D., Hans K., S R., pblais (Apr 2013) in sv.clarion.clarion8.