0

I have tried to create a custom border less form for my application. I decided that it had to be resizable, so I put 8 panels on its sides (4 corners, 4 sides actually) and created code which will resize my form when called. Like, for example:

    private void E_MouseDown(object sender, MouseEventArgs e)
    {
        Active = true;
    }
    private void East_MouseMove(object sender, MouseEventArgs e)
    {
        if (Active)
        {
            this.Size = new Size(this.Width + e.Location.X, this.Height);
            this.Refresh();

        }
    }
    private void E_MouseUp(object sender, MouseEventArgs e)
    {
        Active = false;
    }

Unfortunately, the resizing is slow, overloads the CPU and performs visual glitches even with double buffering for the form turned on. I have quite a bit of controls on my form. But what I have noticed is the fact that when I switch to a standard border (like Sizable), and DWM handles the window chrome, resizing is perfect. No glitches, stuttering and flicker. So I came to wonder, how does Windows manage to do? Is there a way to simulate what it is doing via the 8 panels? I hate when it flickers and it halts my project for no reason. The fact is that I worked all day long to mimic the Visual Studio 2013 window chrome and nearly suceeded, there is just this annoying problem... Can you help, please?

Thanks.

Valentin Radu
  • 629
  • 1
  • 11
  • 26
  • It uses this.Invalidate(), not this.Refresh(). Use [WM_NCHITTEST](http://stackoverflow.com/a/2575452/17034) instead of panels. – Hans Passant Aug 26 '14 at 21:12
  • How, can you elaborate a bit? I am new to this, I do not really know how to do it...? Thanks. – Valentin Radu Aug 26 '14 at 21:14
  • You got copy/paste code, if you can't get that going then you ought to be focusing on something else. Then again, one minute isn't exactly enough to even try it. Try it. – Hans Passant Aug 26 '14 at 21:17
  • Thanks, it worked, finally. I failed for me because of my custom CreateParams... anyway, any idea on how to set a form padding's color? – Valentin Radu Aug 26 '14 at 21:43

0 Answers0