在頁框中添加垂直滾動條的實現方法
程序代码:
CLEAR ALL CLEAR Main() CLEAR ALL RETURN PROCEDURE Main() LOCAL loMainForm loMainForm = CREATEOBJECT("_MainForm") WITH loMainForm .Caption = "頁框嵌入滾動條實例程序" .MinWidth = 800 .MinHeight = 600 .AutoCenter = .T. .Show ENDWITH READ EVENTS ENDPROC DEFINE CLASS _MainForm AS Form ADD OBJECT PageFrame1 AS PageFrame PROCEDURE Arrange LOCAL lnIndex WITH ThisForm.PageFrame1 .Top = 5 .Left = 5 .Height = ThisForm.Height - .Top - 5 .Width = ThisForm.Width - .Left - 5 FOR lnIndex = 1 TO .PageCount IF .Pages(lnIndex).ControlCount > 0 WITH .Pages(lnIndex).Controls(1) .Top = 0 .Left = 0 .Height = ThisForm.PageFrame1.Height .Width = ThisForm.PageFrame1.Width .Arrange ENDWITH ENDIF NEXT ENDWITH ENDPROC PROCEDURE Activate ThisForm.Arrange ENDPROC PROCEDURE Resize ThisForm.Arrange ENDPROC PROCEDURE Destroy CLEAR EVENTS ENDPROC PROCEDURE PageFrame1.Init WITH This .PageCount = 3 WITH .Pages(1) .AddObject("Container1", "_WithScrollBar") .Container1.Visible = .T. ENDWITH ENDWITH ENDPROC ENDDEFINE DEFINE CLASS _WithScrollBar AS Container ADD OBJECT ScrollBar1 AS OleControl WITH OleClass = "MSComCtl2.FlatScrollBar.2" ADD OBJECT Label1 AS Label WITH Height = 25, AutoSize = .T., Caption = "請滾動右側滾動條觀察效果:", Origin_Top = 100 ADD OBJECT Text1 AS TextBox WITH Height = 25, Width = 100, Origin_Top = 100 PROCEDURE Arrange WITH This.Label1 .Top = .Origin_Top .Left = 10 ENDWITH WITH This.Text1 .Top = .Origin_Top .Left = This.Label1.Left + This.Label1.Width ENDWITH WITH This.ScrollBar1 .Top = 0 .Left = This.Width - 22 .Height = This.Height - 30 ENDWITH ENDPROC PROCEDURE ScrollBar1.Init WITH This .Orientation = 0 .Min = 0 .Max = 1000 .SmallChange = 10 .LargeChange = 50 ENDWITH ENDPROC PROCEDURE ScrollBar1.Change LOCAL lnIndex FOR lnIndex = 1 TO This.Parent.ControlCount WITH This.Parent.Controls(lnIndex) IF UPPER(.Name) != UPPER("ScrollBar1") .Top = .Origin_Top - This.Value ENDIF ENDWITH NEXT ENDPROC ENDDEFINE