Solved

VB.net resizable borderless moveable form

Posted on 2012-04-05
2
941 Views
Last Modified: 2012-04-05
Hi

I was directed to the following link http://www.codeproject.com/Articles/24005/Resizable-Moveable-Customizable-Borderless-Form

and tried to build the C# code shown in VB.net but for some reason my form doesn't resize easily. It sometimes does then other times stays stagnant. It might have something to do with the C# part  InitializeComponent(); - I show the C# code beneath the VB.net code


Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Text
Imports System.Windows.Forms

Public Class Form1
    ' Set the thickness of the virtual form border that should catch the resizing
    ' If below 1, the resize function does not work!
    Private VIRTUALBORDER As Integer = 5
    Private SHOWVIRTUALBORDERS As Boolean = True

    ' Declare the limits for the form size
    Private MINHEIGHT As Integer = 10
    Private MAXHEIGHT As Integer = 300
    Private MINWIDTH As Integer = 20
    Private MAXWIDTH As Integer = 600


    Private RESIZESTART As Point
    Private RESIZEDESTINATION As Point
    Private MOUSEPOS As Point

    ' Define Rectangles & Booleans for all 9 + 1 areas of the Form.
    Private R0 As Rectangle
    Private R1 As Rectangle
    Private R2 As Rectangle
    Private R3 As Rectangle
    Private R4 As Rectangle
    Private R5 As Rectangle
    Private R6 As Rectangle
    Private R7 As Rectangle
    Private R8 As Rectangle
    Private R9 As Rectangle


    ' Bool to determine if the form is being moved (True when the form is clicked in the center area (R5))
    Private ISMOVING As Boolean

    ' Bool to determine if the form is being rezised (True when the form is clicked in all areas except the center (R5))
    Private ISREZISING As Boolean

    ' Bool's to determine in which direction the form is moving
    Private ISRESIZINGLEFT As Boolean
    Private ISRESIZINGRIGHT As Boolean

    Private ISRESIZINGTOP As Boolean
    Private ISRESIZINGBOTTOM As Boolean

    Private ISRESIZINGTOPRIGHT As Boolean
    Private ISRESIZINGTOPLEFT As Boolean

    Private ISRESIZINGBOTTOMRIGHT As Boolean
    Private ISRESIZINGBOTTOMLEFT As Boolean


    '
    '        
    '          
    '          
    '                Y
    '          
    '                |
    '                |
    '                |
    '                |    
    '                |                                                                          
    '   X   ---------|------------------------------------------------------------------------   X
    '                |                                                                          
    '                |    <-------------------------- R0 ----------------------------->
    '                |
    '                |
    '                |    |-----------------------------------------------------------|  
    '                |    | R1 |                      R2                         | R3 |
    '                |    |-----------------------------------------------------------|
    '                |    |    |                                                 |    |
    '                |    |    |                                                 |    |
    '                |    | R4 |                      R5                         | R6 |
    '                |    |    |                                                 |    |
    '                |    |    |                                                 |    |
    '                |    |-----------------------------------------------------------|  
    '                |    | R7 |                      R8                         | R9 |
    '                |    |-----------------------------------------------------------|
    '                |
    '                |
    '                |
    '                |
    '          
    '                Y                                                                                                                          

    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        Me.SuspendLayout()
        '
        'frmBounds
        '
        Me.ClientSize = New System.Drawing.Size(282, 255)
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None
        Me.Name = "frmBounds"
        Me.ResumeLayout(False)
    End Sub

    Private Sub Form1_MouseDown(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
        Select Case e.Button
            Case MouseButtons.Left

                If R1.Contains(MOUSEPOS) Then
                    ISREZISING = True
                    ISRESIZINGTOPLEFT = True
                    RESIZESTART = PointToScreen(New Point(e.X, e.Y))
                End If
                If R2.Contains(MOUSEPOS) Then
                    ISREZISING = True
                    ISRESIZINGTOP = True
                    RESIZESTART = PointToScreen(New Point(e.X, e.Y))
                End If
                If R3.Contains(MOUSEPOS) Then
                    ISREZISING = True
                    ISRESIZINGTOPRIGHT = True
                    RESIZESTART = PointToScreen(New Point(e.X, e.Y))
                End If
                If R4.Contains(MOUSEPOS) Then
                    ISREZISING = True
                    ISRESIZINGLEFT = True
                    RESIZESTART = PointToScreen(New Point(e.X, e.Y))
                End If
                If R5.Contains(MOUSEPOS) Then
                    ' If the center area of the form is pressed (R5), then we should be able to move the form.
                    ISMOVING = True
                    ISREZISING = False
                    MOUSEPOS = New Point(e.X, e.Y)
                    Cursor = Cursors.SizeAll
                End If
                If R6.Contains(MOUSEPOS) Then
                    ISREZISING = True
                    ISRESIZINGRIGHT = True
                    RESIZESTART = PointToScreen(New Point(e.X, e.Y))
                End If
                If R7.Contains(MOUSEPOS) Then
                    ISREZISING = True
                    ISRESIZINGBOTTOMLEFT = True
                    RESIZESTART = PointToScreen(New Point(e.X, e.Y))
                End If
                If R8.Contains(MOUSEPOS) Then
                    ISREZISING = True
                    ISRESIZINGBOTTOM = True
                    RESIZESTART = PointToScreen(New Point(e.X, e.Y))
                End If
                If R9.Contains(MOUSEPOS) Then
                    ISREZISING = True
                    ISRESIZINGBOTTOMRIGHT = True
                    RESIZESTART = PointToScreen(New Point(e.X, e.Y))
                End If
                Exit Select
        End Select
    End Sub

    Private Sub Form1_MouseMove(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
        RESIZEDESTINATION = PointToScreen(New Point(e.X, e.Y))
        R0 = Bounds

        ' If the form has captured the mouse...
        If Capture Then
            If ISMOVING = True Then
                ISREZISING = False
                ' ISMOVING is true if the R5 rectangle is pressed. Allow the form to be moved around the screen.
                Location = New Point(MousePosition.X - MOUSEPOS.X, MousePosition.Y - MOUSEPOS.Y)
            End If
            If ISREZISING = True Then
                ISMOVING = False

                If ISRESIZINGTOPLEFT Then
                    Bounds = New Rectangle(R0.X + RESIZEDESTINATION.X - RESIZESTART.X, R0.Y + RESIZEDESTINATION.Y - RESIZESTART.Y, R0.Width - RESIZEDESTINATION.X + RESIZESTART.X, R0.Height - RESIZEDESTINATION.Y + RESIZESTART.Y)
                End If
                If ISRESIZINGTOP Then
                    Bounds = New Rectangle(R0.X, R0.Y + RESIZEDESTINATION.Y - RESIZESTART.Y, R0.Width, R0.Height - RESIZEDESTINATION.Y + RESIZESTART.Y)
                End If
                If ISRESIZINGTOPRIGHT Then
                    Bounds = New Rectangle(R0.X, R0.Y + RESIZEDESTINATION.Y - RESIZESTART.Y, R0.Width + RESIZEDESTINATION.X - RESIZESTART.X, R0.Height - RESIZEDESTINATION.Y + RESIZESTART.Y)
                End If
                If ISRESIZINGLEFT Then
                    Bounds = New Rectangle(R0.X + RESIZEDESTINATION.X - RESIZESTART.X, R0.Y, R0.Width - RESIZEDESTINATION.X + RESIZESTART.X, R0.Height)
                End If
                If ISRESIZINGRIGHT Then
                    Bounds = New Rectangle(R0.X, R0.Y, R0.Width + RESIZEDESTINATION.X - RESIZESTART.X, R0.Height)
                End If
                If ISRESIZINGBOTTOMLEFT Then
                    Bounds = New Rectangle(R0.X + RESIZEDESTINATION.X - RESIZESTART.X, R0.Y, R0.Width - RESIZEDESTINATION.X + RESIZESTART.X, R0.Height + RESIZEDESTINATION.Y - RESIZESTART.Y)
                End If
                If ISRESIZINGBOTTOM Then
                    Bounds = New Rectangle(R0.X, R0.Y, R0.Width, R0.Height + RESIZEDESTINATION.Y - RESIZESTART.Y)
                End If
                If ISRESIZINGBOTTOMRIGHT Then
                    Bounds = New Rectangle(R0.X, R0.Y, R0.Width + RESIZEDESTINATION.X - RESIZESTART.X, R0.Height + RESIZEDESTINATION.Y - RESIZESTART.Y)
                End If

                RESIZESTART = RESIZEDESTINATION
                Invalidate()
            End If
        Else

            ' If the form has not captured the mouse; the mouse is just hovering the form...
            MOUSEPOS = New Point(e.X, e.Y)

            ' Changes Cursor depending where the mousepointer is at the form...
            If R1.Contains(MOUSEPOS) Then
                Cursor = Cursors.SizeNWSE
            End If
            If R2.Contains(MOUSEPOS) Then
                Cursor = Cursors.SizeNS
            End If
            If R3.Contains(MOUSEPOS) Then
                Cursor = Cursors.SizeNESW
            End If
            If R4.Contains(MOUSEPOS) Then
                Cursor = Cursors.SizeWE
            End If
            If R5.Contains(MOUSEPOS) Then
                Cursor = Cursors.[Default]
            End If
            If R6.Contains(MOUSEPOS) Then
                Cursor = Cursors.SizeWE
            End If
            If R7.Contains(MOUSEPOS) Then
                Cursor = Cursors.SizeNESW
            End If
            If R8.Contains(MOUSEPOS) Then
                Cursor = Cursors.SizeNS
            End If
            If R9.Contains(MOUSEPOS) Then
                Cursor = Cursors.SizeNWSE
            End If
        End If
    End Sub

    Private Sub Form1_MouseUp(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseUp        ISMOVING = False
        ISREZISING = False

        ISRESIZINGLEFT = False
        ISRESIZINGRIGHT = False

        ISRESIZINGTOP = False
        ISRESIZINGBOTTOM = False

        ISRESIZINGTOPRIGHT = False
        ISRESIZINGTOPLEFT = False

        ISRESIZINGBOTTOMRIGHT = False
        ISRESIZINGBOTTOMLEFT = False

        Invalidate()
    End Sub


    Private Sub Form1_Paint(sender As Object, e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
        ' Every time the form paints, set the location and size of the form areas...
        '#Region "DIVIDE THE FORM INTO 9 SUB AREAS"
        R1 = New Rectangle(New Point(ClientRectangle.X, ClientRectangle.Y), New Size(VIRTUALBORDER, VIRTUALBORDER))
        R2 = New Rectangle(New Point(ClientRectangle.X + R1.Width, ClientRectangle.Y), New Size(ClientRectangle.Width - (R1.Width * 2), R1.Height))
        R3 = New Rectangle(New Point(ClientRectangle.X + R1.Width + R2.Width, ClientRectangle.Y), New Size(VIRTUALBORDER, VIRTUALBORDER))

        R4 = New Rectangle(New Point(ClientRectangle.X, ClientRectangle.Y + R1.Height), New Size(R1.Width, ClientRectangle.Height - (R1.Width * 2)))
        R5 = New Rectangle(New Point(ClientRectangle.X + R4.Width, ClientRectangle.Y + R1.Height), New Size(R2.Width, R4.Height))
        R6 = New Rectangle(New Point(ClientRectangle.X + R4.Width + R5.Width, ClientRectangle.Y + R1.Height), New Size(R3.Width, R4.Height))

        R7 = New Rectangle(New Point(ClientRectangle.X, ClientRectangle.Y + R1.Height + R4.Height), New Size(VIRTUALBORDER, VIRTUALBORDER))
        R8 = New Rectangle(New Point(ClientRectangle.X + R7.Width, ClientRectangle.Y + R1.Height + R4.Height), New Size(ClientRectangle.Width - (R7.Width * 2), R7.Height))
        R9 = New Rectangle(New Point(ClientRectangle.X + R7.Width + R8.Width, ClientRectangle.Y + R1.Height + R4.Height), New Size(VIRTUALBORDER, VIRTUALBORDER))
        '#End Region


        '#Region "SET FILL COLORS FOR THE VIRTUAL BORDER"
        If SHOWVIRTUALBORDERS Then
            Dim GFX As Graphics = e.Graphics
            GFX.FillRectangle(Brushes.White, R5)

            GFX.FillRectangle(Brushes.Gold, R1)
            GFX.FillRectangle(Brushes.Gold, R3)
            GFX.FillRectangle(Brushes.Gold, R7)
            GFX.FillRectangle(Brushes.Gold, R9)

            GFX.FillRectangle(Brushes.Red, R2)
            GFX.FillRectangle(Brushes.Red, R8)
            GFX.FillRectangle(Brushes.Red, R4)
            GFX.FillRectangle(Brushes.Red, R6)
        End If
        '#End Region
    End Sub

    Private Sub Form1_Resize(sender As Object, e As System.EventArgs) Handles Me.Resize
        'CODE TO LIMIT THE SIZE OF THE FORM
        If Height > MAXHEIGHT Then
            Capture = False
            Height = MAXHEIGHT
        End If
        If Height < MINHEIGHT Then
            Capture = False
            Height = MINHEIGHT
        End If
        If Width > MAXWIDTH Then
            Capture = False
            Width = MAXWIDTH
        End If
        If Width < MINWIDTH Then
            Capture = False
            Width = MINWIDTH
        End If
    End Sub
End Class

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C#
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace knas.BorderlessForm
{    
    //    Title:       Resizable, Moveable & Customizable Borderless Form
    //    Author:      http://www.knas.se

    public partial class frmBounds : Form
    {
        public frmBounds()
        {
            InitializeComponent();

            // Make the original form borderless
            FormBorderStyle = FormBorderStyle.None;

            // For smoother drawing of the form...
            DoubleBuffered = true;

            // Set Opacity
            Opacity = 0.9;
        }


        // Set the thickness of the virtual form border that should catch the resizing
        // If below 1, the resize function does not work!
        private int VIRTUALBORDER = 5;
        private bool SHOWVIRTUALBORDERS = true;

        // Declare the limits for the form size
        private int MINHEIGHT = 10;
        private int MAXHEIGHT = 300;        
        private int MINWIDTH = 20;
        private int MAXWIDTH = 600;


        private Point RESIZESTART;
        private Point RESIZEDESTINATION;
        private Point MOUSEPOS;

        // Define Rectangles & Booleans for all 9 + 1 areas of the Form.
        private Rectangle R0;
        private Rectangle R1;
        private Rectangle R2;
        private Rectangle R3;
        private Rectangle R4;
        private Rectangle R5;
        private Rectangle R6;
        private Rectangle R7;
        private Rectangle R8;
        private Rectangle R9;


        // Bool to determine if the form is being moved (True when the form is clicked in the center area (R5))
        private bool ISMOVING;

        // Bool to determine if the form is being rezised (True when the form is clicked in all areas except the center (R5))
        private bool ISREZISING;

        // Bool's to determine in which direction the form is moving
        private bool ISRESIZINGLEFT;
        private bool ISRESIZINGRIGHT;

        private bool ISRESIZINGTOP;
        private bool ISRESIZINGBOTTOM;

        private bool ISRESIZINGTOPRIGHT;
        private bool ISRESIZINGTOPLEFT;

        private bool ISRESIZINGBOTTOMRIGHT;
        private bool ISRESIZINGBOTTOMLEFT;


        /*
       
         
         
                Y
         
                |
                |
                |
                |    
                |                                                                          
   X   ---------|------------------------------------------------------------------------   X
                |                                                                          
                |    <-------------------------- R0 ----------------------------->
                |
                |
                |    |-----------------------------------------------------------|  
                |    | R1 |                      R2                         | R3 |
                |    |-----------------------------------------------------------|
                |    |    |                                                 |    |
                |    |    |                                                 |    |
                |    | R4 |                      R5                         | R6 |
                |    |    |                                                 |    |
                |    |    |                                                 |    |
                |    |-----------------------------------------------------------|  
                |    | R7 |                      R8                         | R9 |
                |    |-----------------------------------------------------------|
                |
                |
                |
                |
         
                Y                                                                                                                           */
       

        private void frmBounds_Paint(object sender, PaintEventArgs e)
        {
            // Every time the form paints, set the location and size of the form areas...
            #region DIVIDE THE FORM INTO 9 SUB AREAS
            R1 = new Rectangle(new Point(ClientRectangle.X, ClientRectangle.Y), new Size(VIRTUALBORDER, VIRTUALBORDER));
            R2 = new Rectangle(new Point(ClientRectangle.X + R1.Width, ClientRectangle.Y), new Size(ClientRectangle.Width - (R1.Width * 2), R1.Height));
            R3 = new Rectangle(new Point(ClientRectangle.X + R1.Width + R2.Width, ClientRectangle.Y), new Size(VIRTUALBORDER, VIRTUALBORDER));

            R4 = new Rectangle(new Point(ClientRectangle.X, ClientRectangle.Y + R1.Height), new Size(R1.Width, ClientRectangle.Height - (R1.Width * 2)));
            R5 = new Rectangle(new Point(ClientRectangle.X + R4.Width, ClientRectangle.Y + R1.Height), new Size(R2.Width, R4.Height));
            R6 = new Rectangle(new Point(ClientRectangle.X + R4.Width + R5.Width, ClientRectangle.Y + R1.Height), new Size(R3.Width, R4.Height));

            R7 = new Rectangle(new Point(ClientRectangle.X, ClientRectangle.Y + R1.Height + R4.Height), new Size(VIRTUALBORDER, VIRTUALBORDER));
            R8 = new Rectangle(new Point(ClientRectangle.X + R7.Width, ClientRectangle.Y + R1.Height + R4.Height), new Size(ClientRectangle.Width - (R7.Width * 2), R7.Height));
            R9 = new Rectangle(new Point(ClientRectangle.X + R7.Width + R8.Width, ClientRectangle.Y + R1.Height + R4.Height), new Size(VIRTUALBORDER, VIRTUALBORDER));
            #endregion


            #region SET FILL COLORS FOR THE VIRTUAL BORDER
            if (SHOWVIRTUALBORDERS)
            {
                Graphics GFX = e.Graphics;
                GFX.FillRectangle(Brushes.White, R5);

                GFX.FillRectangle(Brushes.Gold, R1);
                GFX.FillRectangle(Brushes.Gold, R3);
                GFX.FillRectangle(Brushes.Gold, R7);
                GFX.FillRectangle(Brushes.Gold, R9);

                GFX.FillRectangle(Brushes.Red, R2);
                GFX.FillRectangle(Brushes.Red, R8);
                GFX.FillRectangle(Brushes.Red, R4);
                GFX.FillRectangle(Brushes.Red, R6);
            }
            #endregion
        }


        private void frmBounds_MouseDown(object sender, MouseEventArgs e)
        {
            switch (e.Button)
            {
                case MouseButtons.Left:

                    if (R1.Contains(MOUSEPOS))
                    {
                        ISREZISING = true;
                        ISRESIZINGTOPLEFT = true;
                        RESIZESTART = PointToScreen(new Point(e.X, e.Y));
                    }
                    if (R2.Contains(MOUSEPOS))
                    {
                        ISREZISING = true;
                        ISRESIZINGTOP = true;
                        RESIZESTART = PointToScreen(new Point(e.X, e.Y));
                    }
                    if (R3.Contains(MOUSEPOS))
                    {
                        ISREZISING = true;
                        ISRESIZINGTOPRIGHT = true;
                        RESIZESTART = PointToScreen(new Point(e.X, e.Y));
                    }
                    if (R4.Contains(MOUSEPOS))
                    {
                        ISREZISING = true;
                        ISRESIZINGLEFT = true;
                        RESIZESTART = PointToScreen(new Point(e.X, e.Y));
                    }
                    if (R5.Contains(MOUSEPOS))
                    {
                        // If the center area of the form is pressed (R5), then we should be able to move the form.
                        ISMOVING = true;
                        ISREZISING = false;
                        MOUSEPOS = new Point(e.X, e.Y);
                        Cursor = Cursors.SizeAll;
                    }
                    if (R6.Contains(MOUSEPOS))
                    {
                        ISREZISING = true;
                        ISRESIZINGRIGHT = true;
                        RESIZESTART = PointToScreen(new Point(e.X, e.Y));
                    }
                    if (R7.Contains(MOUSEPOS))
                    {
                        ISREZISING = true;
                        ISRESIZINGBOTTOMLEFT = true;
                        RESIZESTART = PointToScreen(new Point(e.X, e.Y));
                    }
                    if (R8.Contains(MOUSEPOS))
                    {
                        ISREZISING = true;
                        ISRESIZINGBOTTOM = true;
                        RESIZESTART = PointToScreen(new Point(e.X, e.Y));
                    }
                    if (R9.Contains(MOUSEPOS))
                    {
                        ISREZISING = true;
                        ISRESIZINGBOTTOMRIGHT = true;
                        RESIZESTART = PointToScreen(new Point(e.X, e.Y));
                    }
                    break;
            }
        }
       

        private void frmBounds_MouseMove(object sender, MouseEventArgs e)
        {
            RESIZEDESTINATION = PointToScreen(new Point(e.X, e.Y));
            R0 = Bounds;

            // If the form has captured the mouse...
            if (Capture)
            {
                if (ISMOVING == true)
                {
                    ISREZISING = false;
                    // ISMOVING is true if the R5 rectangle is pressed. Allow the form to be moved around the screen.
                    Location = new Point(MousePosition.X - MOUSEPOS.X, MousePosition.Y - MOUSEPOS.Y);
                }
                if (ISREZISING == true)
                {
                    ISMOVING = false;

                    if (ISRESIZINGTOPLEFT)
                    { Bounds = new Rectangle(R0.X + RESIZEDESTINATION.X - RESIZESTART.X, R0.Y + RESIZEDESTINATION.Y - RESIZESTART.Y, R0.Width - RESIZEDESTINATION.X + RESIZESTART.X, R0.Height - RESIZEDESTINATION.Y + RESIZESTART.Y); }
                    if (ISRESIZINGTOP)
                    { Bounds = new Rectangle(R0.X, R0.Y + RESIZEDESTINATION.Y - RESIZESTART.Y, R0.Width, R0.Height - RESIZEDESTINATION.Y + RESIZESTART.Y); }
                    if (ISRESIZINGTOPRIGHT)
                    { Bounds = new Rectangle(R0.X, R0.Y + RESIZEDESTINATION.Y - RESIZESTART.Y, R0.Width + RESIZEDESTINATION.X - RESIZESTART.X, R0.Height - RESIZEDESTINATION.Y + RESIZESTART.Y); }
                    if (ISRESIZINGLEFT)
                    { Bounds = new Rectangle(R0.X + RESIZEDESTINATION.X - RESIZESTART.X, R0.Y, R0.Width - RESIZEDESTINATION.X + RESIZESTART.X, R0.Height); }
                    if (ISRESIZINGRIGHT)
                    { Bounds = new Rectangle(R0.X, R0.Y, R0.Width + RESIZEDESTINATION.X - RESIZESTART.X, R0.Height); }
                    if (ISRESIZINGBOTTOMLEFT)
                    { Bounds = new Rectangle(R0.X + RESIZEDESTINATION.X - RESIZESTART.X, R0.Y, R0.Width - RESIZEDESTINATION.X + RESIZESTART.X, R0.Height + RESIZEDESTINATION.Y - RESIZESTART.Y); }
                    if (ISRESIZINGBOTTOM)
                    { Bounds = new Rectangle(R0.X, R0.Y, R0.Width, R0.Height + RESIZEDESTINATION.Y - RESIZESTART.Y); }
                    if (ISRESIZINGBOTTOMRIGHT)
                    { Bounds = new Rectangle(R0.X, R0.Y, R0.Width + RESIZEDESTINATION.X - RESIZESTART.X, R0.Height + RESIZEDESTINATION.Y - RESIZESTART.Y); }

                    RESIZESTART = RESIZEDESTINATION;
                    Invalidate();
                }
            }

            // If the form has not captured the mouse; the mouse is just hovering the form...
            else
            {
                MOUSEPOS = new Point(e.X, e.Y);

                // Changes Cursor depending where the mousepointer is at the form...
                if (R1.Contains(MOUSEPOS))
                { Cursor = Cursors.SizeNWSE; }
                if (R2.Contains(MOUSEPOS))
                { Cursor = Cursors.SizeNS; }
                if (R3.Contains(MOUSEPOS))
                { Cursor = Cursors.SizeNESW; }
                if (R4.Contains(MOUSEPOS))
                { Cursor = Cursors.SizeWE; }
                if (R5.Contains(MOUSEPOS))
                { Cursor = Cursors.Default; }
                if (R6.Contains(MOUSEPOS))
                { Cursor = Cursors.SizeWE; }
                if (R7.Contains(MOUSEPOS))
                { Cursor = Cursors.SizeNESW; }
                if (R8.Contains(MOUSEPOS))
                { Cursor = Cursors.SizeNS; }
                if (R9.Contains(MOUSEPOS))
                { Cursor = Cursors.SizeNWSE; }
            }
        }


        private void frmBounds_Resize(object sender, EventArgs e)
        {
            //CODE TO LIMIT THE SIZE OF THE FORM
            if (Height > MAXHEIGHT)
            {
                Capture = false;
                Height = MAXHEIGHT;
            }
            if (Height < MINHEIGHT)
            {
                Capture = false;
                Height = MINHEIGHT;
            }
            if (Width > MAXWIDTH)
            {
                Capture = false;
                Width = MAXWIDTH;
            }
            if (Width < MINWIDTH)
            {
                Capture = false;
                Width = MINWIDTH;
            }
        }
       

        private void frmBounds_MouseUp(object sender, MouseEventArgs e)
        {
            ISMOVING = false;
            ISREZISING = false;

            ISRESIZINGLEFT = false;
            ISRESIZINGRIGHT = false;

            ISRESIZINGTOP = false;
            ISRESIZINGBOTTOM = false;

            ISRESIZINGTOPRIGHT = false;
            ISRESIZINGTOPLEFT = false;

            ISRESIZINGBOTTOMRIGHT = false;
            ISRESIZINGBOTTOMLEFT = false;

            Invalidate();
        }
       


    }
}
0
Comment
Question by:murbro
2 Comments
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
Comment Utility
The C# code is using the Constructor, not the Load() event:
Public Class Form1

    Public Sub New()
        ' This call is required by the designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.
        FormBorderStyle = FormBorderStyle.None
        DoubleBuffered = True
        Opacity = 0.9
    End Sub

End Class

Open in new window


*Not sure if that will fix your problem.
0
 

Author Closing Comment

by:murbro
Comment Utility
That made a big difference. Thanks very much! It still has a slight jump but I suppose that is to be expected
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

762 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now