Q&A

  • 상태바에 나타나는 글씨들을 왔다갔다 가게 어케 나타내요?
상태방에 나타나는 글씨들을 왔다갔다하는 방법 좀 알려주세요ㅠㅠ?
1  COMMENTS
  • Profile
    최용일 2004.01.10 14:59
    안녕하세요. 최용일입니다.

    타이머 하나 놓고 OnTimer이벤트에서 판넬을 다시 그리도록 해주시면 됩니다...

    아래 예제 응용해보세요...

    unit ufrmMain;

    interface

    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, ExtCtrls, ComCtrls;

    type
      TForm1 = class(TForm)
        StatusBar1: TStatusBar;
        Timer1: TTimer;
        procedure StatusBar1DrawPanel(StatusBar: TStatusBar;
          Panel: TStatusPanel; const Rect: TRect);
        procedure FormCreate(Sender: TObject);
        procedure Timer1Timer(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;

    var
      Form1: TForm1;

    implementation

    {$R *.dfm}

    const
      PanelText = 'Move String Test...';

    procedure TForm1.StatusBar1DrawPanel(StatusBar: TStatusBar;
      Panel: TStatusPanel; const Rect: TRect);
    begin
      StatusBar.Tag := (StatusBar.Tag + 4) mod StatusBar.Width;
      StatusBar.Canvas.TextOut(StatusBar.Tag, 4, PanelText);
    end;

    procedure TForm1.FormCreate(Sender: TObject);
    var
      StatusPanel: TStatusPanel;
    begin
      StatusBar1.Tag := 0;
      StatusBar1.OnDrawPanel := StatusBar1DrawPanel;
      
      StatusPanel := StatusBar1.Panels.Add;
      StatusPanel.Style := psOwnerDraw;
      StatusPanel.Text := PanelText;

      Timer1.Interval := 100;
    end;

    procedure TForm1.Timer1Timer(Sender: TObject);
    begin
      StatusBar1.Repaint;
    end;

    end.

    ^^ 항상 즐코하세요...