Programacion orientada a objetos VFP 7.0

¿Como se puede programar un form desde un prg, esto es, sin utilizar el generador de forms?
¿Como se utiliza OLE DB para acceder a una base de datos Oracle desde VFP 7.0?
1

1 respuesta

1
Respuesta de
Con respecto de tu pregunta 1
Te pongo un ejemplo:
forma = CREATEOBJECT("form")
forma.show
READ events
DEFINE CLASS form1 AS form
Top = 7
Left = 75
Height = 280
Width = 422
DoCreate = .T.
ShowTips = .T.
Caption = "Graficador Davphantom"
Name = "Form1"
ADD OBJECT label2 AS label WITH ;
BorderStyle = 1, ;
Caption = "", ;
Height = 1, ;
Left = 300, ;
Top = 168, ;
Width = 37, ;
BackColor = RGB(255,0,0), ;
Name = "Label2"
ADD OBJECT label3 AS label WITH ;
BorderStyle = 1, ;
Caption = "", ;
Height = 0, ;
Left = 372, ;
Top = 168, ;
Width = 37, ;
BackColor = RGB(255,255,0), ;
Name = "Label3"
ADD OBJECT text1 AS textbox WITH ;
Alignment = 3, ;
Value = 0, ;
Format = "", ;
Height = 25, ;
InputMask = "", ;
Left = 24, ;
Top = 48, ;
Width = 97, ;
Name = "Text1"
ADD OBJECT text2 AS textbox WITH ;
Alignment = 3, ;
Value = 0, ;
Format = "", ;
Height = 25, ;
InputMask = "", ;
Left = 24, ;
Top = 84, ;
Width = 97, ;
Name = "Text2"
ADD OBJECT text3 AS textbox WITH ;
Alignment = 3, ;
Value = 0, ;
Format = "", ;
Height = 25, ;
InputMask = "", ;
Left = 24, ;
Top = 120, ;
Width = 97, ;
Name = "Text3"
ADD OBJECT command1 AS commandbutton WITH ;
Top = 168, ;
Left = 12, ;
Height = 25, ;
Width = 121, ;
Caption = "Generar Gráfico", ;
Name = "Command1"
ADD OBJECT label1 AS label WITH ;
BackStyle = 1, ;
BorderStyle = 1, ;
Caption = "", ;
Height = 1, ;
Left = 228, ;
Top = 168, ;
Width = 37, ;
BackColor = RGB(0,0,255), ;
Name = "Label1"
ADD OBJECT label6 AS label WITH ;
AutoSize = .T., ;
FontBold = .F., ;
FontName = "MS Sans Serif", ;
FontSize = 9, ;
WordWrap = .T., ;
BackStyle = 1, ;
Caption = "Digite los valores que desee graficar, en este caso solo son 3 valores pero podra hacerlo para los que desee. El truco es simplemente una regla de 3. Observen el código", ;
Height = 41, ;
Left = 12, ;
Top = 7, ;
Width = 382, ;
Name = "Label6"
ADD OBJECT command2 AS commandbutton WITH ;
Top = 204, ;
Left = 288, ;
Height = 27, ;
Width = 84, ;
Caption = "Command2", ;
Name = "Command2"
PROCEDURE command1.Click
* Determino cual es el mayor valor de los 3 digitado
IF thisform.Text1.Value > thisform.text2.Value and thisform.Text1.Value > thisform.text3.Value
valmayor = thisform.Text1.Value
ELSE
IF thisform.Text2.Value > thisform.text3.Value
valmayor = thisform.Text2.Value
ELSE
valmayor = thisform.Text3.Value
ENDIF
ENDIF
*****************************************************
* REALIZA EL GRAFICO CON UNA REGLA DE TRES *
*****************************************************
thisform.LockScreen = .t.
thisform.Label1.Height = (200 * thisform.Text1.Value)/valmayor
thisform.Label2.Height = (200 * thisform.Text2.Value)/valmayor
thisform.Label3.Height = (200 * thisform.Text3.Value)/valmayor
thisform.Label3.Top = 247 - thisform.Label3.Height
thisform.Label2.Top = 247 - thisform.Label2.Height
thisform.Label1.Top = 247 - thisform.Label1.Height
thisform.LockScreen = .f.
ENDPROC
PROCEDURE command2.Click
lcFile = GETFILE("DOC")
loWord = CREATEOBJECT("Word.Application")
loWord.Documents.Open(lcFile)
loWord.Application.Visible = .T.
RELEASE loWord
ENDPROC
ENDDEFINE
Con respecto de tu pregunta 2:
Creas el DSN (supongo que ya sabes como hacerlo) y después lo accesas así:
Nhandle = SQLCONNECT('basededatos','User','password')
if Nhandle>0 Then
if S
Añade un comentario a esta respuesta
Añade tu respuesta
Haz clic para o
Escribe tu mensaje
¿No es la respuesta que estabas buscando? Puedes explorar otras preguntas del tema Visual Fox Pro o hacer tu propia pregunta: