|
I've made a small code for free drawing in a pictureBox. With that, i can draw when i click-n-hold left mouse-button, release the mouse and draw anothers (without myPenWidth). But if i define myPen with the myPenWidth(if no, it's always 1 by default), there always a error "OutOfMemory" to be made when "i release my first mousedown and mousemove, and mousedown again".
Why's it happens??
This is my code:
Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown<br />
If e.Button = MouseButtons.Left Then<br />
mousePath.StartFigure()<br />
End If<br />
End Sub<br />
<br />
Private Sub PictureBox1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove<br />
If e.Button = MouseButtons.Left Then<br />
PictureBox1.Image = myImg<br />
Dim g As Graphics = Graphics.FromImage(PictureBox1.Image)<br />
Dim myPen As Pen = New Pen(Color.Blue, myPenWidth) <br />
mousePath.AddLine(e.X, e.Y, e.X, e.Y)<br />
g.DrawPath(myPen, mousePath)<br />
End If<br />
<br />
End Sub
|
|
|
|
|
You're not Diposing your Pen and Graphics objects after you're done using them in your MouseMove event handler. If you skip this step, you'll quite easily run the system out of GDI resources and/or system handles, causing the "Out of Memory" Exception.
.
.
.
Dim g As Graphics = Graphics.FromImage(PictureBox1.Image)
Dim myPen As Pen = New Pen(Color.Blue, myPenWidth)
mousePath.AddLine(e.X, e.Y, e.X, e.Y)
g.DrawPath(myPen, mousePath)
myPen.Dispose()
g.Dispose()
.
.
But, since you'll using this method constantly, you might want to put creating/destroying the Pen objject outside the MouseMove handler. This way you won't be creating a new pen every time the mouse moves at least one pixel!
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
i've modified it following your way, but it still OutOfMemory...
hix, how can i do this?
Any more help??
|
|
|
|
|
You can use mousePath.AddEllipse instead of mousePath.AddLine
Private mousePath As New System.Drawing.Drawing2D.GraphicsPath<br />
Dim myPenWidth As Integer = 12<br />
<br />
Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown<br />
If e.Button = Windows.Forms.MouseButtons.Left Then<br />
mousePath.StartFigure()<br />
End If<br />
End Sub<br />
<br />
Private Sub PictureBox1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove<br />
If e.Button = Windows.Forms.MouseButtons.Left Then<br />
Dim g As Graphics = Graphics.FromImage(PictureBox1.Image)<br />
Dim myPen As Pen = New Pen(Color.Blue, myPenWidth)<br />
PictureBox1.Image = myImage<br />
mousePath.AddEllipse(e.X, e.Y, myPenWidth, myPenWidth)<br />
g.DrawPath(myPen, mousePath)<br />
End If<br />
End Sub
Chatura from Pearl of the Indian Ocean.
|
|
|
|
|
You only need to start the figure the first time it is clicked as it is already started after this
This will remove the out of memory error but make it so that the next drawn line joins to the last one automatically which you'll have to look at
Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown
If e.Button = MouseButtons.Left Then
If MousePath.PointCount = 0 Then
MousePath.StartFigure()
End If
End If
End Sub
"If i was king cigarettes would be free."
|
|
|
|
|
Thanks!!
|
|
|
|
|
I need to have a user select an item from a combo box and I need to use that text. I have tried combobox.selecteditem, .selectedvalue, .selectedtext and none of these seem to work. Please help. Thanks in advance.
Also, the text originally comes from a database.
|
|
|
|
|
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged<br />
Dim myText As String<br />
myText = ComboBox1.SelectedItem.ToString<br />
End Sub
Chatura from Pearl of the Indian Ocean.
|
|
|
|
|
Hi Friend,
Sorry I don't know ur name.
First of all I would like to know which database u r using and whether u r retrieving data from the database or inserting the data into the database.
If u r firing a SQL query then I think this will b helpful to u :
strsql = "SELECT * FROM Emp WHERE Emp_Name='" & Combo1 & "'"
This query displays all the records from the table named 'Emp' according to the list item selected from the combobox named 'combo1'. 'strsql' is a string holding the query.
Success is not a Destination,
... But a Journey !!
|
|
|
|
|
mcqRecordset.Open "select * From MultipleChoice, MultipleChoiceAnswer,Level Where MultipleChoice.multipleChoiceID=MultipleChoiceAnswer.multipleChoiceID AND MultipleChoice.levelID=Level.levelID", myConnection, adOpenStatic, adLockOptimistic
Error: error in from clause
plz help me
Thx again
Arshaad
|
|
|
|
|
Keep it in the same thread!
---
b { font-weight: normal; }
|
|
|
|
|
Try restructuring the query...
select * From MultipleChoice AS MC<br />
JOIN MultipleChoiceAnswer AS MCA ON MC.multipleChoiceID = MCA.multipleChoiceID<br />
JOIN Level AS L<br />
ON MC.levelID = L.levelID<br />
...Steve
1. quod erat demonstrandum
2. "Give a man a fish and you've fed him for a day. Teach him how to fish and you've fed him for life." I read that somewhere once
|
|
|
|
|
hello there, any help in the following:
For sure u tried to change the skin of windows media player,when u choose the skin the interface(form) take the shape of a certain picture,not the square shape of the ordinary form, example the radiohead skin.
Any help using VB.NET and ill be very very thanksfull
|
|
|
|
|
Set FormBorderStyle property to None
Set the BackgroundImage property to the image you want to use
Now set the TransparencyKey property to the background color of the image.
Run you app
Note: When I tried to do this by using VB.Net 2003 it didn?t work. Solution to this problem is reseting the screen to use color values that are 24 bits or less. In Vb.Net 2005, it works fine.
If the background color of the image appears in your image too, you can see holes in your image, therefore, do not use a common color as the background color of the image.
Chatura from Pearl of the Indian Ocean.
|
|
|
|
|
i've also noticed that not all video cards will make the backgronud color transparent, so be aware that someone running your app could still see the original shape of the form
~~~ From Milano to The Hague, easy as it goes ~~~
|
|
|
|
|
thanks a lot Chatura for ur help
|
|
|
|
|
Hello, iam doing a software, and i need code to open a .doc file on its own (this file to open in MSword) using VB.NET.
-- modified at 4:55 Sunday 26th March, 2006
|
|
|
|
|
|
Hi Guys,
Well I'm totally stumped. I've got a bit of vbscript code that tries to find a particular process running on a machine (Windows NT). If the process exists I want the text ("I am running...") displayed. If it doesn't exist then I want the text ("I am not running") displayed.
Just some background on the OS. Its Win NT 4 service pack 6 and i reinstalled WMI Core 1.5
On win xp, win 2k and win 2k3 the script below works fine. However on windows nt where this will reside on it fails giving me an error 80041001 which I belive is a "Call failed" error.
Can anyone shed some light on why this would be happening on NT in particular? Thanks in advance
<%
Dim strComputer, strProcess
strComputer = "."
On Error Resume Next
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}! \\" _
& strComputer & "\root\cimv2")
Set colProcess = objWMIService.ExecQuery _
("Select * from Win32_Process")
For Each objProcess in colProcess
do while objProcess.name = "Someprocess.exe"
strProcess = objProcess.name
'objProcess.Name
'If objProcess.name = "Someprocess.exe" then
Response.Write ("I am running...")
'Else
'End If
Exit Do
Loop
Next
If strProcess = "" then
Response.Write ("I am NOT running")
End If
%>
|
|
|
|
|
Does the account the this script is running under have at least PowerUser permissions to the machine you're monitoring?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
How do I set the permissions for users in Windows NT? The interface is not what Im used to and Im not sure how I can change it. Thanks
|
|
|
|
|
What user account is this script running under??? Is this script in a web page?? Does the script run on the server or on the client side?? Are you running it by double-clicking a *.VBS file??
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
The script is in a webpage and runs on the server. How do I determine which account is running that script. I would have though it would have been the IUSR_xxxxxxxx account or am I wrong?
|
|
|
|
|
It'll be that account and, No, it doesn't have sufficient rights to do what you want. Add that account to the Power Users group and it'll get the rights it needs. BUT!!! BEWARE!!! This ia a HUGE security risk if your NT server is visible to the Internet.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Where do you actually setup the permissions for accounts in Windows NT?
|
|
|
|