Jump to content
  • Advertisement
Sign in to follow this  
shane1985

[.net] Problems with Hide/Show

This topic is 4810 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am working on a program which has a main window, and then calls a new form to get user input. The problem is, when I click the "done" button, and call this.Hide(), I get a large flicker about half of the time as it appears to be redrawing the main window. This happens with both newform.Show() and newform.ShowDialog(). Also, it does not appear to occur when I use this.Close(). Any ideas? -Shane

Share this post


Link to post
Share on other sites
Advertisement
Well I think it might be normal: if your input dialog is in front of your main window, when you close the dialog the main window must be repainted.

If the painting of your main window is long/complex, it may flicker a bit. If it's a problem, try to use double-buffering if you can.

Regards,
jods

Share this post


Link to post
Share on other sites
What does flicker exactly, then ?
You may also give more details about how your application is built. Since this is .NET forum, I assume you have a WinForms application. You say your main window is OpenGL, which I understand as you use OpenGL to render the window in the Paint message.

Do you do all the painting in the WM_PAINT message ? Otherwise, the window will clear its background (OnPaintBackground) and then render itself (OnPaint) and so it could flicker, even if OpenGL rendering is double-buffered.

In .NET 1.1, you have to set the following flags:
myControl.Setstyle(Controlstyles.UserPaint | Controlstyles.AllPaintingInWmPaint, true);
Notes:
- myControl could be a form (Form inherits Control)
- the following flag may also be useful, but should not be needed since OpenGL already buffers the rendering:
myControl.Setstyle(Controlstyles.DoubleBuffer, true);

In .NET 2.0, you can set all 3 flags and enable double-buffering for a control just by setting the DoubleBuffered property to true;

It should help,
jods

Share this post


Link to post
Share on other sites
Actually, the way I was doing it was just having an event handler called when the window was invalidated, and from there calling the opengl.draw function.

Is there a way to disable to background clear while still doing the rendering this way?

Or do I need to rework the way I'm rendering to the OpenGL control?

BTW, yes it is a WinForms application, and the main window has a large control into which I render with OpenGL.

[Edit]

I messed around with it a little bit, and switched from responding to invalidate to responding to paint with the same event handler.

I also removed another line that may have contributed to the problem, and it appears to work for now.

Share this post


Link to post
Share on other sites
Glad that your problem was resolved.
Painting the form in response to Invalidate surely was a problem.

When you call Invalidate, you basically mark your control (or a part of it) as needing repainting. This makes windows sends a WM_PAINT message to your control, which result in OnPaint being called. So the correct way to do it is to Invalidate, and do the painting in OnPaint.

Note: if you want an immediate repainting, call Update after Invalidate. It ensures that the needed painting is done.

Regards,
jods

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!