* With the project open FOR EACH oFile IN _VFP.ActiveProject.Files IF oFile.Type="K" && form * Open the form either in the Form Designer MODIFY FORM (oFile) NOWAIT AssignUniqueControlIDs() Keyboard '{Ctrl-W}' ENDIF ENDFORUnfortunately, the Ctrl+W doesn't work, so the form does not save.
Procedure AssignUniqueControlIDs * Assigns Unique IDs to all objects on this form * (Used as a builder, called when Form is open in Form Designer) Local loForm loForm = GetTarget() If "O" = Vartype (loForm) DrillControls (loForm) Endif Return * Following programs from Tamar Granor * Modified by Jim Nelson 05/20/2008 *============================================================================== * Program: ControlRenamer.PRG * Purpose: Main class for Control Renamer Builder * Copyright: (c) 2005 Tamar E. Granor, Ph.D. * Last revision: 05/02/05 * Notes: You may freely distribute this builder * as long as this header is retained. * Contact: tamar@thegranors.com *============================================================================== Procedure GetTarget * Grab a reference to the top-level control/form Local aSelected[1], oTarget, oLast If Aselobj(aSelected) = 0 If Aselobj(aSelected, 1) = 0 oTarget = .Null. Endif Endif If Vartype(aSelected[1]) = "O" oTarget = aSelected[1] Do While Upper(oTarget.Parent.BaseClass)<>"FORMSET" oLast = oTarget oTarget = oTarget.Parent Enddo * Form class/form or something else? If not a form class * need to go back down one level If Not Pemstatus(oTarget, "BufferMode", 5) * It's not a real form; it's the pseudo-form * represented by the Class Designer oTarget = oLast Endif Else oTarget = .Null. Endif Return oTarget Endproc Procedure DrillControls(oContainer) * Assign property C_UniqueID (unless already assigned for all children) * and then repeat for all THEIR children. Local Array aControls[1] Local nControls, oObject, nControl nControls = Amembers(aControls, oContainer, 2) For nControl = 1 To nControls oObject = Evaluate("oContainer." + aControls[nControl]) AssignUniqueID (oObject) * Drill down If Pemstatus(oObject, "Objects", 5) DrillControls(oObject) Endif Endfor Return nControls Endproc Procedure AssignUniqueID (oObject) * assign C_UniqueID unless already assigned If Pemstatus (oObject, "h_UniqueID", 5) And Empty (oObject.h_UniqueID) oObject.AddProperty( "h_UniqueID", Sys(2015)) Endif Endproc