ورود

View Full Version : سوال: راهنمایی درباره TabbedNotebook



Ahmad_NiceBoy
چهارشنبه 15 دی 1389, 21:53 عصر
باسلام

پروژه ای در دلفی 7 نوشتم و نیاز به Tab Control دارم.
مشکل TabbedNotebook اینه که رنگش قابل تغییر نیست!
زیاد دنبال حل این مشکل بودم. چیزی پیدا نکردم. کامپوننت رایگان هم گیرم نیود.

توی یه سایت خارجی یک نفر اعلام کرده بود که تونسته مشکل رنگ در TabbedNotebook رو حل کنه و unit مربوطه هم گذاشته بود. ولی من نتونستم ازش استفاده کنم!


unit PaintTabbedNotebook;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ComCtrls, Tabnotbk,CommCtrl;

type
TPaintTabbedNotebook = class(TTabbedNotebook)

private
FOnPaint : TNotifyEvent;
FCol : TColor;
procedure WMPaint(var Message: TWMPaint); message wm_Paint;
Procedure SetColor(C:TColor);

{ Private-Deklarationen }
protected
{ Protected-Deklarationen }
public

Constructor Create(Aowner : TComponent); override;
{ Public-Deklarationen }
published
property OnPaint: TNotifyEvent read FOnPaint write FOnPaint;
Property HighlightColor: TColor read FCol Write SetColor;
{ Published-Deklarationen }
end;

procedure Register;

implementation

procedure TPaintTabbedNotebook.SetColor(C:TColor);
Begin;
FCol:=C;
RePaint;
End;

Constructor TPaintTabbedNotebook.Create(Aowner : TComponent);
Begin;
Inherited Create(Aowner);
HighLightColor:=Clred;
End;

procedure TPaintTabbedNotebook.WMPaint(var Message: TWMPaint);
var
R : TRect;
I : Integer;
begin
inherited;
if assigned(FOnPaint) then FOnPaint(self);
I := Self.Perform(TCM_GETCURSEL,0,0); //Get Current tab, pageindex is set later
if I > -1 then
begin
Self.Perform(TCM_GETITEMRECT,I,Integer(@R)); //Get PaintRect
r.Left := r.left + 1;
r.right := r.right - 1;
Canvas.Brush.Color := HighLightColor; //Paint Tab
Canvas.TextRect(r,r.left+2,r.top+2,Pages[I]);
Canvas.DrawFocusRect(r);
end;
end;


procedure Register;
begin
RegisterComponents('Samples', [TPaintTabbedNotebook]);
end;

end.

فایل مربوط به این تاپیک خارجی هم پیوست می کنم (http://turboupload.com/6ooldmtapdld)
لطفا بنده رو راهنمایی بفرمائید.

BORHAN TEC
دوشنبه 20 دی 1389, 02:03 صبح
سلام،:قلب:
راستش من Delphi 7 روی سیستمم نصب نیست. من یک مثال با Delphi XE نوشتم که می تونید از اون استفاده کنید.
این هم از برنامه: