在delphi的winform上要如何实现呢?
就好像网页上的新闻一样,内容是滚动的,而且内容是动态的,实时刷新。。
内容在winform界面上滚动,而且每一个标题都像一个超链接一样,点击就能访问到指定网址。。
这个要怎样做到啊?大大们教下啊。。

解决方案 »

  1.   

    按字符滚动很简单:每次从p个字符开始显示,p:=p+1
    如果要按像素滚动:先把一屏文字画在一个内部的bitmap,每次从第p个像素开始显示,p:=p+1点击就能访问到指定网址:根据鼠标的x坐标+p,得到此处属于哪一个标题,跳到它对于的网址即可
      

  2.   

    放个Webbrowser,用<marquee>显示
      

  3.   

    画吧根据内容改变FTop的值,依次画出列表中的数据,下面只画了一个'abc'
    procedure TForm1.FormPaint(Sender: TObject);
    begin
      Inc(FTop,3);
      Canvas.TextOut(10,100-FTop,'abc');
    end;procedure TForm1.Timer1Timer(Sender: TObject);
    begin
      Self.Repaint;
    end;
      

  4.   

    放个Panel,动态创建label到Panel里
    给Label的click事件添加打开链接动作
    用Timer控件label的位置
    当label达到不可见的位置时,释放label
      

  5.   

    当label达到不可见的位置时,释放label我初步的想法也跟你一样,但不知道上面这个如何判定呢?
      

  6.   

    bdmh画的是由下往上纵向滚动,下面改成从右至左的横向滚动type
      TForm1 = class(TForm)
        Timer1: TTimer;
        Button1: TButton;
        procedure FormPaint(Sender: TObject);
        procedure Timer1Timer(Sender: TObject);
        procedure FormCreate(Sender: TObject);
        procedure FormClick(Sender: TObject);
      private
        { Private declarations }
        FLeft: Integer;
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}procedure TForm1.FormPaint(Sender: TObject);
    begin
      if FLeft <= 0 then
        FLeft := Width
      else
        Dec(FLeft, 1);
      Canvas.TextOut(FLeft, 10, 'abc');
    end;procedure TForm1.Timer1Timer(Sender: TObject);
    begin
      Self.Repaint;
    end;procedure TForm1.FormCreate(Sender: TObject);
    begin
      FLeft := Width;
      Timer1.Interval := 30;
      Timer1.Enabled := True;
    end;
      

  7.   

    根据边界值比较,如上面例子中就是
      if FLeft <= 0 then
    如果滚动方式不一样,略加修改即可
      

  8.   

    左右就是判断
    if label.left < 0-label.width then上下就是
    if label.top < 0 - label.height then
      

  9.   

    想实现点击,就要在click事件中,根据你的鼠标位置,和字体高度,去判断点击在第几行,然后去列表中找到新闻内容
      

  10.   

    我现在总结了以下实现方式..但代码不知道怎么写..
    在界面上放一个PANEL..
    动态添加LABEL,LABEL的长度跟标题长度一致..
    多个LABEL时,后一个LABEL按照一定间距跟在第一个LABEL上...
    但难点就是,如何实现点击,还有就是怎样控制LABEL的位置了..
    因为要实现滚动,就是不停有新的LABEL生成,也不停的有旧的LABEL需要释放..
      

  11.   

    上面所说用Panel的实现,保存为两个文件,你有空可转成多线程// 另存为 Unit1.dfm object Form1: TForm1
      Left = 272
      Top = 289
      Width = 501
      Height = 178
      Caption = 'Form1'
      Color = clBtnFace
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clWindowText
      Font.Height = -11
      Font.Name = 'MS Sans Serif'
      Font.Style = []
      OldCreateOrder = False
      OnClose = FormClose
      PixelsPerInch = 96
      TextHeight = 13
      object Panel1: TPanel
        Left = 16
        Top = 16
        Width = 185
        Height = 81
        BevelOuter = bvNone
        TabOrder = 0
        object Panel2: TPanel
          Left = 0
          Top = 16
          Width = 185
          Height = 41
          BevelOuter = bvNone
          TabOrder = 0
        end
      end
      object Button1: TButton
        Left = 408
        Top = 8
        Width = 75
        Height = 25
        Caption = 'Start'
        TabOrder = 1
        OnClick = Button1Click
      end
      object ListView1: TListView
        Left = 216
        Top = 8
        Width = 185
        Height = 97
        Columns = <
          item
            AutoSize = True
          end
          item
            AutoSize = True
          end>
        Items.Data = {
          CB0000000400000000000000FFFFFFFFFFFFFFFF010000000000000005616161
          616114687474703A2F2F7777772E62616964752E636F6D00000000FFFFFFFFFF
          FFFFFF010000000000000005626262626214687474703A2F2F7777772E676F6F
          676C652E636E00000000FFFFFFFFFFFFFFFF0100000000000000056363636363
          13687474703A2F2F6D61696C2E3136332E636F6D00000000FFFFFFFFFFFFFFFF
          010000000000000005646464646414687474703A2F2F6D61696C2E6C6976652E
          636F6DFFFFFFFFFFFFFFFF}
        RowSelect = True
        ParentShowHint = False
        ShowHint = False
        TabOrder = 2
        ViewStyle = vsReport
      end
      object Button2: TButton
        Left = 408
        Top = 48
        Width = 75
        Height = 25
        Caption = 'Stop'
        TabOrder = 3
        OnClick = Button2Click
      end
    end//另存为 Unit1.pasunit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls, ExtCtrls, ComCtrls, ShellApi;type
      TMyLabel = class(TLabel)
        procedure Click; override;
      end;type
      TForm1 = class(TForm)
        Panel1: TPanel;
        Panel2: TPanel;
        Button1: TButton;
        ListView1: TListView;
        Button2: TButton;
        procedure Button1Click(Sender: TObject);
        procedure Button2Click(Sender: TObject);
        procedure FormClose(Sender: TObject; var Action: TCloseAction);
      private
        { Private declarations }
      public
        procedure domove;
        { Public declarations }
      end;var
      Form1: TForm1;
      d: boolean;implementation{$R *.dfm}procedure TMyLabel.Click;              // 点击打开网页
    begin
      inherited Click;
      ShellExecute(Application.Handle, 'Open', pchar(Self.Hint), nil, nil,sw_shownormal);
    end;procedure TForm1.domove;
    begin
      while d do
      begin
        Application.ProcessMessages;
        if Panel2.Top > -Panel2.Height then
          Panel2.Top:= Panel2.Top -1
        else Panel2.Top:= Panel1.Height;
        sleep(100);
      end;
    end;procedure TForm1.Button1Click(Sender: TObject);
    var
      i,c: integer;
      L: TLabel;
    begin
      Panel2.Top:= Panel1.Height;
      for i:= Panel2.ComponentCount-1 downto 0 do
        if Panel2.Components[i] is TLabel then
          Panel2.Components[i].Free;
      for i:=0 to ListView1.Items.Count-1 do
      begin
          L:= TMyLabel.Create(Panel2);
          L.Caption:= ListView1.Items.Item[i].Caption;
          L.Hint:= ListView1.Items.Item[i].SubItems.Strings[0];     // 存网址
          L.Parent:= Panel2;
          L.Visible:= true;
      end;
      c:= 0;
      for i:= 0 to Panel2.ComponentCount-1 do
        if Panel2.Components[i] is TLabel then
        begin
          (Panel2.Components[i] as TLabel).Top:= c*13;
          (Panel2.Components[i] as TLabel).Visible:= true;
          inc(c);
        end;
      Panel2.Height:= Panel2.ComponentCount*13;
      d:= true;
      domove;
    end;procedure TForm1.Button2Click(Sender: TObject);
    begin
      d:= false;
    end;procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
    begin
      d:= false;
    end;end.
      

  12.   

    把这样一个html文件整合进exe的资源里,然后在软件里调用这个资源就可以了,很多软件都是这么做的
      

  13.   

    if you want to implement this on web apps, it is pretty easy: just using jQuery...
      

  14.   

    左右就是判断 
    if label.left < 0-label.width then 上下就是 
    if label.top < 0 - label.height then
      

  15.   

    用Timer控件,在事件中改变Label的Left