4 |
The LA Fox DeveloDer Newsletter
|
September
1997
|
Drag and Drop
(Con’t from page 3)
object.
do case
case nState
=
0 && Entering this object
oSource.Draglcon=this.parent.CanTargetlcon
case nState
=
1 && Leaving this object
oSource. Dragicon
=
this. parent.NoDroplcon
endcase
Keep in mind that oSource is “lstSource”, our Drag source. We change the cursor from the circle and slash (NODROP.CUR) to a page with “YES” on it whenever the cursor is over our drop target. Since both our targets are images and behave in the same way, this code is identical for either target.
2. The DragDrop method is what gets executed when the ‘drop” portion occurs. For these two targets the code is nearly identical:
For the Screen Picture object, the code reads:
LPARAMETERS oSource, nXcoord, nYCoord
FOR ncnt
=
I to ThisForm.IstSource.ListCount
if ThisFor.1stSource.selected(nCnt)
?? chr(7)
if messagebox(’View Report Now?', +32,’Vlew’)==l &&OK
cRptNametrim(aReports(nCntj)
report form (cRptName) preview
endif
endf
endfor
and for the Printer Picture Object, the code looks like:
LPARAMETERS oSource, nXCoord, nYCoord
for nCnt
=
I to ThisForm.IstSource.ListCount
if ThisForm.IstSource.selected(nCnt)
?? chr(7)
cRptNametrim(aReports(nCnt])
report form (cRptName) noconsole to print
endif
endif
endfor
No rocket science here, just very little code to produce a feature that
can
impress our clients and make for stimulating conversation at cocktail parties.
Files for this demo were all contained in a single directory. They have been zipped and are available as VFP_DRAG.ZIP on the LA Fox Website at
http://www.mesllc.com/lafox.html.
|
Implementation of ActiveX Controls in Visual FoxPro
by Michael W Thomas, Rocky Mountain FUG
Licensing and Distribution
Licensing of ActiveX controls varies greatly. Some charge the developer a one time fee, sometimes as
low
as a few hundred dollars, while others may charge a “per-seat” fee. Some
OCX’s
also require a license file (generally
have a .LIC extension) to be distributed with the OCX.
When distributing, you must also make sure that the support libraries are also available. For ActiveX, you must have the OLE 2.2 libraries installed. Microsoft packages these files into a self-extracting executable called AXDIST.EXE and is available from their web site. If using an older OLE-compliant control, the MFC libraries are required, the latest being version 4.2. Note that the MFC’s have 16-bit and 32-bit versions with the same file names. Controls created with Visual Basic also require the 1.3MB VB Virtual Machihe DLL(MSVBVM5O.DLL).
ActiveX controls must be registered on each computer running the application in order to be used. Fortunately, ActiveX controls, if written property, are self-registering using regsvr32.exe. In your VFP application, you should check to make sure that die control is registered bekirz. trying to instantiate it or you will receive an error (which may notbe trapable within VFP). Each class has a unique ID that looks like this: {8996B0A1-D7BE- 101 B-8650-00AA003A5593}. All of the classes are registered in the Windows Registry under HKEY_CLASSES_ROOT\CLSID.
OCX’s are generally installed to the \Windows\System directory.
Documentation
The most difficult part of developing applications using ActiveX is finding proper documentation. In short, I have not found adequate documentation on any aspect of ActiveX. Even the Word Basic and VBA command language, used in ActiveX automation, is difficult to find. Finding documentation for Exchange client is nearly impossible. Third-party ActiveX controls will probably offer the most comprehensive documentation, but it is still insufficient, in my experience. Just a warning...
ActiveX Controls in Visual FoxPro
Visual FoxPro is an excellent language in which to work with ActiveX controls. In VFP, ActiveX controls are imbedded in OLEContainer controls. This provides a feature that is unique to VFP: the ability to subclass ActiveX controls. Once the OLEContainer class is defined, it can be instantiated and subclassed as any other VFP class. In the class designer, when you select to create a class based on OLEContainer, you will be prompted with a list of ActiveX controls to choose from.
|
Page 4
|
4 |