Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Repainting a TPanel on a TTabSheet.

Status
Not open for further replies.

zikar

Programmer
Oct 10, 2000
31
JP
Hello,

I have an application with a TPageControl object, itself containing four TTabSheet items. One of the TTabSheet item contains a TPanel element.

My question is why does the repainting of the TPanel does not work properly ?

To be more precise :
1) If the application starts with the TTabSheet containing the TPanel, active. Then the repainting works OK as long as this TTabSheet stays active.
2) When coming from another active page, making the TTabSheet containing the TPanel active. It sops working correctly : if I cover part of the TPanel with another windows, it does not get repainted when I uncover it back. Why ?
3) If I do something involving a change on the TPanel, then the repainting starts to work again properly.

There is obviously something I am not understanding well in the mechanism of repainting the TPanel. Can somebody give me an advice or a hint.

What should be done and where, so that the TPanel always get repainted ?

Thanks in advance.

Michel
 
I'm not sure if this trick will work, but maybe if you use SetFocus() on the TPanel when you set that active tabsheet. It might send the repaint messages directly to the Panel. Sounds like either a windows or a borland bug though.
 
Hi, thanks for this idea;

I tried it, but unfortunately it doesn't change anything.

I wouldn't go that far as thinking it is a Window or Borland bug as you mention. I rather think, I am not making properly the various calls involved in the repainting process.

One detail though I might have forgotten when writing my first message. I am using a TControlCanvas on the TPanel and I am drawing on the TPanel using this TControlCanvas.

What is strange is that, when the canvas has been touched once after making the sheet active, it starts to work fine again. It looks like touching the canvas changes an internal flag making things work. May be I just need to know what this flag is ?

I am waiting for more tips, if you have any.

Michel
 
Belive or not it looks like a BCB bug to me. My app has been affected with that a while. But the fix is simple. Call the control (TPageControl, TTabControl or TForm - whitch is affected too, when docked to another TWinControl) Repaint() method in any event handler that causing the paintin problem.

Unbornchikken
 
OK, then maybe it's abug -:)

I do not really understand your solution though.

I call the Repaint() method in the Form::FormPaint and also I have specific code to draw the canvas which called when the ActivePage->Name corresponds to the one containing the Panel. But as I wrote, this code does not seem to be called as it should all the time when the page is active.
 
Yea. Sorry about my english. I've learnt it from role-playing games like Fallout & co.

So. If an event/action/code occurs what changes any apperance or any purport INSIDE the PageControl you should call it Repaint() method after that.

E.g. you dock a form to PageControl manually. That often works but if you delete that form when it is docked the PageControl offten forget to repaint itself. The solution is simple: call the PageControl Repaint method after the form deletion code.

Hope that was better understandable.

Unbornchikken
 
OK, thanks again.

I have tried a few things. But nothing works.

I am stuck with this problem.

I will try more later.

If somebody has more ideas or an example of a TabSheet with a TPanel inside, I would be interested in taking a look.

Michel
 
Explain further what you mean by using a TControlCanvas on the TPanel. That makes a big difference. Explain the heirarchy a little more too. Like, TPageControl has 1 TPanel on it, and inside that panel is 1 TCanvasControl? And when you touch something, explain that a bit more, what is being updated, the TCanvasControl or the TPanel?

Chris
 
Hi,

I am using a TPageControl and 4 tabsheets, too.

On each Tabsheet there is a TPanel, then a TScrollbox and then my Items to make all items still visible if anyone resizes my app window. I remember during the beginning when I added the tabsheets, that I also had some repainting problems (but I do not remember which).

What I did is not only to set the "ActivePage" property of the TPageControl but I also called the (others AND actual) Tabsheets' ->Show() and ->Hide() functions. Try this and tell me if it was of any help? :)

Regards,

Michael
 
Thanks for all those tips and sorry for my lack of clarity in the first explanation.

I finally solved the problem by calling Repaint() on the MouseDown event of the TPageControl. I tried a few thing and it sounded like I could have used almost any other mouse event.

I must admit I do not fully understand why this works.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top