TreeView flashing when resizing a form

T

Terry

I've seen several posts from people who have seen this flashing in
TreeView's when resizing a form. I've noticed it in my app, but only in the
child windows. For example, my main form has a splitter with a TreeView and
I do not get the flickering with it.

I created a new Form based Windows app. Added a TreeView (dock left), then
a splitter and a property grid on the right (dock fill). For this test, I
added a panel and button at the bottom so I could create the child form.

I created a second form and created it the exact same way - TreeView on the
left, splitter and a property grid on the right. In the click handler for
the button on the first form, I create a new "Form2" and call "ShowDialog"
passing "this" in as a parameter to make the main form the parent for the
dialog.

After adding some nodes to each of the tree views, fire up the app. If you
resize the main form, you won't see flickering in the tree view. Click the
button to show the parent form and resize it - you will see horrible
flickering.

Now, why is that? With the exception of the extra panel to hold the button
on the main form, they are identical, yet the child displayed with
ShowDialog shows terrible flickering.

If I had to guess (which I guess I am guessing right now :) I'd say
Microsoft was expecting that forms shown with "ShowDialog" would not be made
resizable so they left out paint optimizations when resizing. If that is
the case, how do we get rid of the flickering when resizing a dialog?

Thanks,
Terry
 
R

Raffaele Rialdi [MVP]

Now, why is that? With the exception of the extra panel to hold the
button on the main form, they are identical, yet the child displayed
with ShowDialog shows terrible flickering.

Try setting double buffer via SetStyle method.

Please do not crosspost.

BTW, .it hierarchy is in Italian and so you should posto into Italian
language here.
 
T

Terry

More information on this. The TreeView only flashes in XP if the desktop is
set to use the "XP Theme". If it is set to "Windows Classic", it does not
flicker when resizing the window.

I also noticed that the folder tree in Windows Explorer flickers badly when
resizing Explorer, so perhaps, if it's OK for Microsoft, I shouldn't worry
about it.

Terry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top