|
You have to either draw the string to an image that the picturebox is showing or override the Paint event of the picturebox and put the drawstring code in that, so when the picturebox is told to redraw itself, it has the code to redraw the string.
Controls and images are not "draw once and forget about it". The images of controls do no persist themselves. You have to supply the code to redraw the image AT ANY TIME.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi, I am inserting current date and time in separate fields for every record inserted or modified. The records are correctly updated in the access database. However, the same is not reflected in the datagrid where the inserted or updated data is displayed. The date appears correct, but the time appears as some date. Please help.
With Best Regards,
Mayur
|
|
|
|
|
I have a chat app that use a webcam. I am taking a screenshot of the preview window in order to get the image. Only problem is, if the window is hidden or say minimized, my images come back as big Black square..ughh
Anyone know how to get the window to keep painting itself when its hidden or minimized?
Any help would be appreciated.
Thanks
-Jason
|
|
|
|
|
Hidden windows never the get told to paint themselves by Windows. You can try sending a WM_PAINT message to the target window handle, but there is no guarantee that it'll work anyway. If the window determines that it, itself, is obscured, it won't waste the time painting those regions.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
how to convert a varchar value into varbinary at runtime
iam using vb 6.0 as frontend and sql as backend
|
|
|
|
|
give an example for your need
|
|
|
|
|
the application is to create login id and i want the value i entered in password in varchar is reflected in login tables password column field as varbinary
something like "convert( & txtpwd.text & as varbinary)"
but in my form varbinary is not there
|
|
|
|
|
I dont think that Vb has a built in conversion method for that, although I may be wrong.
But you can use the Convert function in SQL to do it.
CONVERT(varbinary(Length), @TheVarChar))
In your case, the length parameter would be optional
-Jason
-- modified at 4:07 Thursday 2nd February, 2006
|
|
|
|
|
i want to rename folders. i've used system.io namespace, but directories haven't renamed.
if a folder contains files or directories, the directory created a new name, but files and folders doesn't copied. they'll still alive in the old folder.
if you know a function or api (or whatever) to rename folders (like in windows), please response it
|
|
|
|
|
It would help if you posted the code your using to do the rename. Without seeing exactly what you're doing, it's impossible to tell you what you're doing wrong.
Renaming a folder will not make a copy of it and will not copy the contents of the old folder to the copy. You should be doing something like this:
Directory.Move(currentFolderName, newFolderName)
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
i've tried this function. but it fails. i want a code to rename folder while the folder contains something. think in DOS OS we can't do this because, the folder has something. but windows we can easily change folder names. how can i do like that in vb. because windows can do. i inspected kernel32.dll but i couldn't find any suitable functions.
|
|
|
|
|
Read this reply from Dave[^] again, post your code and we can have a look at what you are doing wrong.
...Steve
"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." (Translation: I'll show you the way, but not write the code for you.) I read that somewhere once
|
|
|
|
|
Public Sub renameFolder(ByVal oldFolder As String, ByVal newFolder As String)
Dim folder As New IO.DirectoryInfo(oldFolder)
folder.MoveTo(newFolder)
'The other method
'Dim folder As IO.Directory
'folder.Move(oldFolder, newFolder)
End Sub
|
|
|
|
|
Works on my machine, but you have no error handling at all so we don't know what the problem really is. Use this code to report and display any exception that's thrown...
Public Sub renameFolder(ByVal oldFolder As String, ByVal newFolder As String)
Dim folder As New IO.DirectoryInfo(oldFolder)
Try
folder.MoveTo(newFolder)
'The other method
'Dim folder As IO.Directory
'folder.Move(oldFolder, newFolder)
Catch ex As Exception
'
' Inspect the ex object to determine the reason
' for the error.
'
MsgBox(ex.Message.ToString, MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly, "MoveTo Failed")
Finally
'
End Try
End Sub
...Steve
"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." (Translation: I'll show you the way, but not write the code for you.) I read that somewhere once
|
|
|
|
|
now it works. but i can't understand, this code didn't run like now. it had just created an empty folder. (Thanks GOD) now it runs..
thanks for your patience and interests....
|
|
|
|
|
dungeonsdarknight wrote: now it works. but i can't understand, this code didn't run like now
Maybe, just maybe, the old folder was in use at the time you ran the code at first and threw an exception which you did not catch. If so, you may run into the problem in the future so some exception handling is highly recommended.
...Steve
"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." (Translation: I'll show you the way, but not write the code for you.) I read that somewhere once
|
|
|
|
|
Like Steve said, ths code works. The problem you're probably having is that you can't rename a folder until all the filers in that folder have been closed by whatever processes are using them.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
My project takes a screenshot twice per second and inserts it into a picture box. During this, I am using System.Drawing to draw using the mouse. I am trying to make the label that I draw on transparent so the screenshot in the picture box will be visible. I only want what I draw visible in the label. The following code will show you my technique to draw on the label.
Dim startX As Int16
Dim endX As Int16
Dim startY As Int16
Dim endY As Int16
Dim m_Drawing As Boolean
Dim EraserOn As Boolean
Dim MyPen As New Pen(Color.Black)
Private Sub lblPaint_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles lblPaint.Paint
Dim g As Graphics = e.Graphics
Dim A, B, X, Y As Integer
If EraserOn Then
g.Clear(System.Drawing.Color.White)
EraserOn = False
Return
End If
If radLine.Checked = True Then
g.DrawLine(MyPen, New Point(startX, startY), New Point(endX, endY))
ElseIf radBox.Checked = True Then
If (endX - startX) >= 0 Then
A = endX - startX
X = startX
Else
A = startX - endX
X = endX
End If
If (endY - startY) >= 0 Then
B = endY - startY
Y = startY
Else
B = startY - endY
Y = endY
End If
g.DrawRectangle(MyPen, New Rectangle(X, Y, A, B))
End If
End Sub
Private Sub lblPaint_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles lblPaint.MouseDown
If radFree.Checked = True Then
m_Drawing = True
End If
startX = e.X
startY = e.Y
End Sub
Private Sub lblPaint_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles lblPaint.MouseUp
endX = e.X
endY = e.Y
If m_Drawing = False Then
lblPaint.Refresh()
End If
m_Drawing = False
End Sub
Private Sub lblPaint_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles lblPaint.MouseMove
If m_Drawing Then
lblPaint.CreateGraphics().DrawLine(MyPen, startX, startY, e.X, e.Y)
startX = e.X
startY = e.Y
End If
End Sub
The lblPaint label is set to transparent. What can I do to make it transparent while I draw but only display what I draw?
-- modified at 21:08 Wednesday 1st February, 2006
|
|
|
|
|
What are you doing to redraw your lines AFTER the mouse is released and the label has to be redrawn? Nothing!
You're not tracking what lines need to be redrawn on the label control when the label is, in your code, .Refresh ed.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
If I put lblPaint.Refresh in the MouseUp event it will erase what I've drawn. I'm not sure what you're talking about. How can I correct my problem
|
|
|
|
|
Yeah, it erases what you've drawn. You code isn't REDRAWING it in the labels Paint event! Your code has to store the coordinates of these lines, somewhere, for each line that is drawn. In the labels paint event, it must redraw all those lines every time there is a WM_PAINT message from windows. You'll get this message many, many times, even if you're not dragging the mouse around drawing new lines. So, yes, you're code has to be prepared to coninuously redraw the lines you've drawn and stored.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I can't think of any other way other than to store each coordinate in an array. But the array would utilize lots of memory after some time would it not? And also performance would not be there.
|
|
|
|
|
You could store it them in an array, or whatever list object you want. Memory use will be minimial since your ownly storing 4 32-bit numbers per line. Performance is not an issue unless you're going to be drawing thousands of lines on this control.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I figured out a way but my RAM is drained and then the garbage collector empties and then it fills back up. Same process over and over.
Are there any examples that demonstrate how to redraw?
|
|
|
|
|
It's not as hard as it seems. It just takes a bit of planning to get it right, but what you do depends heavily on what you want the control to do and look like.
Google for "Control Custom Painting[^]" and you'll come up with all kinds of articles and examples.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|