最近いろいろお世話になっております。
TStatusBar をフォームにはって、
Colorプロパティを変更したのですが
何も変化がありません。
このプロパティってTStatusBarの背景の色が
変わるんじゃないんですか?
このあたりが、ヒントかな?。
これだっ!
http://delphi.about.com/od/vclusing/a/statusbar_owner.htm
-----------------------------------------------------------
1. Drop a TStatusBar (name: "StatusBar1") on a Delphi form.
2. Drop a TImageList (name: "ImageList1").
3. Add 2 bitmap images to the image list
4. Add 3 Panels to the status bar
5. Use the code above to set owner drawing for the first two panels (in the form's OnCreate event)
6. Use the code below to apply custom drawing of the first to panels by adding graphics, applying different font and panel color. Do this inside the OnDrawPanel event of the StatusBar1.
-----------------------------------------------------------
procedure TForm1.FormShow(Sender: TObject);
begin
StatusBar1.Panels[0].Style := psOwnerDraw;
end;
procedure TForm1.StatusBar1DrawPanel(StatusBar: TStatusBar;
Panel: TStatusPanel; const Rect: TRect);
begin
with StatusBar1.Canvas do
begin
case Panel.Index of
0: //fist panel
begin
Brush.Color := clRed;
Font.Color := clNavy;
Font.Style := [fsBold];
end;
1: //second panel
begin
Brush.Color := clYellow;
Font.Color := clTeal;
Font.Style := [fsItalic];
end;
end;
//Panel background color
FillRect(Rect) ;
//Panel Text
TextRect(Rect,2 + ImageList1.Width + Rect.Left, 2 + Rect.Top,Panel.Text) ;
end;
//draw graphics
ImageList1.Draw(StatusBar1.Canvas, Rect.Left, Rect.Top, Panel.Index) ;
end;
//Change drawing style of StatusBar Panels
procedure TForm1.FormCreate(Sender: TObject) ;
begin
StatusBar1.Panels[0].Style := psOwnerDraw;
StatusBar1.Panels[1].Style := psOwnerDraw;
end;
>このプロパティってTStatusBarの背景の色が
>変わるんじゃないんですか?
XPManifest 貼り付けてなければ 変わる
XPManifestとは何でしょうか?
当方、WindowsVista SP1, Delphi 2007 です。
majideさんありがとうございます。
試してみたのですが、
OnDrawEventが発生しません。
> 当方、WindowsVista SP1, Delphi 2007 です。
お使いの環境は最初に書いて頂けると...。
XPManifest は D7〜D2006 に存在する
XP のテーマに対応させるためのコンポーネントです。
D2007以降ではこの機能はビルトインになっており、
[プロジェクト | オプション | アプリケーション] の
"ランタイムテーマを有効にする" がそれに該当します(デフォルトでON)。
KHE00221 さんの発言を読み替えると、
"ランタイムテーマを有効にする" にチェックが入っていなければ変わる
という事になります。
DEKOさんありがとうございます。
確かにチェックをはずすと、色が変わるようになりました。
けど、ボタンとかの表示等もイメージ変わってしまいました。
StatusBar だけ XPManifest をオフにする方法って
ありませんか?
StatusBar で OnDrawを使って描画をしてみようと思ったのですが
うまくいきません。
私の実力ではまだまだ初級ですね。
あきらめて、Panelを使います。
>OnDrawEventが発生しません。
何処に使用するのでしょうか。
majideさんが紹介されたホームページを見ました。
1.TStatusBar(名前: 「StatusBar1」)をForm1に設置してください。
2.TImageList(名前: 「ImageList1」)をForm1に設置してください。
3.イメージ・リストに2つのビットマップ・イメージを加えます。
4.ステータスバーに3枚のパネルを加えます。
(ステータスバー上で右クリック->パネルの設定->パネルの追加)
5.最初の2枚のパネルに図をセットするのに下記のコードを使用します。
(Form1のOnCreateのイベントコード追加)
StatusBar1.Panels[0].Style := psOwnerDraw;
StatusBar1.Panels[1].Style := psOwnerDraw;
6 StatusBar1のDrawPanelのイベントにmajideさん指定のコードをコピー
念の為に
DrawPanelのイベントにと言うのは
OnDroawPanelの事です。
ツイート | ![]() |