FoxPro/Visual FoxPro - Ayuda con imagen

 
Vista:

Ayuda con imagen

Publicado por Juan (40 intervenciones) el 24/05/2013 18:15:07
Buenos días programadores, acudo a ustedes para solicitarles su colaboracion en lo siguiente: necesito tener dentro de un formulario una miscelanea de imagenes diminutas, como circulos, cuadrados, triangulos, que me permita seleccionar dicha imagen y crear una copia para ubicarla en otro punto del formulario, que a la vez me permita guardar y recuperar la imagen y su ubicación.

Gracias por su ayuda
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
sin imagen de perfil
Val: 1.011
Oro
Ha mantenido su posición en FoxPro/Visual FoxPro (en relación al último mes)
Gráfica de FoxPro/Visual FoxPro

Ayuda con imagen

Publicado por Fidel (558 intervenciones) el 25/05/2013 01:26:00
Idea:
Se pueden copiar tomando con Click derecho sobre la imagen y pegando con click izquierdo.
Se pueden copiar las imágenes ya establecidas y las agregadas también.
Todas las imágenes se pueden mover manteniendo presionado click izquierdo y moviendo el ratón.
1) Tienes un formulario creado con algunas imágenes agregadas (control Image)
2) En el formulario debe haber un botón para guardar cambios.
3) Debes agregar 3 métodos de usuario: Getbind, GetCopia y Movimage
4) Usarás INIT, UNLOAD y MOUSEMOVE del formulario.
En el listado siguiente está el código correspondiente a cada sección.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
**********************
* METODOS DE USUSARIO
**********************
* --------------
* GETBIND
* --------------
FOR EACH ocontrol IN thisform.Controls
	IF UPPER(ocontrol.baseclass)="IMAGE"
		UNBINDEVENTS(OCONTROL)
		BINDEVENT(ocontrol,"MouseMove",thisform,"movimage")
		BINDEVENT(oControl,"RightClick",thisform,"getcopia")
	ENDIF
ENDFOR
 
* ----------------
* GETCOPIA
* ----------------
nEvents=AEVENTS(gaEvent,0)
IF nEvents=0
	RETURN
ENDIF
obj=gaEvent[1]
thisform.MousePointer=5
Thisform.imasel=obj.picture
Thisform.copia=.t.
 
* ---------------
* MOVIMAGE
*-----------------
LPARAMETERS nButton, nShift, nXCoord, nYCoord
nEvents=AEVENTS(gaEvent,0)
IF nEvents=0
	RETURN
ENDIF
obj=gaEvent[1]
IF nbutton=1
	WITH obj
		.left=nxCoord
		.top=nyCoord
	ENDWITH
ENDIF
*--------------------------------------------
 
* METODOS DEL FORMULARIO (NATIVOS)
***********************************
* MOUSEDOWN
* -----------
LPARAMETERS nButton, nShift, nXCoord, nYCoord
IF nButton=1
	IF thisform.copia
		thisform.copia=.f.
		IF VARTYPE(thisform.nPicture)#"N"
			thisform.nPicture=1
		else
			thisform.nPicture=thisform.nPicture+1
		ENDIF
		cnew="AddImg"+LTRIM(STR(thisform.nPicture))
		thisform.AddObject(cnew,"Image")
		obj=thisform.&cnew
		WITH obj
			.picture=thisform.imasel
			.left=nxCoord
			.top=nyCoord
			.visible=.t.
		ENDWITH
		thisform.MousePointer=0
		thisform.getbind()
	ENDIF
endif
 
* INIT DEL FORMULARIO
* --------------------
IF !FILE("REMPICT.dbf")
	CREATE TABLE REMPICT FREE ;
	("NOMBRE" C(50),;
	"IMACON" C(20),;
	"IMAPICT" C(80),;
	"IMATOP" I,;
	"IMALEFT" I)
ENDIF
IF !USED("REMPICT")
	USE REMPICT IN 0 EXCLUSIVE
ENDIF
SELECT REMPICT
DELETE TAG ALL
INDEX ON NOMBRE+IMACON TAG REMPICT
cForm=UPPER(thisform.Name)
nPicture=0
SCAN FOR LEFT(nombre,LEN(cform)+1)==cForm+"/"
	cObjeto=ALLTRIM(imacon)
	cImagen=ALLTRIM(imapict)
	nTop=imatop
	nLeft=imaleft
	IF !PEMSTATUS(thisform,cObjeto,5)
		thisform.NewObject(cObjeto,"Image")
		obj=thisform.&cobjeto
		WITH obj
			.picture=cImagen
			.Top=ntop
			.left=nleft
			.Visible=.t.
		ENDWITH
		nPicture=nPicture+1
	ENDIF
ENDSCAN
ADDPROPERTY(thisform,"Imasel","")
ADDPROPERTY(thisform,"Copia","")
ADDPROPERTY(thisform,"nPicture",nPicture)
Thisform.getBind()
* ---------------------------------------------------------
 
* UNLOAD DEL FORMULARIO
* ----------------------
IF USED("REMPICT")
	SELECT REMPICT
	USE
ENDIF
 
 
* ---------------------------
* EVENTO CLICK DE UN BOTON (Grabar / Aceptar)
**********************************************
SELECT rempict
ngrab=0
FOR EACH ocontrol IN thisform.Controls
	IF UPPER(ocontrol.baseclass)="IMAGE"
		cName=UPPER(oControl.name)
		cForm=UPPER(thisform.name)
		nLeft=oControl.left
		nTop=oControl.top
		cPicture=ocontrol.picture
		cBusca=cForm+"/"+cName+"/"
		nGRab=ngrab+1
		IF !INDEXSEEK(cBusca,.f.,"REMPICT","REMPICT")
			INSERT INTO rempict (nombre,imacon,imapict,imatop,imaleft) ;
				values(cBusca,cName,cPicture,ntop,nleft)
		ELSE
			SELECT REMPICT
			INDEXSEEK(cBusca,.t.,"REMPICT","REMPICT")
			REPLACE IMATOP WITH NTOP,IMALEFT WITH NLEFT
		ENDIF
	ENDIF
ENDFOR
thisform.Release
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar