0

谁能给我指出一些代码/给我一些关于如何为 VFP 8 或 9 创建平滑滚动垂直选取框的想法?

任何帮助表示赞赏。

4

3 回答 3

0

您可以使用可滚动容器

于 2008-09-22T14:23:31.023 回答
0

这是一个滚动消息的快速程序。将以下内容放入 prg 文件并运行它。

我会让 containerScrollArea 成为一个封装计时器、标签和滚动代码的类。给它 GetNextMessage 方法,您可以覆盖该方法以检索消息。

* Put a container on the screen to hold our scroller
_screen.AddObject("containerScrollArea", "container")

WITH _Screen.containerScrollArea
    * Size it
    .Visible = .t.
    .Width = 100
    .Height = 100

    * Add two labels, one to hold each scrolling message
    .AddObject("labelScroll1", "Label") 
    .AddObject("labelScroll2", "Label") 

    * This timer will move the labels to scroll them
    .AddObject("timerScroller", "ScrollTimer")
ENDWITH

WITH _Screen.containerScrollArea.labelScroll1
    * The labels are positioned below the margin of the container, so they're not initially visible
    .Top = 101
    .Height = 100
    .Visible = .t.
    .WordWrap = .t.
    .BackStyle= 0
    .Caption = "This is the first scrolling text, which is scrolling."
ENDWITH

WITH _Screen.containerScrollArea.labelScroll2
    * The labels are positioned below the margin of the container, so they're not initially visible
    .Top = 200
    .Height = 100
    .Visible = .t.
    .WordWrap = .t.
    .BackStyle= 0
    .Caption = "This is the second scrolling text, which is scrolling."
ENDWITH

* Start the timer, which scrolls the labels
_Screen.containerScrollArea.timerScroller.Interval = 100


DEFINE CLASS ScrollTimer AS Timer
    PROCEDURE Timer

        * If the first label is still in view, move it by one pixel
        IF This.Parent.labelScroll1.Top > -100
            This.Parent.labelScroll1.Top = This.Parent.labelScroll1.Top - 1
        ELSE
            * If the first label has scrolled out of view on the top of the container, move it back to the bottom.
            This.Parent.labelScroll1.Top = 101
            * Load some new text here
        ENDIF

        IF This.Parent.labelScroll2.Top > -100
            * If the second label is still in view, move it by one pixel
            This.Parent.labelScroll2.Top = This.Parent.labelScroll2.Top - 1
        ELSE
            * If the second label has scrolled out of view on the top of the container, move it back to the bottom.
            This.Parent.labelScroll2.Top = 101
            * Load some new text here
        ENDIF
    ENDPROC
ENDDEFINE
于 2008-10-02T21:58:41.617 回答
0

不幸的是,我的工作性质让我没有时间玩弄图形,但如果我这样做了,我会考虑使用 GDI+ 和 VFP。这是一篇让您入门的文章

于 2008-10-06T21:17:26.093 回答