Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Represent Records as Command Buttons
Message
De
29/05/2017 18:07:08
 
 
À
29/05/2017 04:20:57
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Network:
SAMBA Server
Database:
MySQL
Application:
Desktop
Divers
Thread ID:
01651586
Message ID:
01651612
Vues:
102
This message has been marked as a message which has helped to the initial question of the thread.
this is a simple top level form with buttons as you ask.
*Each record of table/cursor is in a button.click on any button to see all record  data.
*the form is scrollable (as container).the scroolbar appears if needed.

_Screen.WindowState=1
Declare Integer Sleep In kernel32 Integer
Publi oform
oform=Newobject("ybuttons")
oform.Show
Read Events
Retu
*
Define Class ybuttons  As Form
	Top = 25
	Left = 102
	Height = 577
	Width = 862
	ShowWindow = 2
	ScrollBars = 2
	Caption = "table record in a commandbutton-click any button to see relative info"
	BackColor = Rgb(212,208,210)
	Name = "form1"

	Procedure ybuild

	Local m.xspace,m.wbutton,m.delta,m.xleft,m.xtop
	m.xtop=20
	m.xleft=40
	m.wbutton=130
	m.delta=2  &&interspace
	m.xspace=Int(Thisform.Width-xleft)/(m.wbutton+m.delta)  &&buttons by row

	Sele ycurs
	With Thisform
		.LockScreen=.T.
		j=0
		k=0
		Scan
			i=Recno()
			Try
				.AddObject("command"+Trans(i),"commandbutton")
			Catch
			Endtry
			With Eval(".command"+Trans(i))
				.Width=m.wbutton
				.Height=34
				.WordWrap=.T.
				Rand(-1)
				.BackColor=Rgb(255*Rand(),255*Rand(),255*Rand())
				.FontBold=.T.
				.MousePointer=15
				.SpecialEffect=2
				.Caption=Trans(Recno())+" "+Allt(ycurs.cust_id)
				j=j+1
				If j<m.xspace
					If i=1
						k=1
						.Left=m.xleft
						.Top=m.xtop
					Else
						.Left=Eval("thisform.command"+Trans(i-1)+".left")+Eval("thisform.command"+Trans(i-1)+".width")+m.delta
						.Top=m.xtop+(k-1)*.Height+m.delta
					Endi
				Else
					k=k+1
					.Left=m.xleft
					.Top=m.xtop+(k-1)*.Height+m.delta
					j=1
				Endi
				.Visible=.T.
				Try
					.Name="command"+Trans(i)
				Catch
				Endtry
			Endwith
			Bindevent(Eval("thisform.command"+Trans(i)),"mousedown",Thisform,"my")
			Sleep(5)  &&to render random  backcolor as well
		Endscan
		.LockScreen=.F.
	Endwith
	Endproc

	Procedure my
	Lparameters nButton, nShift, nXCoord, nYCoord
	*--- aevent create an array laEvents
	Aevents( myArray, 0)
	*--- reference the calling object
	loObject = myArray[1]
	Local N
	N=Int(Val(Substr(loObject.Name,8)))
	Local m.myvar
	m.myvar=""
	Sele ycurs
	Go N
	m.myvar="Record:"+Trans(N)+Chr(13)
	For i=1 To Fcount()
		m.myvar=m.myvar+Field(i)+":"+Trans(Eval(Field(i)))+Chr(13)
	Endfor
	Messagebox(m.myvar,0+32+4096)
	Endproc

	Procedure Destroy
	Clea Events
	Endproc

	Procedure Load
	Close Data All
	Sele * From Home(1)+"samples\data\customer" Into Cursor ycurs
	*brow
	Endproc

	Procedure Init
	Thisform.resize()
	Endproc

	Procedure Resize
	Thisform.ybuild()
	Endproc

Enddefine
*
*-- EndDefine: ybuttons
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform