Click here to Skip to main content
16,016,306 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Dispose Class Pin
nitin_ion3-May-05 1:48
nitin_ion3-May-05 1:48 
GeneralRe: Dispose Class Pin
Colin Angus Mackay3-May-05 3:24
Colin Angus Mackay3-May-05 3:24 
GeneralRe: Dispose Class Pin
nitin_ion3-May-05 19:21
nitin_ion3-May-05 19:21 
GeneralRe: Dispose Class Pin
Colin Angus Mackay3-May-05 20:46
Colin Angus Mackay3-May-05 20:46 
GeneralRe: Dispose Class Pin
nitin_ion3-May-05 20:51
nitin_ion3-May-05 20:51 
GeneralRe: Dispose Class Pin
Colin Angus Mackay3-May-05 22:28
Colin Angus Mackay3-May-05 22:28 
GeneralRe: Dispose Class Pin
nitin_ion3-May-05 22:59
nitin_ion3-May-05 22:59 
QuestionHow to capture width in paint event of picturebox Pin
meghadwivedi2-May-05 19:52
meghadwivedi2-May-05 19:52 
I am using below code for drawing lines on picturebox. I am able to change color in it but when i have passed width as parameter with color in paint event then it gives "Out of memory Exception". I can't understand if color is working then why width is not working in paint event. If i pass static 1 then only it works.


Code:
Enum PathColor
BLUE1 = 0
blue2 = 1
blue3 = 2
blue4 = 3
GREEN1 = 4
green2 = 5
green3 = 6
green4 = 7
RED1 = 8
red2 = 9
red3 = 10
red4 = 11
white1 = 12
black1 = 13

End Enum
Enum penwidth

blue1w = 0
blue2w = 1
blue3w = 2
blue4w = 3
green1w = 4
green2w = 5
green3w = 6
green4w = 7
red1w = 8
red2w = 9
red3w = 10
red4w = 11
whitew = 12
blackw = 13

End Enum

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
' Create GraphicsPath for each color
Me.picboard.BackColor = System.Drawing.Color.White
'Me.picboard.BackgroundImage = System.Drawing.Image.FromFile(Application.StartupPath & "\white.bmp")
For i As Integer = 0 To 13
path(i, i) = New GraphicsPath
Next i
' Create each color
myUserColor(PathColor.RED1) = myUserColor(PathColor.RED1).Red
myUserColor(PathColor.red2) = myUserColor(PathColor.red2).Red
myUserColor(PathColor.red3) = myUserColor(PathColor.red3).Brown
myUserColor(PathColor.red4) = myUserColor(PathColor.red4).Brown

myUserColor(PathColor.BLUE1) = myUserColor(PathColor.BLUE1).Blue
myUserColor(PathColor.blue2) = myUserColor(PathColor.blue2).Blue
myUserColor(PathColor.blue3) = myUserColor(PathColor.blue3).Cyan
myUserColor(PathColor.blue4) = myUserColor(PathColor.blue4).Cyan

myUserColor(PathColor.GREEN1) = myUserColor(PathColor.GREEN1).Green
myUserColor(PathColor.green2) = myUserColor(PathColor.green2).Green
myUserColor(PathColor.green3) = myUserColor(PathColor.green3).Yellow
myUserColor(PathColor.green4) = myUserColor(PathColor.green4).Yellow
myUserColor(PathColor.white1) = myUserColor(PathColor.white1).White
myUserColor(PathColor.black1) = myUserColor(PathColor.black1).Black
myPenWidth(penwidth.blue1w) = 5


myPenWidth(penwidth.blue2w) = 5
myPenWidth(penwidth.blue3w) = 5
myPenWidth(penwidth.blue4w) = 5

myPenWidth(penwidth.red1w) = 5
myPenWidth(penwidth.red2w) = 5
myPenWidth(penwidth.red3w) = 5
myPenWidth(penwidth.red4w) = 5

myPenWidth(penwidth.green1w) = 5
myPenWidth(penwidth.green2w) = 5
myPenWidth(penwidth.green3w) = 5
myPenWidth(penwidth.green4w) = 5
myPenWidth(penwidth.whitew) = 5
myPenWidth(penwidth.blackw) = 5
End Sub

Private Sub picboard_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles picboard.Paint
' Try ' error trapping

'myUserColor = (System.Drawing.Color.Black) 'You can remove this line and add a user selected color to
'change the value of myUserColor
If undo = True Then


For i As Integer = 0 To 13
path(i, i) = New GraphicsPath
path(i, i).Reset()
Next i
'Dim g As Graphics = picboard.CreateGraphics()
'g.Clear(Color.White)
'e.Graphics.Clear(System.Drawing.Color.White)

