Linux中国 Linux中国门户站!
设为主页 设为主页
收藏本站 收藏本站
 
当前位置 :首页 ->编程语言 ->Delphi ->正文

从实作标题栏按钮开始浅谈组件的制作

来源:Linuxdby.com 作者:Webmaster 时间:2007-06-05 点击: [收藏] [投稿]

 

  with Result do

  begin

    FrameThick := GetSystemMetrics(SM_CYFRAME);

    Left := (Rec.Right - Rec.Left) - RightMargin - FrameThick;

    Top := FrameThick;

    if FForm.Borderstyle in [bsSizeToolWin, bsSizeable] then

    begin

      Dec(Left, 2); Inc(Top, 2);

    end

    else begin

      Dec(Left); Inc(Top);

    end;

    if (FForm.Borderstyle in [bsSizeToolWin,bsToolWindow]) then

    begin

      BtnWidth := GetSystemMetrics(SM_CXSMSIZE) - 2;

      BtnHeight := GetSystemMetrics(SM_CYSMSIZE) - 4;

    end

    else begin

      BtnWidth := GetSystemMetrics(SM_CXSIZE) - 2;

      BtnHeight := GetSystemMetrics(SM_CYSIZE) - 4;

    end;

    Right := Left + BtnWidth;

    Bottom := Top + BtnHeight;

  end;

end;

 

procedure TTitleBarButton.Paint;

var

  GlyphRect: TRect;

begin

  if not FVisible then Exit;

  with TCanvas.Create do

  begin

    try

      Handle := GetWindowDC(FForm.Handle); //得到窗体DC,包括标题栏、菜单、滚动条等

 

      Brush.Color := FColor;         //画Button凸起和按下时的外观

      if FButtonDown then

        Pen.Color := clBtnHighlight

      else

        Pen.Color := cl3DDkShadow;

      Rectangle(BoundsRect);

      with BoundsRect do

      begin

        if FButtonDown then

          Pen.Color := cl3DDkShadow

        else

          Pen.Color := clBtnHighLight;

        MoveTo(Left,Bottom-2);

        LineTo(Left,Top);

        LineTo(Right-1,Top);

        Pen.Color := clGray;

        if FButtonDown then

        begin

          MoveTo(Left+1,Bottom-3);

          LineTo(Left+1,Top+1);

          LineTo(Right-2,Top+1);

        end

        else begin

          MoveTo(Left+1,Bottom-2);

          LineTo(Right-2,Bottom-2);

          LineTo(Right-2,Top);

        end;

      end;

 

      if Assigned(Glyph) then      //如果关联了图片,则画图片

      begin

        GlyphRect := BoundsRect;

        GlyphRect.Right := GlyphRect.Right - 7;

        GlyphRect.Bottom := GlyphRect.Bottom - 5;

        if FButtonDown then

          OffsetRect(GlyphRect,4,3)

        else

          OffsetRect(GlyphRect,3,2);

 

        with GlyphRect do

 如果您对本文有任何疑问或者建议,请到讨论区发表您的意见: >> 论坛入口 <<



上一篇:“98五笔字型输入法”大批量造词   下一篇:如何把数据库的内容写入到Word文档中?

文章评论】 【收藏本文】 【推荐好友】 【打印本文】 【我要投稿】 【论坛讨论
更多相关文章
Power by linux-cn.com 粤ICP备05006655号