Question

First look at Exercise 14.7. Then implement same thing in a MDI application. You should have a File Menu which has two sub menus New and Exit. By clicking on New menu, a MDI form should pops up and let the user to paint (similar to Ex. 14.7). Clicking on Exit will terminate the application. (Ex. 14.7) (Enhanced Painter) Extend the program of Fig. 14.38 to include options for changing the size and color of the lines drawn. Create a GUI similar to Fig. 14.43. The user should be able to draw on the applications Panel. To retrieve a Graphicsobject for drawing, call method panel-Name.CreateGraphics). substituting in the name of your Panel.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

below is the solution:

create two form one is main form and one is child form to paint on child form. in child form create a picturebox

frmMain.vb:

Public Class frmMain
    Private Sub NewToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles NewToolStripMenuItem.Click
        frmPaint.Show()
    End Sub

    Private Sub ExitToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ExitToolStripMenuItem.Click
        Me.Close()
    End Sub
End Class

frmPain.vb:

Public Class frmPaint
    Private oldx, oldy As Integer 'variable for x and y axis cursor move
    Private setBool As Boolean = False
    Private Sub frmPaint_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Cursor = Cursors.Hand 'set the cursor as hand
        Me.PictureBox1.BorderStyle = BorderStyle.FixedSingle 'set the picture box border style with line
    End Sub

    Private Sub Event_MouseDown(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown
        If e.Button = Windows.Forms.MouseButtons.Left Then 'if mouse left
            setBool = True 'set the bool value to true when mouse pressed
            oldx = e.X
            oldy = e.Y
        End If
    End Sub

    Private Sub MouseEvent_MouseMove(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove
        Dim g As Graphics = Me.PictureBox1.CreateGraphics 'create a graphics object
        If setBool Then 'check if the bool value is true
            g.DrawLine(Pens.Black, oldx, oldy, e.X, e.Y)
            oldx = e.X
            oldy = e.Y
        End If

    End Sub

    Private Sub MouseEvent_MouseUp(sender As Object, e As MouseEventArgs) Handles PictureBox1.MouseUp
        setBool = False 'set the bool value to false when mouse release
    End Sub
End Class

output:

Add a comment
Know the answer?
Add Answer to:
First look at Exercise 14.7. Then implement same thing in a MDI application. You should have...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • could you please help me with this problem, also I need a little text so I...

    could you please help me with this problem, also I need a little text so I can understand how you solved the problem? import java.io.File; import java.util.Scanner; /** * This program lists the files in a directory specified by * the user. The user is asked to type in a directory name. * If the name entered by the user is not a directory, a * message is printed and the program ends. */ public class DirectoryList { public static...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT