OCX in Procedure (.p)

adamrussell

New Member
Does anyone have any knowledge or experience in attaching/creating an OCX within a procedure? I know how to do it within a window, but I have not been able to do it in a procedure.

Thanks in advance.
 

lord_icon

Member
Your missing the point. If you wish to embed a control, then that is GUI and you WILL need a container source (a window).
However you can access control attributes & functions to perform actions from CHAR. This is similar to accessing a dll. Though what is the point of using a ocx if you are using CHAR not GUI?
 

TomBascom

Curmudgeon
pstimer would be a fairly obvious example of an ocx that would be just as useful for ChUI as it is GUI.
 
Here is a chunk of code I wrote years ago to something similar (assuming I understand your request).

It's meant to be run persistently. Basically, you pass it the handle of the frame on which you want to place the OCX control. Obviously, the .WRX has to have already been created.

I'm sure it could be implemented much more nicely these days.

/*- rtb_treeview.p
*- Jeff Ledbetter
*- August 1998
Instantiates an OCX on a given frame. This allows us to create a .WRX file
for a window once, and use it in several places.
*/

DEFINE INPUT PARAMETER Pcall-proc-frame AS HANDLE NO-UNDO.
DEFINE INPUT PARAMETER Prow AS INTEGER NO-UNDO.
DEFINE INPUT PARAMETER Pcolumn AS INTEGER NO-UNDO.
DEFINE INPUT PARAMETER Pheight AS INTEGER NO-UNDO.
DEFINE INPUT PARAMETER Pwidth AS INTEGER NO-UNDO.
DEFINE INPUT PARAMETER Phidden AS LOGICAL NO-UNDO.
DEFINE INPUT PARAMETER Psensitive AS LOGICAL NO-UNDO.
DEFINE INPUT PARAMETER Pparent-proc AS HANDLE NO-UNDO.

DEFINE OUTPUT PARAMETER Pocx-handle AS COMPONENT-HANDLE NO-UNDO.
DEFINE OUTPUT PARAMETER Pocx-frame AS WIDGET-HANDLE NO-UNDO.

/*- frame to hold control and handle to the control itself -*/
DEFINE VARIABLE Mocx-frame AS WIDGET-HANDLE NO-UNDO.
DEFINE VARIABLE Mch-ocx-frame AS COMPONENT-HANDLE NO-UNDO.

/*- other variables -*/
DEFINE VARIABLE UIB_S AS LOGICAL NO-UNDO.
DEFINE VARIABLE OCXFile AS CHARACTER NO-UNDO.

CREATE CONTROL-FRAME Mocx-frame
ASSIGN FRAME = Pcall-proc-frame
ROW = Prow
COLUMN = Pcolumn
HEIGHT = Pheight
WIDTH = Pwidth
HIDDEN = Phidden
SENSITIVE = Psensitive.
Mocx-frame:NAME = "TreeViewCtrlFrame":U.

OCXFile = SEARCH("treeview.wrx":U).

ASSIGN Mch-ocx-frame = Mocx-frame:COM-HANDLE
UIB_S = Mch-ocx-frame:LoadControls(OCXFile, "TreeViewCtrlFrame":U).

ASSIGN Pocx-handle = Mch-ocx-frame
Pocx-frame = Mocx-frame.

RETURN.
PROCEDURE TreeViewCtrlFrame.TreeView.NodeClick:
DEFINE INPUT PARAMETER Pnode AS COM-HANDLE.
RUN treeview_nodeclick IN Pparent-proc (Pnode).
END PROCEDURE.

PROCEDURE TreeViewCtrlFrame.TreeView.Expand:
DEFINE INPUT PARAMETER Pnode AS COM-HANDLE.
RUN treeview_expand IN Pparent-proc (Pnode).
END PROCEDURE.

PROCEDURE TreeViewCtrlFrame.TreeView.MouseUp:
DEFINE INPUT PARAMETER Pbutton AS INTEGER.
DEFINE INPUT PARAMETER Pshift AS INTEGER.
DEFINE INPUT PARAMETER Px AS INTEGER.
DEFINE INPUT PARAMETER Py AS INTEGER.
RUN treeview_mouseup IN Pparent-proc (Pbutton).
END PROCEDURE.
 
Top