Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Borderless form flickers to much after resizing.

Posted on 2011-09-24
7
Medium Priority
?
466 Views
Last Modified: 2013-12-17
Dear Experts,

I have made a borderless form with a borderline painted.
And the user is able to resize the form.
But when the form gets resized it flickers to much!

What can I do about this?

Who knows the answer and is willing to help me?

Greetings,

Peter Kiers
private void StickyNotes_Paint(object sender, PaintEventArgs e)
         {
            using (Pen pen = new Pen(Brushes.Silver, 2))
            {
                e.Graphics.DrawRectangle(pen, this.ClientRectangle);
            }
         }

      Private void StickyNotes_Resize(object sender, EventArgs e)
{
this.Invalidate();
}

Open in new window

0
Comment
Question by:peterkiers
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 36593087
I thought it might surface as a problem.

There is a ResizeEnd event - you could put the invalidate in there (instead of OnResize) but check it first - it looks odd.

If it is not suitable you would need to store the original rectangle coordinates you draw then erase them (draw in pen with sam colour as the background) before drawing the new rectangle in the OnPaint event.


(Maybe you should consider just having a border on the form instead of borderless - stops you inventing the wheel again)
0
 
LVL 1

Author Comment

by:peterkiers
ID: 36593112
ResizeEnd had no effect.

"If it is not suitable you would need to store the original rectangle coordinates you draw then erase them (draw in pen with sam colour as the background) before drawing the new rectangle in the OnPaint event."

Can you PLEASE tell me how?
P.

0
 
LVL 1

Author Comment

by:peterkiers
ID: 36593115
Oh ye,forgot to mention

I have just a form that i have give a certain color
and a borderline painted.

P.
0
Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 1000 total points
ID: 36593428
You are recreating and disposing of the Pen on each pass into Paint.

Define the Pen as a form level variable.

Then, I haven't work in those things for a long time and I do not have time to check, so I could be wrong, but I do not think you have to Invalidate the form. It is done automatically while you are resizing. If you do it, it gets done twice.

And finally, a personal remark. I do not thing that it is a good idea to have a resizable form with such a thin border. Any user of Windows is used to the look of a resizable form. It has a tick border that is in more than one color, either some kind of a gradient in the newer versions of Windows, or thin black lines with grey inside in the order ones.
0
 
LVL 86

Assisted Solution

by:Mike Tomlinson
Mike Tomlinson earned 1000 total points
ID: 36594455
Have you tried enabling double buffering?...
0
 
LVL 40
ID: 36595270
Double buffering saves a copy of the bitmap. It is thus useful when there is something on the form. As I understand, the form is empty right now.
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 36595620
Try Invalidate(false); instead of just Invalidate();  Maybe that will help (it shouldn't force child controls to redraw).
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question