|
-
Nov 22nd, 2000, 01:20 PM
#1
Thread Starter
Addicted Member
Hi, im having a little trouble with this.
Code:
Option Compare Text
Option Explicit
Public WithEvents Boton As CommandButton 'Crea Botones para colocarse en frmDropWindow
Public WithEvents bLabel As Label 'Crea los Labels
Public WithEvents bFrame As Frame 'Crea los frames
Public globalX As Integer 'Equivale a la posicion X del raton en la pantalla
Public globalY As Integer 'Equivale a la posision Y del raton en la pantalla
Public ControlName As String 'Le coloca un nombre al nuevo control
Public ControlCaption As String 'Le cambia el Caption al nuevo control
Public Opciones As Integer 'Para conocer cual boton se presiono para crear el control
Public strTemp As String 'String a convertirse en instruccion
Public bIndex As Integer 'Index para poder crar mas instancias de Boton
'Funcion para convertir un string en un comando.
Private Declare Function EbExecuteLine Lib "vba6.dll" _
(ByVal pStringToExec As Long, ByVal Foo1 As Long, _
ByVal Foo2 As Long, ByVal fCheckOnly As Long) As Long
Private Sub CrearFrame_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
CrearFrame.Drag vbBeginDrag
globalX = X
globalY = Y
Opciones = 3
End Sub
Private Sub CrearLabel_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
CrearLabel.Drag vbBeginDrag
globalX = X
globalY = Y
Opciones = 2
End Sub
Private Sub CrearBoton_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
CrearBoton.Drag vbBeginDrag
globalX = X
globalY = Y
Opciones = 1
End Sub
Private Sub Form_DragDrop(Source As Control, X As Single, Y As Single)
CrearBoton.Move X - globalX, Y - globalY
CrearLabel.Move X - globalX, Y - globalY
CrearFrame.Move X - globalX, Y - globalY
End Sub
Public Sub Creacion(Source As Control, X As Single, Y As Single)
'Funcion para crear los controles en la forma frmDropWindow
If Opciones = 1 Then
bIndex = bIndex + 1
'ControlName = InputBox("Entra el nombre del control, es una variable, debe ser un nombre unico, que no comienze con numeros y que no tenga espacios!!!.", "Control Name")
Set Boton = frmDropWindow.Controls.Add("VB.CommandButton", Boton(bIndex))
Boton.Visible = True
Boton.Caption = InputBox("Entra el caption para el boton.", "Caption")
Boton.Move X - globalX, Y - globalY
Else
If Opciones = 2 Then
ControlName = InputBox("Entra el nombre del control, es una variable, debe ser un nombre unico, que no comienze con numeros y que no tenga espacios!!!.", "Control Name")
Set bLabel = frmDropWindow.Controls.Add("VB.Label", ControlName)
bLabel.Visible = True
bLabel.Caption = InputBox("Entra el caption para el boton.", "Caption")
bLabel.Move X - globalX, Y - globalY
Else
If Opciones = 3 Then
ControlName = InputBox("Entra el nombre del control, es una variable, debe ser un nombre unico, que no comienze con numeros y que no tenga espacios!!!.", "Control Name")
Set bFrame = frmDropWindow.Controls.Add("VB.Frame", ControlName)
bFrame.Visible = True
bFrame.Caption = InputBox("Entra el caption para el boton.", "Caption")
bFrame.Move X - globalX, Y - globalY
End If 'Opcion 1
End If 'Opcion 2
End If 'Opcion 2
End Sub
Private Sub Form_Load()
frmDropWindow.Show
bIndex = 0
End Sub
Function FExecuteCode(stCode As String, _
Optional fCheckOnly As Boolean) As Boolean
'Aqui se convierte el string en una instruccion.
FExecuteCode = EbExecuteLine(StrPtr(stCode), 0&, 0&, Abs(fCheckOnly)) = 0
End Function
Private Sub Form_DragDrop(Source As Control, X As Single, Y As Single)
frmToolBox.Creacion Source, X, Y
End Sub
The problem is that if i create a sub to add funcioality to Boton it will onli work with a new instance of it, if i create another, the old instace wont work again, is there away around that?
Thanks in advance!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|