Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Want to remove Command Group
Message
From
18/12/2000 13:24:44
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00454738
Message ID:
00454747
Views:
20
>I have a form that has several command buttons. Each button is contained within its' own command group. I would like to preserve the button but remove the command group. Is there anyway to do this?
>
>Brenda

You'd have to create new buttons on the form. I would suggest hacking the VCX or SCX, but in this case it would be problematic since each button in a command group doesn't have its own record.
*-- make sure form designer is open
If ASelObj(laObj,1)=1
     oForm = laObj[1]
Else
     Messagebox("No form designer open.")
     Return
EndIf
*-- make sure object is a command group
If ASelObj(laObj)=1 And Upper(laObj[1].BaseClass)="COMMANDGROUP"
     oGrp = laObj[1]
Else
     MessageBox("No object selected or object is not a command group.")
     Return
EndIf
For Each oBtn In oGrp.Buttons
     *--     create new button on form with same name as button in group
     Store oBtn.Name To lcOldName, lcNewName
     lnCnt = 0

     *--     no duplcate objects - tag a number to the end if it exists
     Do While Type("oForm."+lcNewName)="O"
          lnCnt = lnCnt + 1
          lcNewName = lcOldName + Transform(lnCnt)
     EndDo
     oForm.NewObject(lcNewName, "commandbutton")
     oNew = oForm.&lcNewName
     *-- get pems for button
     *     and set them for new button
     AMembers(laMem,oBtn,1)
     For ji = 1 To ALen(laMem,1)
          lcMem = laMem[ji,1]
          Do Case
          Case laMem[ji,2]="Property" 
               If !PEMStat(oNew,lcMem,1) And !lcMem=="NAME"
                    *--     not read-only, write to new button
                    oNew.&lcMem = oBtn.&lcMem
               EndIf
          Case Inlist(laMem[ji,2],"Method","Event")
               lcCode =oBtn.ReadMethod(lcMem)
               If !Empty(lcCode)
                    *--     have code, write it to the new button
                    oNew.WriteMethod(lcMem, lcCode)
               EndIf
          EndCase
     EndFor
EndFor
Insanity: Doing the same thing over and over and expecting different results.
Previous
Reply
Map
View

Click here to load this message in the networking platform