OnPaint for TabControl not working.

aewarnick

Well-known member
Joined
Jan 29, 2003
Messages
1,031
I created my own custom tab control inheriting from TabControl. I have it in one of my programs and it is painted but my override of the OnPaint event does not even enter.

protected override void OnPaint(PaintEventArgs e)

OnResize works but not OnPaint. Why?
 
Last edited by a moderator:
That control is drawn by Windows, not any .NET code, so overriding that method is pretty much useless unfortunately. To draw it yourself you would have to intercept the WM_PAINT message and send the control various messages to find out the bounds of everything.
 
Does that mean that I will have to draw the whole thing, or can I just paint on the ClientRectange a different color. Either transparent or gradient?

And if you would, could you direct me to some sample code of doing this thing?
 
I have no experience ownerdrawing tabcontrols, perhaps someone else will chip in.

If youre after a way to make the tabcontrol client background gradiented properly under windows xp, there is a replacement control out there which does it correctly.
 
I take it that for each control there are different messages sent and not just a standard for everything?
 
Its always WM_PAINT sent to paint it, but thats not much use without the other messages that _you_ send to the control to get or set the bounds of everything so you know where to paint.
 
Back
Top