Quantcast
Channel: Windows Forms General forum
Viewing all articles
Browse latest Browse all 12583

Aerosnap when Form Border Style is set to none?

$
0
0

If I want a custom form how do I get Aero Snap properties?

I have a panel that behaves as a title bar and three buttons for minimize, restore and close, but I can only use the panel to drag the window around, it doesn't have aero properties like the custom forms used in iTunes or Visual Studio 2012.

//Variables

//Dragging
        private bool dragging = false;
        private Point dragCursorPoint;
        private Point dragFormPoint;

//Minimize, Restore and Close private void btnExit_Click(object sender, EventArgs e) { Application.Exit(); } private void btnRstrMax_Click(object sender, EventArgs e) { if (this.WindowState == FormWindowState.Maximized) { this.WindowState = FormWindowState.Normal; } else { this.WindowState = FormWindowState.Maximized; } } private void btnMin_Click(object sender, EventArgs e) { this.WindowState = FormWindowState.Minimized; } //Panel to drag window, how do I make it behave like a proper title bar with aero snap properities? private void panel1_MouseDown(object sender, MouseEventArgs e) { dragging = true; dragCursorPoint = Cursor.Position; dragFormPoint = this.Location; } private void panel1_MouseMove(object sender, MouseEventArgs e) { if (dragging) { Point dif = Point.Subtract(Cursor.Position, new Size(dragCursorPoint)); this.Location = Point.Add(dragFormPoint, new Size(dif)); } } private void panel1_MouseUp(object sender, MouseEventArgs e) { dragging = false; } private void panel1_MouseDoubleClick(object sender, MouseEventArgs e) { btnRstrMax.PerformClick(); }



Ivan


Viewing all articles
Browse latest Browse all 12583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>