Advertisement
jsbsan

Copiar un control

Aug 3rd, 2013
466
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
GAMBAS 0.79 KB | None | 0 0
  1. PUBLIC SUB ControlCopy(hControl AS OBJECT, Parent AS Container) AS OBJECT
  2.  
  3. DIM hNewMe AS OBJECT = Object.New(Object.Type(hControl), [Parent]) 'on génère un objet de la même classe
  4. DIM s AS STRING
  5. DIM hclass AS Class = Object.Class(hControl)
  6. DIM hChild AS OBJECT
  7. 'On copie les propriétés
  8. FOR EACH s IN hclass.Symbols
  9. IF s = "Chlidren" THEN CONTINUE
  10. IF NOT hclass[s].ReadOnly THEN Object.SetProperty(hNewMe, s, Object.GetProperty(hControl, s))
  11.  
  12. NEXT
  13.  
  14. 'Bon la en vrai Basic j'aurais du passé par un goto :/
  15. 'en gros si ce n'est pas un conteneur on quitte et on retourne le nouvel objet
  16. IF NOT hclass.Symbols.Exist("Children") THEN RETURN hNewMe
  17.  
  18. 'On copie les enfants
  19. FOR EACH hChild IN hControl.Children
  20. ControlCopy(hChild, hNewMe)
  21. NEXT
  22. 'On retourne l'enfant
  23. RETURN hNewMe
  24.  
  25. END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement