打印本文 打印本文 关闭窗口 关闭窗口
从实作标题栏按钮开始浅谈组件的制作
作者:武汉SEO闵涛  文章来源:敏韬网  点击数3420  更新时间:2009/4/23 18:39:49  文章录入:mintao  责任编辑:mintao
m.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


          StretchBlt(Handle, Left, Top, Right-Left, Bottom-Top,


            FGlyph.Canvas.Handle, 0, 0, FGlyph.Width, FGlyph.Height, srcCopy);


      end;


    finally


      ReleaseDC(FForm.Handle,Handle);


      Free;


    end;


  end;


上一页  [1] [2] [3] [4] [5]  下一页

打印本文 打印本文 关闭窗口 关闭窗口