Autor Beitrag
AlA
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 30



BeitragVerfasst: Mi 09.04.03 13:51 
Wie kann ich ein icon in einer Statusbar anzeigen???

_________________
ala
delphiDeveloper
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 48



BeitragVerfasst: Mi 09.04.03 15:19 
Titel: Im Event OnDrawPanel Code hinzufügen
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
procedure TFormMain.StatusBarBuildDrawPanel(StatusBar: TStatusBar;
  Panel: TStatusPanel; const Rect: TRect);
var
  Text: string;
  MyRect: TRect;
begin
  StatusBarBuild.Panels[0].Text := 'Der StatBarText';
  StatusBarBuild.Hint := 'StatbarHint';
  with StatusBarBuild do
  begin
    Canvas.Font.Name := 'Tahoma';

    if Panel = Panels.Items[0] then
    begin
      ImageListStatBar.Draw(Canvas, Rect.Left, Rect.Top + 2, 2, true); 
      // der vorletzte Parameter icon aus Imagelist
      Text := Panels[0].Text;
    end;

    MyRect := Rect;
    MyRect.Left := Rect.Left + 20;

    DrawText(Canvas.Handle, PChar(Text), -1, MyRect, dt_singleline or
      dt_vcenter);
  end;
end;
AlA Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 30



BeitragVerfasst: Mi 09.04.03 20:15 
Gibts da auch irgentwo ein tutorial dazu ich peil nämlich net grad viel von dem was da im quelltext steht

_________________
ala
delphiDeveloper
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 48



BeitragVerfasst: Do 10.04.03 00:02 
Titel: Tuturial habe ich nicht
aber wenn du willst schicke ich dir ein minimal beispiel per mail zu.
Interesse?
AlA Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 30



BeitragVerfasst: Do 10.04.03 07:43 

_________________
ala
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Do 10.04.03 11:03 
Titel: Re: Im Event OnDrawPanel Code hinzufügen
delphiDeveloper hat folgendes geschrieben:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
procedure TFormMain.StatusBarBuildDrawPanel(StatusBar: TStatusBar;
  Panel: TStatusPanel; const Rect: TRect);
var
  Text: string;
  MyRect: TRect;
begin
  StatusBarBuild.Panels[0].Text := 'Der StatBarText';
  StatusBarBuild.Hint := 'StatbarHint';
  with StatusBarBuild do
  begin
    Canvas.Font.Name := 'Tahoma';

    if Panel = Panels.Items[0] then
    begin
      ImageListStatBar.Draw(Canvas, Rect.Left, Rect.Top + 2, 2, true); 
      // der vorletzte Parameter icon aus Imagelist
      Text := Panels[0].Text;
    end;

    MyRect := Rect;
    MyRect.Left := Rect.Left + 20;

    DrawText(Canvas.Handle, PChar(Text), -1, MyRect, dt_singleline or
      dt_vcenter);
  end;
end;

Kompliziert, kompliziert. Warum alles selber machen, wenn es Windows viel besser kann? :roll:
ausblenden Quelltext
1:
2:
hIcon := LoadImage(hInstance, MAKEINTRESOURCE(4), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); 
SendMessage(hStatusBar, SB_SETICON, 0, hIcon);

Wie du das Icon in eine Ressource bekommst, sollte hie rim Forum stehen, bei den FAQ oder Tutorials. hStatusbar ist das Handle deiner Statusbar also:
ausblenden Quelltext
1:
Statusbar1.Handle					

Die 0 gibt das Panel an, wo das Icon rein soll: 0 erste Panel, 1 zweite Panel, usw.