|
I don't understand why the collection is shared. If you want to destroy the shared collection with an instance of the class (i.e. any instance of the class) then it would affect all instances of the class.
Have you considered just emptying the collection? Or assigning a new collection object to the shared member variable. You could encapsulate this by creating, say, a Reset() method that either empties the collection, or assigns a new collection to the shared member variable. This would mean that there is at least a collection object, even if it doesn't have any items in it.
My: Blog | Photos | Next SQL Presentation
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
|
|
|
|
|
Yep i have assigned a new collection to the shared collection.
|
|
|
|
|
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
|
|
|
|
|
Hi;
I do not have a definitive answer for you. What I believe is happening is when you go to draw with the e.Graphics.DrawPath function, that function fails with the “out of memory” exception. I believe there are too many points in the GraphicsPath object. You can prove this fore yourself by storing the start X and Y during mouse down event and add the line during the mouse up event to the GraphicsPath . You will only have two points for each line but the program will work. The only difference between the two is the number of points in GrapthicsPath.
One other points, the variable path( , ) should only be a one dimensional array such as path(13) would work fine.
I hope this was of some help.
|
|
|
|
|
Hi I have a program which is a gui for a command line program. The command line program calls ntvdm. Heres the part I need help with.
I have redirect the output to a textbox this works fine as long as I don't run the functions that use ntvdm.exe if I do then the output will not redirect until the end of it processing (can be a very long time) while if I run the command line with the gui it prints directly to cmd.exe as it goes.
Pretty much I was wondering if anyone knows how to get the output to show up line for line when it uses ntvdm.exe?
I've tried everything and need help (well everything I can think of)
Jay
|
|
|
|
|
NTVDM is the NT Virtual DOS Machine and every DOS application, or 16-bit Windows 3.1 app, run in it. What do you by "using the functions in ntvdm"? If your application writes directly to the screen buffer, there's no way your going to capture the output using redirected streams because the output isn't being shown using the standard console streams.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
okay the program uses the nt dos for some functions then passes the output over. So I guess I won't be able to capture it until its done.
was worth a try thanks for your help
Jay
|
|
|
|
|
Having a weird problem. On some of my forms, my textboxes are appearing flat with a blue border around them instead of fixed3d. My property for the textbox says BorderStyle Fixed3D. I'm using vb.net 2003. Anyone come accross this problem?
"The things that will destroy us are: politics without principle; pleasure without conscience; wealth without work; knowledge without character; business without morality; science without humanity; and worship without sacrifice."
-Mahatma Gandhi (1869-1948)
|
|
|
|
|
|
I checked the solution and everything looks proper. I forgot to mention that this weird behavior happens only to some of my testbox's not all of them?
Regards
"The things that will destroy us are: politics without principle; pleasure without conscience; wealth without work; knowledge without character; business without morality; science without humanity; and worship without sacrifice."
-Mahatma Gandhi (1869-1948)
|
|
|
|
|
Are u using WindowsXP?? because the XP theme for textboxes is flat with blue border.
If u enable using XP visual styles
Application.EnableVisualStyles()
then u will get that style, even if u set the BorderStyle property to Fixed3D.
Hope this helps
|
|
|
|
|
Nope, don't have that code in my programs.
"The things that will destroy us are: politics without principle; pleasure without conscience; wealth without work; knowledge without character; business without morality; science without humanity; and worship without sacrifice."
-Mahatma Gandhi (1869-1948)
|
|
|
|
|
5 from string " asdcxxv (5)". Thanks.
<italic>Work hard, Work effectively.
|
|
|
|
|
A regular expression, like "\((\d*)\)".
This will match any digits within brackets, and put them into match group 1.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I mean, I want to get the number within brackets. I couldn't find any VB function to get the position of "(" character in the string. I'm looking something like indexOf, Find, or something like that. I'm using VB6.
<italic>Work hard, Work effectively.
|
|
|
|
|
You don't have regex in VB6 ? I thought you did. I'm sorry, I don't use any variety of VB, I have certainly never installed VB6. I hope someone else can help you.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Read MSDN on use of InStr function. It can be used to search strings for any character.
Robert
|
|
|
|
|
Hi Yulianto,
try this thing,
Dim Str, StrValue, StrTemp As String
Dim PosStart, PosEnd As Integer
Str = "asdcxxv (5)"
PosStart = InStr(Str, "(")
StrTemp = Mid(Str, PosStart + 1)
PosEnd = InStrRev(StrTemp, ")")
StrValue = Mid(StrTemp, 1, PosEnd - 1)
MsgBox StrValue
hope this helped you
Het Waghela
Be Humble in Victory and Strong in Defeat.
Het Waghela, Blog|Het Waghela DotNet Questions Link|More Links
|
|
|
|
|
I am trying to create a customeizable unix style program launcher
(for those of you who dont know unix, it is a lot of 3d cubes sitting in clusters)
using a MDI container to launch the programs in.
is it possible to launch a external program (MSWord for instance) inside a MDI container as a child? if so, how??
Thanks a lot.
|
|
|
|
|
What are the limitations of custom controls in VB.NET?
Is my imagination the limit?
|
|
|
|
|
nick.ueda wrote:
What are the limitations of custom controls in VB.NET?
Is my imagination the limit?
No, your ability to code them in such a way that they are responsive and useful is the limit.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
but I can create one from scratch correct?
hypothetically I can create a custom control
that looks like nothing anyone has ever seen?
I guess I am trying to ask if I am limited to
only inheriting controls that already exist
within the .Net Framework. I can create base
controls myself and build on them right?
|
|
|
|
|
You can inherit from a base Control class that does nothing, and then you'll be responsible for all painting and event handling, meaning you can create a control that does whatever you like. However, unless you have a strong need to do otherwise, you should base your controls on existing ones ( for example, a text box that validates input should just look like a normal text box at first glance ), so that your users are not confused.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I understand...yeah I wasn't looking to stray too
far from standards but I have an idea in my mind
for a control that I think would work really well
for an application that I am working on. I need
to try it out, but I wanted to verify that it is
possible to create anything before I waste my time.
|
|
|
|
|
No worries. Good luck with it. I suggest checking articles here on CP first, it's possible someone has already written the control you have in mind, and presented it as an article. At the least, you'll get lots of info on how best to write custom controls.
Christian Graus - Microsoft MVP - C++
|
|
|
|