Statusbar da belirli bir alanı bold yapma

Delphi'de kod yazma ile ilgili sorularınızı bu foruma yazabilirsiniz.
Cevapla
Kullanıcı avatarı
brs
Üye
Mesajlar: 626
Kayıt: 04 Eki 2012 03:52

Statusbar da belirli bir alanı bold yapma

Mesaj gönderen brs »

İyi akşamlar Statusbar da belirli bir alanı bol yapmak mümkün mü?

örnek: Hoş Geldin Admin bugün 29 Haziran 2014

Kod: Tümünü seç

    Form2.Statusbar1.Panels[0].text := 'Hoş Geldin, ' + Edit1.text +
              ' Bugün ' + FormatDateTime('d mmmm yyyy dddd', Now) +
              ' Giriş İşlemi Başarıyla Sağlandı!';
İşi bilen yardım eder, az bilen akıl verir, bilmeyen eleştirir, yapamayan ise çamur atar...
Kullanıcı avatarı
mrmarman
Üye
Mesajlar: 4741
Kayıt: 09 Ara 2003 08:13
Konum: İstanbul
İletişim:

Re: Statusbar da belirli bir alanı bold yapma

Mesaj gönderen mrmarman »

Güzel bir soru...

- Cevabı CANVAS işlemleri ile yapabilirsin. Bir de örnek hazırladım. Elim değmişken biraz komplike birşey oldu. Parse vs. içerikli oldu ama sen kendine pay çıkartırsın.

Aşağıdaki gibi bir yapı oluşturdum.

Resim

Kullanımı :

Kod: Tümünü seç

procedure TForm1.FormCreate(Sender: TObject);
begin
  StatusBar1.Panels[0].Style := psOwnerDraw;
end;

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

Procedure StatusBarYaz( aCanvas: TCanvas; strYazi:String );
Var
  Liste : TStringList;
  strBlok, strYazilacak : String;
  i, x : Integer;
begin
  strBlok := strYazi;
  Liste := TStringList.Create;
  while Pos('>', strBlok) > 0 do
  begin
    System.Delete( strBlok, 1, Pos('<', strBlok) );
    Liste.Add( Copy(strBlok, 1, Pos('<', strBlok)-1) );
    System.Delete( strBlok, 1, Pos('>', strBlok) );
    System.Delete( strBlok, 1, Pos('>', strBlok) );
  end;

  x := 2; // sol marjin...
  With aCanvas do
  begin
    Font.Style  := [];
    Font.Color  := clBlack;
    Brush.Style := bsSolid;
    FillRect( ClipRect );

    for i := 0 to Liste.Count - 1 do
    begin
      if Liste[i][1] = 'c' then
      begin // Renk Değişikliği
        strYazilacak := Liste[i];
        System.Delete( strYazilacak, 1, Pos('>', strYazilacak) );
        Font.Color := StringToColor( strYazilacak );
        strYazilacak := '';
      end else
      if Liste[i][1] = '>' then
      begin // Font Stili Normal'e Dönüş...
        Font.Style   := [];
        strYazilacak := Liste[i];
        System.Delete( strYazilacak, 1, Pos('>', strYazilacak) );
      end else
      if Liste[i][1] = 'b' then
      begin // Font Stili bold
        Font.Style  := [fsBold];
        strYazilacak := Liste[i];
        System.Delete( strYazilacak, 1, Pos('>', strYazilacak) );
      end else
      if Liste[i][1] = 'i' then
      begin // Font Stili italic
        Font.Style  := [fsItalic];
        strYazilacak := Liste[i];
        System.Delete( strYazilacak, 1, Pos('>', strYazilacak) );
      end else
      if Liste[i][1] = 'd' then
      begin // Font Stili bold/italic
        Font.Style  := [fsBold, fsItalic];
        strYazilacak := Liste[i];
        System.Delete( strYazilacak, 1, Pos('>', strYazilacak) );
      end;
      TextOut( x, 2, strYazilacak );
      x := x + TextWidth( strYazilacak ) + 4
    end;
  end;
  Liste.Free;
end;

procedure TForm1.StatusBar1DrawPanel(StatusBar: TStatusBar; Panel: TStatusPanel; const Rect: TRect);
begin
  StatusBarYaz( StatusBar.Canvas, ''
    + ' <>Hoş Geldin</>'
    + ' <c>clRed</c>'
    + ' <b>' + Edit1.Text + '</b>'
    + ' <c>clBlack</c>'
    + ' <>Bugün '+FormatDateTime('d mmmm yyyy dddd', Now) + '</>'
    + ' <i>Giriş İşlemi Başarıyla Sağlandı!</i>'
    + ' <d>Bold Italic''de bu olsun...</d>'
     );
end;

Resim
Resim ....Resim
Kullanıcı avatarı
brs
Üye
Mesajlar: 626
Kayıt: 04 Eki 2012 03:52

Re: Statusbar da belirli bir alanı bold yapma

Mesaj gönderen brs »

Teşekkür ederim...
İşi bilen yardım eder, az bilen akıl verir, bilmeyen eleştirir, yapamayan ise çamur atar...
Kullanıcı avatarı
hido
Üye
Mesajlar: 268
Kayıt: 29 Mar 2014 04:32

Re: Statusbar da belirli bir alanı bold yapma

Mesaj gönderen hido »

mrmarman yazdı:Güzel bir soru...

- Cevabı CANVAS işlemleri ile yapabilirsin. Bir de örnek hazırladım. Elim değmişken biraz komplike birşey oldu. Parse vs. içerikli oldu ama sen kendine pay çıkartırsın.

Aşağıdaki gibi bir yapı oluşturdum.

Resim

Kullanımı :

Kod: Tümünü seç

procedure TForm1.FormCreate(Sender: TObject);
begin
  StatusBar1.Panels[0].Style := psOwnerDraw;
end;

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

Procedure StatusBarYaz( aCanvas: TCanvas; strYazi:String );
Var
  Liste : TStringList;
  strBlok, strYazilacak : String;
  i, x : Integer;
begin
  strBlok := strYazi;
  Liste := TStringList.Create;
  while Pos('>', strBlok) > 0 do
  begin
    System.Delete( strBlok, 1, Pos('<', strBlok) );
    Liste.Add( Copy(strBlok, 1, Pos('<', strBlok)-1) );
    System.Delete( strBlok, 1, Pos('>', strBlok) );
    System.Delete( strBlok, 1, Pos('>', strBlok) );
  end;

  x := 2; // sol marjin...
  With aCanvas do
  begin
    Font.Style  := [];
    Font.Color  := clBlack;
    Brush.Style := bsSolid;
    FillRect( ClipRect );

    for i := 0 to Liste.Count - 1 do
    begin
      if Liste[i][1] = 'c' then
      begin // Renk Değişikliği
        strYazilacak := Liste[i];
        System.Delete( strYazilacak, 1, Pos('>', strYazilacak) );
        Font.Color := StringToColor( strYazilacak );
        strYazilacak := '';
      end else
      if Liste[i][1] = '>' then
      begin // Font Stili Normal'e Dönüş...
        Font.Style   := [];
        strYazilacak := Liste[i];
        System.Delete( strYazilacak, 1, Pos('>', strYazilacak) );
      end else
      if Liste[i][1] = 'b' then
      begin // Font Stili bold
        Font.Style  := [fsBold];
        strYazilacak := Liste[i];
        System.Delete( strYazilacak, 1, Pos('>', strYazilacak) );
      end else
      if Liste[i][1] = 'i' then
      begin // Font Stili italic
        Font.Style  := [fsItalic];
        strYazilacak := Liste[i];
        System.Delete( strYazilacak, 1, Pos('>', strYazilacak) );
      end else
      if Liste[i][1] = 'd' then
      begin // Font Stili bold/italic
        Font.Style  := [fsBold, fsItalic];
        strYazilacak := Liste[i];
        System.Delete( strYazilacak, 1, Pos('>', strYazilacak) );
      end;
      TextOut( x, 2, strYazilacak );
      x := x + TextWidth( strYazilacak ) + 4
    end;
  end;
  Liste.Free;
end;

procedure TForm1.StatusBar1DrawPanel(StatusBar: TStatusBar; Panel: TStatusPanel; const Rect: TRect);
begin
  StatusBarYaz( StatusBar.Canvas, ''
    + ' <>Hoş Geldin</>'
    + ' <c>clRed</c>'
    + ' <b>' + Edit1.Text + '</b>'
    + ' <c>clBlack</c>'
    + ' <>Bugün '+FormatDateTime('d mmmm yyyy dddd', Now) + '</>'
    + ' <i>Giriş İşlemi Başarıyla Sağlandı!</i>'
    + ' <d>Bold Italic''de bu olsun...</d>'
     );
end;

Hocam StatusBar diğer hücreleri nasıl bold ve renk düzenlemesi yapabiliriz.
Cevapla