Is there any other way to influence the size of the tab ?
Kind regards,
Mark Smits
--
Sm...@Com-Unit.com
Com-Unit BV, The Netherlands.
The makers of Spider-Road®.
There is. Look at the entry for TCM_SETITEMSIZE in win32.hlp.
--
Peter Below (TeamB)
Use the newsgroup archives :
http://www.mers.com/searchsite.html
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be
>There is. Look at the entry for TCM_SETITEMSIZE in win32.hlp.
Thanks. Been trying it, but the effect is not what I expected. I am
using the OnShow event, which seems to be the right place, of the
tabsheet to do this:
SendMessage(PageControl1.Handle, TCM_SETITEMSIZE, 0,
MAKELPARAM(100,100));
It looks like it's reserving space as specified, but still the tab
size itself takes the old dimensions. I am getting drawn something
like this:
_____
| Tab |
|
|
|
| |
| |
| |
------------------------------
where it should be
_____________
| Tab |
| |
| |
| ----------------
| |
| |
| |
------------------------------
In other words: Tab is still as small as the fontsize and captionsize
allow it to be. It is not the specified width. There seems to be some
reserved space of the new dimensions (concluded that because of the
incomplete right line). Not all the lines are drawn. Missing the right
one of the tab and the top of the page.
Further more, my drawing is not displayed in that reserved region. I
see some drawing on the left (some kind of border idea) and the
drawing in the (small) tab, but that's it.
Any help appreciated. I've put my testcase source below my sig.
Kind regards,
Mark Smits
--
Sm...@Com-Unit.com
Com-Unit BV, The Netherlands.
The makers of Spider-Road®.
procedure TForm1.PageControl1DrawTab(Control: TCustomTabControl;
TabIndex: Integer; const Rect: TRect; Active: Boolean);
var
CenterText, CenterRect: Integer;
TextLeft, TextTop: Integer;
RectTop, RectMiddle, RectBottom: TRect;
begin
try
RectTop := Rect;
RectMiddle := Rect;
RectBottom := Rect;
RectTop.Bottom := RectTop.Top + ((Rect.Bottom - Rect.Top) div 3);
RectMiddle.Top := RectTop.Bottom + 1;
RectMiddle.Bottom := RectMiddle.Top + ((Rect.Bottom - Rect.Top)
div 3);
RectBottom.Top := RectMiddle.Bottom + 1;
Control.Canvas.Brush.Color := clRed;
Control.Canvas.FillRect(RectTop);
Control.Canvas.Brush.Color := clWhite;
Control.Canvas.FillRect(RectMiddle);
Control.Canvas.Brush.Color := clBlue;
Control.Canvas.FillRect(RectBottom);
Control.Canvas.Brush.Style := bsClear;
Control.Canvas.Font.Color := clBlack;
Control.Canvas.Font.Style := Control.Canvas.Font.Style + [fsBold];
Control.Canvas.Font.Size := RectMiddle.Bottom - RectMiddle.Top -
(2 * 3);
CenterText := Control.Canvas.TextWidth(TabSheet1.Caption) div 2;
CenterRect := (Rect.Right - Rect.Left) div 2;
TextLeft := Rect.Left + (CenterRect - CenterText);
CenterText := Control.Canvas.TextHeight(TabSheet1.Caption) div 2;
CenterRect := (Rect.Bottom - Rect.Top) div 2;
TextTop := Rect.Top + (CenterRect - CenterText);
Control.Canvas.TextOut(TextLeft, TextTop, TabSheet1.Caption);
finally
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if not PageControl1.OwnerDraw then begin
TabSheet1.Caption := 'THE NETHERLANDS';
PageControl1.OwnerDraw := True;
end else begin
TabSheet1.Caption := 'Tab';
PageControl1.OwnerDraw := False;
end;
end;
procedure TForm1.TabSheet1Show(Sender: TObject);
var
Result: Integer;
i: Integer;
begin
if PageControl1.OwnerDraw then begin
Result := SendMessage(PageControl1.Handle, TCM_SETITEMSIZE, 0,
MAKELPARAM(200,200));
end;
end;
I have never used this message but from the docs i suspect that it is
intended for the use with owner-drawn tabcontrols only, so *you* are
supposed to fill the reserved area with meaningful content, the default
drawing will still use the old standard size.
>I have never used this message but from the docs i suspect that it is
>intended for the use with owner-drawn tabcontrols only, so *you* are
>supposed to fill the reserved area with meaningful content, the default
>drawing will still use the old standard size.
If only my drawing would show up in that reserved area. But it isn't
and the "default" tab with its "default size" is still drawn
automatically. I think I must force a repaint in some way. If time
permits I will go through the VCL source and see what Borland is doing
when setting TabWidth/TabHeight.
Anyway, I am now using the TabHeight and TabWidth to control the size
of the Tabs. Not exactly what I need (I need varying widths not
depending on the TextWidth of the caption), but it will do for now.
Thanx for the help.
As a cheap n' chearful fudge you can extend the caption with spaces to
adjust tabwidth.
--
Regards,
Chris Luck.