document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. \' Gambas class file
  2.  
  3. \'Nota Importante:
  4. \'debe de estar activado el componente gb.settings
  5. Public FormaAdaptacion As Integer \'\'0-> se adapta al formato inicial; 1-> se adapta al formulario, deformandose la imagen de fondo
  6.  
  7. Public Sub crearPosiciones(f As Form)
  8.  
  9.   Dim c As Object
  10.   \'guardo datos del formulario
  11.   Settings[f.name & "/X"] = f.x
  12.   Settings[f.name & "/Y"] = f.y
  13.   Settings[f.name & "/W"] = f.w
  14.   Settings[f.name & "/H"] = f.h
  15.   \'guardo todas las posiciones de todos los controles
  16.   For Each c In f.Controls
  17.    
  18.     Settings[c.name & "/X"] = c.x
  19.     Settings[c.name & "/Y"] = c.y
  20.     Settings[c.name & "/W"] = c.width
  21.     Settings[c.name & "/H"] = c.height
  22.    
  23.   Next
  24.  
  25. End
  26.  
  27. Public Sub restaurarPosiciones(f As Form)
  28.  
  29.   Dim fdato_x As Integer
  30.   Dim fdato_y As Integer
  31.   Dim fdato_w As Integer
  32.   Dim fdato_h As Integer
  33.   Dim cdato_x As Integer
  34.   Dim cdato_y As Integer
  35.   Dim cdato_w As Integer
  36.   Dim cdato_h As Integer
  37.  
  38.   Dim c As Object
  39.  
  40.   fdato_x = Settings[f.name & "/X"]
  41.   fdato_y = Settings[f.name & "/Y"]
  42.   fdato_w = Settings[f.name & "/W"]
  43.   fdato_h = Settings[f.name & "/H"]
  44.  
  45.   If FormaAdaptacion = 0 Then
  46.    
  47.     For Each c In f.Controls
  48.      
  49.       cdato_x = Settings[c.name & "/X"]
  50.       cdato_y = Settings[c.name & "/Y"]
  51.       cdato_w = Settings[c.name & "/W"]
  52.       cdato_h = Settings[c.name & "/H"]
  53.      
  54.       c.x = cdato_x * f.w / fdato_w
  55.       c.y = cdato_y * f.w / fdato_w
  56.       c.h = cdato_h * f.w / fdato_w
  57.       c.w = cdato_w * f.w / fdato_w
  58.      
  59.     Next
  60.     f.h = fdato_h * f.w / fdato_w
  61.   Else
  62.     \'se adapta a las dimensiones del formulario, pudiendose alterar las imagenes de fondo...
  63.     \'Gracias a las explicaciones de Pablo Redondo (alaplancha),
  64.     \'cambios producidos....
  65.     For Each c In f.Controls
  66.      
  67.       cdato_x = Settings[c.name & "/X"]
  68.       cdato_y = Settings[c.name & "/Y"]
  69.       cdato_w = Settings[c.name & "/W"]
  70.       cdato_h = Settings[c.name & "/H"]
  71.      
  72.       \'paso 1 cambio del sistema de coordenas al centro
  73.       c.x = (cdato_x - fdato_w / 2)
  74.       c.y = (cdato_y - fdato_h / 2)
  75.      
  76.       \'aplico scala eje X y eje Y
  77.       c.x = c.x * f.w / fdato_w
  78.       c.y = c.y * f.h / fdato_h
  79.       \'
  80.      
  81.       \'cambio de sistema de coordenadas
  82.       c.x = c.x + f.w / 2
  83.       c.y = c.y + f.h / 2
  84.      
  85.       \'escalo anchos y largos    
  86.       c.h = cdato_h * f.h / fdato_h
  87.       c.w = cdato_w * f.w / fdato_w
  88.      
  89.     Next
  90.    
  91.   Endif
  92.  
  93. End
');