Message
From
28/12/2016 13:35:37
 
 
To
28/12/2016 09:22:42
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 10
Network:
Windows Server 2012
Database:
MS SQL Server
Application:
Robot
Miscellaneous
Thread ID:
01646151
Message ID:
01646163
Views:
75
i give you this code to make scrollbars appear only when needed.
please test this code below
*testing the grid scrollbars dynamically.
*scrollbars appear when needed only

_screen.windowstate=1

Publi myform
myform=Newobject("yscroll")
myform.Show
Read Events
Retu
*
Define Class yscroll As Form
	Height = 346
	Width = 759
	ShowWindow = 2
	AutoCenter = .T.
	Caption = "Testing scrollbars dynamically."
	Name = "Form1"

	Add Object grid1 As Grid With ;
		Anchor = 15, ;
		Height = 277, ;
		Left = 11, ;
		ScrollBars = 0, ;
		Top = 5, ;
		Width = 733, ;
		Name = "Grid1"

	Add Object command1 As CommandButton With ;
		Top = 307, ;
		Left = 183, ;
		Height = 27, ;
		Width = 84, ;
		Anchor = 768, ;
		Caption = "No scrollbars", ;
		BackColor = Rgb(128,255,0), ;
		Name = "Command1"

	Add Object optiongroup1 As OptionGroup With ;
		AutoSize = .T., ;
		ButtonCount = 4, ;
		Anchor = 768, ;
		Value = 1, ;
		Height = 27, ;
		Left = 305, ;
		Top = 307, ;
		Width = 264, ;
		Name = "Optiongroup1", ;
		Option1.Caption = "Test1", ;
		Option1.Value = 1, ;
		Option1.Height = 17, ;
		Option1.Left = 5, ;
		Option1.Style = 0, ;
		Option1.Top = 5, ;
		Option1.Width = 61, ;
		Option1.AutoSize = .F., ;
		Option1.Name = "Option1", ;
		Option2.Caption = "Test2", ;
		Option2.Height = 17, ;
		Option2.Left = 68, ;
		Option2.Style = 0, ;
		Option2.Top = 5, ;
		Option2.Width = 61, ;
		Option2.AutoSize = .F., ;
		Option2.Name = "Option2", ;
		Option3.Caption = "Test3", ;
		Option3.Height = 17, ;
		Option3.Left = 131, ;
		Option3.Style = 0, ;
		Option3.Top = 5, ;
		Option3.Width = 61, ;
		Option3.AutoSize = .F., ;
		Option3.Name = "Option3", ;
		Option4.Caption = "Test4", ;
		Option4.Height = 17, ;
		Option4.Left = 198, ;
		Option4.Top = 5, ;
		Option4.Width = 61, ;
		Option4.Name = "Option4"

	Add Object label1 As Label With ;
		AutoSize = .T., ;
		FontBold = .T., ;
		FontSize = 10, ;
		Anchor = 768, ;
		Caption = "Grdid.scrollbars=0", ;
		Height = 18, ;
		Left = 587, ;
		Top = 309, ;
		Width = 117, ;
		ForeColor = Rgb(255,0,0), ;
		BackColor = Rgb(255,255,128), ;
		Name = "Label1"

	Procedure yscroll
		Local m.x,m.y
		With Thisform.grid1
			m.x=0
			For i=1 To .ColumnCount
				m.x=m.x+.Columns(i).Width
			Endfor
			m.x=m.x+.ColumnCount*.GridLineWidth+2*Sysmetric(5)
			m.y=(.RowHeight+.GridLineWidth)*Reccount()+Sysmetric(6)

			Do Case
				Case m.x<.Width And m.y<.Height
					.ScrollBars=0
				Case m.x<.Width And m.y>.Height
					.ScrollBars=2
				Case m.x>.Width And m.y<.Height
					.ScrollBars=1
				Case m.x>.Width And m.y>.Height
					.ScrollBars=3
			Endcase

			.Refresh
		Endwith
	Endproc

	Procedure Load
		Close Data All
	Endproc

	Procedure grid1.Init
		With This
			.RecordSource=""
			.GridLines=0
			.DeleteMark=.F.
			.ScrollBars=0
			.Refresh
		Endwith
	Endproc

	Procedure command1.Click
		Thisform.grid1.ScrollBars=0
	Endproc

	Procedure optiongroup1.InteractiveChange
		Thisform.label1.Caption="Grid.scrollbars="+Trans(Thisform.grid1.ScrollBars)
	Endproc

	Procedure optiongroup1.Option1.Click
		Sele * From Home(1)+"samples\data\customer" Where Recn()<5 Into Cursor ycurs

		With Thisform.grid1
			.RecordSource="ycurs"
			.Refresh
		Endwith
		Thisform.yscroll()
	Endproc

	Procedure optiongroup1.Option2.Click
		Sele  fax,address From Home(1)+"samples\data\customer" Into Cursor ycurs
		With Thisform.grid1
			.RecordSource="ycurs"
			.Refresh
		Endwith
		Thisform.yscroll()
	Endproc

	Procedure optiongroup1.Option3.Click
		Sele * From Home(1)+"samples\data\customer" Into Cursor ycurs
		With Thisform.grid1
			.RecordSource="ycurs"
			.Refresh
		Endwith
		Thisform.yscroll()
	Endproc


	Procedure optiongroup1.Option4.Click
		Sele  fax,address From Home(1)+"samples\data\customer"  Where Recno()<6Into Cursor ycurs
		With Thisform.grid1
			.RecordSource="ycurs"
			.Refresh
		Endwith
		Thisform.yscroll()
	Endproc


Enddefine
*
*-- EndDefine: yscroll
Note: see your country at the first time, never know it.......i search in google soon.
Happy new year 2017.
Previous
Next
Reply
Map
View