大家好:
  在WINDOWS XP系统中,用下面的代码可以更改pagecontrol标签颜色。代码如下:
procedure TfrmPMCDCD.PageControl2DrawTab(Control: TCustomTabControl;
  TabIndex: Integer; const Rect: TRect; Active: Boolean);
var
  C: TCanvas;
  R: TRect;
  mCaption: string;
  mPtr: integer;
  mPos: integer;
begin
  R := Rect;
  C := PageControl2.Canvas;
  if Active then
  begin
    R.Top := R.Top + 2;
    R.Left := R.Left + 2;
    R.Right := R.Right - 2;
    R.Bottom := R.Bottom - 2;
    C.Font.Color := clCaptionText;
    C.Font.Style := C.Font.Style + [fsBold];
    C.Brush.Color := clActiveCaption;
  end
  else
  begin
    C.Font.Color := clInActiveCaptionText;
    C.Font.Style := C.Font.Style - [fsBold];
    C.Brush.Color := clInActiveCaption;
  end;
  FillRect(C.Handle,R,C.Brush.Handle);
  if not Active then
    R.Top := R.Top + 2;
  mPos := TabIndex;
  mPtr := 0;
  while (mPtr <= TabIndex) and (mPos < PageControl2.PageCount) do
  begin
    if not PageControl2.Pages[mPtr].TabVisible then
       Inc(mPos);
    Inc(mPtr);
  end;
  mCaption := PageControl2.Pages[mPos].Caption;
  C.FillRect(Rect);
  C.TextOut(Rect.Left+6,Rect.Top+2,mCaption);
end;

但在WINDOWS 7 中无法改变。不知道是那里出问题。效果见下图。

解决方案 »

  1.   

    效果图如下:
    ,如何修改程序,可以使软件在WINDOWS 7 中也可以显示PageControl标签及颜色。谢谢大家!
      

  2.   

    测试环境:Windows 2008 R2 + Delphi 2010
    1、默认情况下:2、修改PageControl的OwenDraw属性为True,效果如下:
      

  3.   


    是上面这个效果???那就是改一下“C.Font.Color := clCaptionText;”,改成“C.Font.Color := clRed;”
      

  4.   

    那就是改一下“C.Font.Color := clCaptionText;”,改成“C.Font.Color := clRed;” 
      

  5.   

    还是使用AlphaControls美化一下皮肤吧,你的界面真心难看
    http://download.csdn.net/detail/wozengcong/6595205