'g.Dispose()
Else
If SetEraser = True Then
myAlpha = 100
picboard.Cursor = New System.Windows.Forms.Cursor("C:\icons\8.ico")
'picboard.Cursor = New System.Windows.Forms.Cursor(Application.StartupPath & "\8.ico")


'Dim CurrentPen = New Pen(Color.FromArgb(myAlpha, System.Drawing.Color.White), 5) 'Set up the pen
'e.Graphics.DrawPath(pen1, mousePath) 'draw the path!
For index As Integer = 0 To 13

'Dim CurrentPen = New Pen(Color.FromArgb(myAlpha, myUserColor(index)), myPenWidth(index)) 'Set up the pen
Dim CurrentPen = New Pen(Color.FromArgb(myAlpha, myUserColor(index)), myPenWidth(index)) 'Set up the pen
'Dim CurrentPen = New Pen(Color.White) 'Set up the pen

e.Graphics.DrawPath(CurrentPen, path(index, index)) 'draw the path!
'e.Graphics.DrawPath(currentpen, mousePath)
'''If (picboard.Image Is Nothing) Then picboard.Image = New Bitmap(picboard.Width, picboard.Height)
'''Dim g As Graphics = Graphics.FromImage(picboard.Image)
'''g.DrawPath(CurrentPen, path(index, index))
Next index

Else
picboard.Cursor = New System.Windows.Forms.Cursor("C:\icons\pen.ico")

myAlpha = 100 ' This will give the color a Alpha effect, you can set this to 255 if you want a full color

'*********************** NOTE ***********************************************
'The line below set the pen up with the ability to add user selected Alpha, Color and Penwidth
' A simpler, but less flexible solution would be to replace the line with the following code:
'Dim CurrentPen = New Pen(System.Drawing.Color.Black, myPenWidth)
'************ End Note ***************************

' Paint all the GraphicsPath one color at a time
'''whitescreen = False
'''blackscreen = False

For index As Integer = 0 To 13

Dim CurrentPen = New Pen(Color.FromArgb(myAlpha, myUserColor(index)),mpenwidth(index)) 'Set up the pen
'Dim CurrentPen = New Pen(Color.FromArgb(myAlpha, myUserColor(index))) 'Set up the pen

e.Graphics.DrawPath(CurrentPen, path(index, index)) 'draw the path!
'''If (picboard.Image Is Nothing) Then picboard.Image = New Bitmap(picboard.Width, picboard.Height)
'''Dim g As Graphics = Graphics.FromImage(picboard.Image)
'''g.DrawPath(CurrentPen, path(index, index))
Next index

End If
'MsgBox("Not happening!")
'End Try
End If

End Sub

Regards
Megha
AnswerRe: How to capture width in paint event of picturebox Pin
Fernando Soto3-May-05 14:30
Fernando Soto3-May-05 14:30 
Generalproblem with ntvdm.exe Pin
Jason Brumwell2-May-05 17:02
sussJason Brumwell2-May-05 17:02 
GeneralRe: problem with ntvdm.exe Pin
Dave Kreskowiak3-May-05 2:22
mveDave Kreskowiak3-May-05 2:22 
GeneralRe: problem with ntvdm.exe Pin
Jason Brumwell3-May-05 15:46
sussJason Brumwell3-May-05 15:46 
GeneralWeird Textbox Behavior Pin
Computer_Guy2-May-05 16:29
Computer_Guy2-May-05 16:29 
GeneralRe: Weird Textbox Behavior Pin
Het21092-May-05 18:59
Het21092-May-05 18:59 
GeneralRe: Weird Textbox Behavior Pin
Computer_Guy3-May-05 2:36
Computer_Guy3-May-05 2:36 
GeneralRe: Weird Textbox Behavior Pin
lmaks3-May-05 19:19
lmaks3-May-05 19:19 
GeneralRe: Weird Textbox Behavior Pin
Computer_Guy4-May-05 2:26
Computer_Guy4-May-05 2:26 
QuestionHow to get Pin
Yulianto.2-May-05 16:09
Yulianto.2-May-05 16:09 
AnswerRe: How to get Pin
Christian Graus2-May-05 16:20
protectorChristian Graus2-May-05 16:20 
GeneralRe: How to get Pin
Yulianto.2-May-05 16:25
Yulianto.2-May-05 16:25 
GeneralRe: How to get Pin
Christian Graus2-May-05 16:26
protectorChristian Graus2-May-05 16:26 
GeneralRe: How to get Pin
rwestgraham2-May-05 18:58
rwestgraham2-May-05 18:58 
AnswerRe: How to get Pin
Het21092-May-05 19:19
Het21092-May-05 19:19 
GeneralMDI Container help Pin
coolsauron2-May-05 15:13
coolsauron2-May-05 15:13 
GeneralLimitations of Custom Controls... Pin
nick.ueda2-May-05 14:32
nick.ueda2-May-05 14:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.