Clearing on load

V

Verdagon

Hey everyone. I have this function in my form called "Display", which I
call every time the load, resize, and paint events are called. It works
fine on paint and resize, but on load it doesnt happen.

When the form loads, it draws what I want, but then after a few
milliseconds it disappears. It's being drawn over by something else.
What's drawing over it?

I've tried using SetStyle, and setting UserPaint and
AllPaintingInWmPaint, and that doesn't do anything. I've tried making
an override of OnPaint and commenting out "base.OnPaint(e)", but that
doesnt work. No matter what I do, my changes are drawn over when the
form loads.

I've also tried overriding DefWndProc to see what messages are causing
this, but I can't make heads or tails of the messages that are coming
through. Although, some of them said things about focus and
activating... so I tried calling Display on the enter and activate
events too, and even that didn't work!

I've googled it, but all I get as results are things about double
buffering, and SetStyle and UserPaint, which I've already tried.

I've even tried calling Validate after every single line of code in my
form.

What am I doing wrong? How do I get rid of this drawing-over of my
form? Or how can I draw my own stuff after this drawing-over occurs?
Thanks in advance.

- E
 
T

Tim Wilson

What does the "Display" method do? If it only paints then you should place
this code, or the call to this method, only inside a Paint event handler or
the OnPaint override. The Form will be painted when it is first shown, and
you can use the SetStyle method and the ResizeRedraw flag to have the Form
repainted when it is resized.
 
V

Verdagon

Aha! Figured it out.

I tried moving all my code to the paint event's handler, and it still
didn't work. So I decided to make a new project, see if it behaved any
differently. It did. I looked at the form's properties, and they were
all messed up. I assume its from my earlier experimenting.

Earlier today I was trying to double buffer my form, so I enabled the
double buffering property on the form. It didn't do anything to reduce
flicker, so I tried the manual double buffering way, and that worked.
But the double buffering property was still on, which drew over any
changes I made.

Thanks for your time!

- E
 

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