Adding the Control to a Project: Clarion Users
The following is a customer provided example for using the Flipper CAD Control in Clarion v.5b.
!!! This is an example of how to implement the Flipper Cad Active X .DLL
!!! Developed using Clarion for Windows Version 5b.
!!!
!!! In addition to this module, you will need to...
!!!
!!! -- Create a Project File that includes this Source File.
!!! -- Set the Project Compile Options to 32 bit.
!!!
include('keycodes.clw') ! Clarion Keycode Equates
include('ocxevent.clw') ! Constants that OCX events use
MAP
include('Ocx.CLW')
EventFunc procedure(*SHORT Reference,SIGNED OleControl,LONG CurrentEvent),LONG
.
ocxname STRING(64)
x_coor Long
y_coor Long
w WINDOW('Flipper Cad'),AT(,,422,253),FONT('MS Sans Serif',8,,FONT:regular),CENTER,SYSTEM,GRAY
MENUBAR
MENU('&File')
ITEM('E&xit'),USE(?Close)
END
MENU('&Properties')
ITEM('&Custom'),USE(?custom)
END
END
OLE,AT(3,7,343,230),USE(?Ole1)
END
BUTTON('Rectangle'),AT(369,34,45,14),USE(?rectangle)
BUTTON('Circle'),AT(369,52,45,14),USE(?circle)
STRING('X: '),AT(10,241),USE(?x_String),RIGHT
STRING(@n_7),AT(19,241),USE(x_coor)
STRING('Y: '),AT(76,241),USE(?y_String),RIGHT
STRING(@n_7),AT(85,241),USE(y_coor)
END
code
open(w)
display
ocxname = 'FlpCad.FlpCad.1' ! Set up the OLE Object
?ole1{PROP:create}=ocxname
if ?ole1{PROP:license}<>'' ! The control supports licence
?ole1{PROP:create}=CLIP(ocxname)&'\!' & ?ole1{PROP:license}
if ~?ole1{PROP:ole}
?ole1{PROP:create}=ocxname
. .
OCXREGISTEREVENTPROC(?Ole1,EventFunc) ! Register Event processing Callback
?ole1{PROP:ReportException} = TRUE ! Turn on Error Reporting
?ole1{ 'WorldSet(0,1000,1000,0)' } ! Set the World to 1000 units square
?ole1{ 'WorldSquare' } = True ! Set the World Square
?ole1{ 'GridWidth' } = 20 ! Grid Width of 20 units
?ole1{ 'GridHeight' } = 20 ! Grid Height of 20 Units
?ole1{ 'GridOn' } = True ! Turn the Grid On
?ole1{ 'ViewSnapToGrid' } = 2 ! Invoke Grid Snapping
?ole1{ 'DrawLine(10,10,590,590,1)' } ! Draw a Line on Layer #1
?ole1{ 'Refresh' } ! Refresh the view
accept
case(event())
of event:accepted
CASE Accepted()
OF ?custom
?ole1{PROP:doverb}= -7 ! Call Flipper Cad Color Screen
?ole1{'Refresh'} ! Refresh the view
of ?rectangle
?ole1 { 'ShapeType' } = 1 ! Set Shapetype to Rectangle
of ?circle
?ole1 { 'ShapeType' } = 19 ! Set Shapetype to Circle
OF ?close
break
. . .
?ole1{PROP:deactivate}=1
return
EventFunc PROCEDURE(*SHORT Reference,SIGNED OleControl,LONG CurrentEvent)
Count LONG !Event processing callback function
Res CSTRING(200)
Parm CSTRING(30)
code
case (OleControl{PROP:LastEventName})
of 'WorldMouseMove' ! Show World Coordinates on Screen
x_coor = OCXGETPARAM(Reference,2)
y_coor = OCXGETPARAM(Reference,3)
display
return(True)
of 'WorldMouseDown'
return(True)
of 'WorldMouseUp'
return(True)
of 'ShapeNumberSelected'
! stop('Shape Selected')
.
!!!!! This loop shows how to return all parameters from a returned event...
Res = 'Event: ' & OleControl{PROP:LastEventName}
loop Count = 1 TO OCXGETPARAMCOUNT(Reference) ! Cycle through all parameters
Parm = OCXGETPARAM(Reference,Count) ! getting each parameter name
Res = CLIP(Res) & ' - ' & Parm ! and concatenate them together
.
return(True)
Last modified on: Tuesday, February 04, 2003