/ Forums / Advansys Formativ / Formativ Creator / Using OCX with formativ

  • Creator
    Topic
  • #3596
    G.Gentien
    Participant

    Hi,

    I’m tring to use an Ocx (created with VB) in a formativ form, How can i reference this OCX in my vbs code or in formativ ?

    thanks
    Gil

  • Author
    Replies
  • #5562
    Support 1
    Participant

    Thank you for your enquiry.

    An OCX is a COM component/object, which must be used in the same way with any scripting language. The component’s ProgID is used to create an instance; eg. if your OCX is “AllenKey”, implemented in the file AcmeTools.OCX, the ProgId might be “AcmeTools.AllenKey”.

    Here is a sample VBScript function to create and return an instance of the Microsoft Word Application object:

    function OpenWord
    
      dim iName
      dim oDoc
      dim oResult
    
      ' GetObject (below) will raise an error if Word is not running,
      ' so suppress normal error handling.
      on error resume next
    
      ' Initialize oResult so we have a value to compare later.
      set oResult = nothing
    
      ' Attempt to reference a running Word instance.
      set oResult = GetObject(, "Word.Application")
    
      if Err.Number <> 0 then
        call Err.Clear
      end if
    
      if oResult is nothing then
        ' Create an instance of the Word application.
        set oResult = CreateObject("Word.Application")
      end if
    
      set OpenWord = oResult
    
    end function

    I hope this helps you.

    Regards,
    Advansys Support

    #5563
    G.Gentien
    Participant

    Hi,

    My OCX dont work in this way, I have to include it in the form to use it (like à grid). How can i do in this case to reference it in formativ( like the spécial grig you have in the special menu).

    thanks for your help

    Gil

    #5564
    Support 1
    Participant

    Thank you for clarifying your requirement.

    Unfortunately it is not possible to use a visual ActiveX control on a Formativ Form (ie. apart from those ActiveX controls already on Formativ’s component palette).

    To make your OCX usable with a Formativ applet, I suggest you create another OCX/DLL which exposes a Form using this control in the way you require. Then your Formativ applet can create an instance of the Form OCX/DLL. Of course the Form should provide methods/properties for all input/output required by the applet.

    For related information see also this post.

    I hope this helps you.

    Regards,
    Advansys Support

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.