Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Subclassing an OCX
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Contrôles ActiveX en VFP
Divers
Thread ID:
00319745
Message ID:
00319791
Vues:
19
>Does anybody know how to subclass an OCX. I want to subclass the MS Treeview control to see if I can reduce the memory required for loading it multiple times. I have been advised to subclass a control on a previous issue but never got around to trying it.

Hi Nigel,

You can also sub-class the control using a prg file. The following code is from my Obj2Bmp application.
DEFINE CLASS CTreeView AS OLECONTROL
  #INCLUDE TreeView.h
  
  .Object.Appearance = 1
  .Object.BorderStyle = 0
  .Object.Height = 185
  .Object.Indentation = 20
  .Object.LabelEdit = tvwManual
  .Object.Left = 12
  .Object.LineStyle = tvwTreeLines
  .Object.MousePointer = 0
  .Object.OLEDragMode = 0
  .Object.OLEDropMode = 0
  .Object.Style = tvwTreelinesPlusMinusPictureText
  .Object.Top = 12
  .Object.Width = 150
  
  Height = 185
  Left = 12
  Top = 12
  Width = 150
  
  PROCEDURE Click
  
    This.Parent.DisableCk.Refresh
  ENDPROC
ENDDEFINE
* The following creates the treeview on the form
IF "6." $ VERSION()
  lctreeclass = "MSComctlLib.Treectrl.2"
ELSE
  lctreeclass = "COMCTL.Treectrl.1"
ENDIF
SET PROCEDURE TO CTView ADDITIVE
This.AddObject('ObjTree', "CTreeView", lctreeclass)
I did this for people running VFP 5.0 that did not have the most recent Treeview control.

Since Obj2Bmp was designed to be run in the development environment licensing isn't an issue. However, in the run time environment, some controls (including the Common Dialogs) require a run time license and may not be able to be created using this method. You'll have to test to determine whether or not this applies to the treeview.
George

Ubi caritas et amor, deus ibi est
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform