Fórum TabIndex X TCustomTabControl ? #299184
12/10/2005
0
Alguém aí pode me dar uma ajuda com isso ?
Olha só, tenho um componente derivado de TCustomTabControl
eu uso a propriedades Tabs para criar abas com registro de um Dataset,
até aí tudo bem, eu preciso fazer ao equivalente ao q faço com o PageControl, pintar as abas criadas:
[color=green:97db81eeee]Com PageControl[/color:97db81eeee]
var nAux: Integer; begin for nAux := 0 to Self.TabIndex-1 do begin if Self.TabIndex <> nAux then begin PaintTab(nAux); Self.Pages[nAux].Brush.Color := clWhite; Self.Pages[nAux].Repaint; end; end;
[color=blue:97db81eeee]Não achei uma maneira de pintar as abas da Tabs do TCustomTabControl[/color:97db81eeee]
Obrigada.
Renatacoimbra
Curtir tópico
+ 0Posts
13/10/2005
Marcelo.l
Inclua em seu form um TImageList (aba Win32), adicione as imagens na ordem em que aparecem os Tabs.
Gostei + 0
13/10/2005
Renatacoimbra
Mais não é isso, não quero colocar uma imagem, e sim pintar a aba com canvas.
Algo do tipo:
var nAux: Integer; begin for nAux := 0 to Self.TabIndex-1 do begin if Self.TabIndex <> nAux then begin PintarTab(nAux); Self.Pages[nAux].Brush.Color := clWhite; Self.Pages[nAux].Repaint; end; end;
só que ao invés de usar Pages:
Self.Pages[nAux].Brush.Color := clWhite;
Gostaria de usar algo como:
Self.Tabs[nAux].Brush.Color := clWhite;
Brigada !
Gostei + 0
13/10/2005
Renatacoimbra
...
Gostei + 0
13/10/2005
Marcelo.l
Desculpe, n~´ao estava prestando atenção e não vi o que vc realamente queria.
Para ´desenhar´ na aba do TCustomTabControl vc terá que setar a propriedade ´OwnerDraw´ para TRUE.
Aí, evento ´OnDrawTab´ vc pode fazer o que quiser usando o CANVAS do componente. Ex:
procedure TForm1.TabControl1DrawTab(Control: TCustomTabControl; TabIndex: Integer; const Rect: TRect; Active: Boolean); var s : string; begin s := TabControl1.Tabs[TabIndex]; case TabIndex of 0: TabControl1.Canvas.Brush.Color := clGreen; 1: TabControl1.Canvas.Brush.Color := clYellow; 2: TabControl1.Canvas.Brush.Color := clRed; end; TabControl1.Canvas.FillRect(Rect); TabControl1.Canvas.Brush.Style := bsClear; TabControl1.Canvas.TextOut(Rect.Left + 2, Rect.Top + 2, s ); end;
A desvantagem é que vc também terá que ´desenhar´ o texto da aba, selecionando fonte, tamanho,etc.
Espero ter ajudado.
Gostei + 0
13/10/2005
Renatacoimbra
Eu não estou escrevendo o código no evento do componente, criei um componente herdando do TCustomTabControl e costaria de implementar esse código para mudar seu visual, só que esse código se refere a propriedades Pages do PageControl, no meu caso é a Tabs.
[color=blue:d408dd4365]OBS: Rotina retirada do componente TXPPageControl[/color:d408dd4365]
procedure TPageControl.hookPaint(var Msg: TMessage); var p: TPaintStruct; nAux: Integer; rAux, rLin: TRect; begin BeginPaint(Self.Handle, p); EndPaint(Self.Handle, p); // Pinta as tabulações Canvas.Brush.Color := TPanel(Parent).Color; Canvas.FillRect(Rect(0, 0, Self.Width, 21)); Canvas.Pen.Width := 1; for nAux := 0 to Self.PageCount-1 do begin if Self.ActivePageIndex <> nAux then begin PaintTab(nAux); Self.Pages[nAux].Brush.Color := clWhite; Self.Pages[nAux].Repaint; end; end; if Self.ActivePageIndex <> -1 then begin nAux := Self.ActivePageIndex; PaintTab(nAux); Self.Pages[nAux].Brush.Color := clWhite; Self.Pages[nAux].Repaint; end; rLin := tabRect(nAux); Self.Color := TForm(Parent).Color; // Pinta o corpo Self.Canvas.Brush.Color := $00B4A791; rAux := Self.DisplayRect; InflateRect(rAux, 4, 4); Self.Canvas.FrameRect(rAux); Self.Canvas.Brush.Color := clWhite; if Self.PageCount <> 0 then begin InflateRect(rAux, -1, -1); Self.Canvas.FrameRect(rAux); InflateRect(rAux, -1, -1); Self.Canvas.FrameRect(rAux); InflateRect(rAux, -1, -1); Self.Canvas.FrameRect(rAux); InflateRect(rAux, -1, -1); Self.Canvas.FrameRect(rAux); end else begin InflateRect(rAux, -1, -1); Self.Canvas.FillRect(rAux); end; Self.Canvas.Pen.Width := 1; Self.Canvas.Pen.Color := clWhite; Self.Canvas.MoveTo(rLin.Left-1, rLin.Bottom); Self.Canvas.LineTo(rLin.Right+1, rLin.Bottom); Msg.Result := 0; if Self.ActivePageIndex <> -1 then Self.Pages[Self.ActivePageIndex].Brush.Color := clWhite; end;
[]´s
Gostei + 0
14/10/2005
Renatacoimbra
...
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)