Code:
Imports System.IO
Imports System.Windows.Forms.MouseEventArgs
Imports System.Windows.Forms.Form
Imports System.Windows.Forms.PaintEventArgs
Public Class Edtor
Private gfx As Graphics
Public user As String
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Form1.Visible = True
Me.Visible = False
End Sub
Private Sub SaveFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles SaveFileDialog1.FileOk
End Sub
Private Sub Edtor_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
gfx.Dispose()
End Sub
Private Sub Edtor_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
gfx = Me.CreateGraphics()
End Sub
Public Sub SaveButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveButton.Click
If (Me.SaveFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK) Then
user = Me.SaveFileDialog1.FileName
End If
End Sub
Public Sub Edtor_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
If RadioButton1.Checked = True Then
If e.Button <> Windows.Forms.MouseButtons.Left Then Exit Sub
Dim rect As Rectangle
With rect
.X = e.X - 1
.Y = e.Y - 1
.Height = 2
.Width = .Height / .Height
gfx.DrawRectangle(System.Drawing.Pens.Red, rect)
End With
End If
If RadioButton2.Checked = True Then
If e.Button <> Windows.Forms.MouseButtons.Left Then Exit Sub
Dim rect As Rectangle
With rect
.X = e.X - 1
.Y = e.Y - 1
.Height = 2
.Width = .Height / .Height
gfx.DrawRectangle(System.Drawing.Pens.Blue, rect)
End With
End If
If RadioButton3.Checked = True Then
If e.Button <> Windows.Forms.MouseButtons.Left Then Exit Sub
Dim rect As Rectangle
With rect
.X = e.X - 1
.Y = e.Y - 1
.Height = 2
.Width = .Height / .Height
gfx.DrawRectangle(System.Drawing.Pens.Black, rect)
End With
End If
End Sub
Private Sub drawonform(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
Call Button2_Click(sender, e)
' Create image.
Dim Newimage As Image = Image.FromFile(user)
' Create Point for upper-left corner of image.
Dim ulCorner As New Point(100, 100)
' Draw image to screen.
e.Graphics.DrawImage(Newimage, ulCorner)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Buttonpic.Click
If (Form1.openDiag.ShowDialog() = Windows.Forms.DialogResult.OK) Then
user = Form1.openDiag.FileName
End If
End Sub
End Class
That is the entire code if that helps you out any, the form is called from a button on a different form called Form1...one this form gets called...nothing is supposed to happen UNTIL i push button2, and then the openfile dialog appears and i choose a file to load...but it does it automatically, and in a loop even though i never specified it in an actual loop.
Thanks for the reply!