zoukankan      html  css  js  c++  java
  • 画一个象windows 开始菜单的竖向标题

    http://delphi.xcjc.net/viewthread.php?tid=42705

    画一个象windows 开始菜单的竖向标题 (cjc)

    Reminder : UnitTools, Unit1

    // 画一个象windows 开始菜单的竖向标题
    procedure DrawBar(ACanvas: TCanvas; const title: string);
    var
      lf : TLogFont;
      tf : TFont;
      H, i: Integer;
      dy: real;
    begin
      with ACanvas do begin
        H := ClipRect.Bottom;
        dy := H / 128;
        for i := 0 to 128 do
        begin
          Brush.Color := RGB(0,0,255-i); //$00000000+i*$10000;
          FillRect( Rect(0,round(i*dy), 20, round((i+1)*dy)) );
        end;
        Font.Name := 'Tahoma';
        Font.Style := Font.Style + [fsBold];
        Font.Color := clWhite;
        tf := TFont.Create;
        try
          tf.Assign(Font);
          GetObject(tf.Handle, sizeof(lf), @lf);
          lf.lfEscapement := 900;
          lf.lfHeight := Font.Height - 2;
          tf.Handle := CreateFontIndirect(lf);
          Font.Assign(tf);
        finally
          tf.Free;
        end;
        ACanvas.Brush.Style := bsClear;
        TextOut(2, H-4, Title);
      end;
    end;


    在子菜单项中,OnDrawItem里加入如下代码:

    procedure TForm1.mnTrayCloseDrawItem(Sender: TObject; ACanvas: TCanvas;
      ARect: TRect; Selected: Boolean);
    begin
      if Selected then begin
        ACanvas.Brush.Color := clHighlight;
        ACanvas.Font.Color := clWhite;
      end
      else begin
        ACanvas.Brush.Color := clMenu;
        ACanvas.Font.Color := clBlack;
      end;

      ARect.Left := 22;
      ACanvas.FillRect(ARect);
      if selected then
      begin
        ACanvas.Brush.Color := clWhite;
        ACanvas.FrameRect(ARect);
      end;

      ARect.Left := 24;
      ImageListSheet.Draw(ACanvas,ARect.Left+1,ARect.Top+2,
         (Sender as TMenuItem).ImageIndex);
      ARect.Left := 24+20;

      ACanvas.Brush.Style := bsClear;
      ACanvas.TextOut(ARect.Left+3, ARect.Top+2,
         (Sender as TMenuItem).Caption);
      if ACanvas.ClipRect.Bottom = ARect.Bottom then DrawBar(ACanvas,'Reminder');
    end;

  • 相关阅读:
    2019-9-2-win10-uwp-判断本地ip
    2018-8-10-使用-Resharper-特性
    2018-8-10-WPF-checkbox文字下掉
    2018-8-10-调试-ms-源代码
    2018-8-10-cant-found-Microsoft.VSSDK.BuildTools.15.0.26201
    2019-9-18-WPF-如何调试-binding
    2018-8-10-WPF-控件继承树
    2018-8-10-sublime-Text-正则替换
    植物大战僵尸阳光冷却地址
    cs1.6 人物地址查询
  • 原文地址:https://www.cnblogs.com/chulia20002001/p/2023565.html
Copyright © 2011-2022 走看看