Basic Painter design flaws and questions

Hey everybody,

I recently began learning Windows programming with VB and I'm having some issues with an assignment. The basis is to create a window called Drawing with two group boxes, one to change the color and one to change the size, and a panel where the drawing takes place. See image:
http://postimg.org/image/xq7xddzj7/



My problem is that the drawing is taking place outside the panel and I'm not entirely sure why.

Code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Public Class Form1

    'Determines whether or not to paint
    Private shouldPaint As Boolean = False

    'Should paint when the mouse is pressed down
    Private Sub drawPanel_MouseDown(sender As Object, e As MouseEventArgs) 
Handles drawPanel.MouseDown
        shouldPaint = True
    End Sub

    'Draw circles when the mouse is pressed and moving
    Private Sub drawPanel_MouseMove(sender As Object, e As MouseEventArgs) 
Handles drawPanel.MouseMove
        If (shouldPaint) Then
            ' Draw a circle where the mouse pointer is present     
            Using g As Graphics = CreateGraphics()
                g.FillEllipse(New SolidBrush(Color.BlueViolet), e.X, e.Y, 4, 4)
            End Using
        End If
    End Sub

    'Do not paint when the mouse is not pressed
    Private Sub drawPanel_MouseUp(sender As Object, e As MouseEventArgs) 
Handles drawPanel.MouseUp
        shouldPaint = False
    End Sub

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    End Sub

End Class 


I have yet to start any coding for the color and size buttons since this currently isn't working inside the panel. Any guidance here would be greatly appreciated!
Last edited on
Not to be a stickler, but you'd probably get more of a response if you post this on some VB forums and not on a C++ forum.
Don't know how VB works but can you debug your program step for step and see what the values are that you get. Most likely it retrieves the absolute value of your cursor or something similar. But as Disch said you should have posted this in a VB forum
Topic archived. No new replies allowed.