Board index » cppbuilder » painting TPageControl without a border

painting TPageControl without a border


2007-03-26 08:43:26 AM
cppbuilder25
Hi all, just a quick question,
I working on a wizard style dialog and I'm trying to use the TPageControl
and TTabSheets to manage and structure this. However I need to paint the
PageControl and child tabsheets without any borders. I'm more or less
achieved this by setting the Style to tsFlatButton and then setting the
TabVisible to false for each tabsheet.
However, the page control is still painted with border - even if it is the
same colour as the parent control. Is it possible to paint the TPageControl
without a border of anykind.
Many thanks in advance,
Mike C
 
 

Re:painting TPageControl without a border

"Mike Collins" < XXXX@XXXXX.COM >wrote:
Quote

[...] Is it possible to paint the TPageControl without a
border of anykind.
Sure. Just intercept any WM_NCPAINT messages and swallow them.
For example:
private: // User declarations
TWndMethod OldWndProc;
void __fastcall NewWndProc( TMessage &Message );
public: // User declarations
__fastcall TForm1(TComponent* Owner);
__fastcall ~TForm1();
//-------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner)
{
OldWndProc = PageControl1->WindowProc;
PageControl1->WindowProc = NewWndProc;
}
//-------------------------------------------------------------
__fastcall TForm1::~TForm1()
{
PageControl1->WindowProc = OldWndProc;
}
//-------------------------------------------------------------
void __fastcall TForm1::NewWndProc( TMessage &Message )
{
if( Message.Msg != WM_NCPAINT )
{
OldWndProc( Message );
}
}
//-------------------------------------------------------------
~ JD
 

Re:painting TPageControl without a border

Hay JD, thanks for the reply.
I tried your code but it didn't seem to solve the problem. I also tried to
combine it with hooking the WndProc for the tabsheets and performing the
same block i.e. WM_NCPAINT however, i still get a white border painted
abount the area. Perhaps i'm missing something here.
Basically i have a Form with two panels, one alined top, the other alined
bottom. Both panels are set so that there colour is clNavy and the form is
set with a colour of clWhite. In the center i have a TPageControl alined to
the client. On the page control i have set the Style to tsFlatButtons.
Within the page control i have a single tabsheet although i will end up with
several tabs. They also appear white and have there TabVisible set to
false. On the first tabsheet i have an Image alined to client - it is
basically just a faded blue background like you would see in a Window XP
installer. Now i wanted to manage each screen in the wizard using a
different tab but at the minute I'm getting an ugly white border painted
around the page control / tab sheet. Intercepting the WM_NCPAINT message on
wither or both controls does not seem to fix it. Any other ideas?
Many thanks in advance,
Mike Collins
"JD" < XXXX@XXXXX.COM >wrote in message
Quote

"Mike Collins" < XXXX@XXXXX.COM >wrote:
>
>[...] Is it possible to paint the TPageControl without a
 

{smallsort}

Re:painting TPageControl without a border

Based on my last post - is it necessary to re-calculate the size of the page
control based on the fact that it is alined to the client and the borders
are now not part of it's size? Was looking at the WM_NCCALCSIZE message but
can't really figure out how to process it...
Thanks again,
Mike
"JD" < XXXX@XXXXX.COM >wrote in message
Quote

"Mike Collins" < XXXX@XXXXX.COM >wrote:
>
 

Re:painting TPageControl without a border

"Mike Collins" < XXXX@XXXXX.COM >wrote:
Quote

Please trim your posts.
Quote
I tried your code but it didn't seem to solve the problem.
Then try changing the logic a tad. For example:
//-------------------------------------------------------------
void __fastcall TForm1::NewWndProc( TMessage &Message )
{
OldWndProc( Message );
if( Message.Msg == WM_NCPAINT )
{
// paint over what is natively painted
}
}
//-------------------------------------------------------------
~ JD
 

Re:painting TPageControl without a border

Thanks for the pointer - i'm looking into it now.
By the way, i did trim my posts...
Mike C
"JD" < XXXX@XXXXX.COM >wrote in message
Quote
Please trim your posts.

 

Re:painting TPageControl without a border

Just for the record, i fixed it with a bit of a hack. Set up the
TPageControl & TTabSheets as described previously but stuck them on a
TPanel. I then set the alignment for the TPageControl to alNone and shifted
it so that it was offset and overlapped. Set the Left = -4, Top = -6,
Height = Panel->Height + 8, Width = Panel->Width + 8, then set all the
anchors - words a treat.
Thanks again,
Mike C
 

Re:painting TPageControl without a border

"Mike Collins" < XXXX@XXXXX.COM >wrote:
Quote

[...] i fixed it with a bit of a hack.
I thought that you were nuts so I tried it and got the same.
I detected WM_NCPAINT with an empty TPageControl and also with
a TTabSheet but when I swallowed the message, nada ... the
border painted any way. Then I removed WS_BORDER from it's
Style and it still painted.
I stopped looking at it after that because you had fixed it to
your satisfaction but it is strange indeed.
~ JD