|
You may use the WaitForMultipleObjects [^] function (instead of WaitForSingleObject one) to wait also for an event and then raise such event whenever you need to terminate gracefully your thread.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Hi Pallini
Thanks for your reply. Your suggestion is certainly a far more elegent way to end the thread, but unfortunately I cannot detect when parent of the ocx is about to shut down, as for some reason it does not call the terminate event
Bertram
|
|
|
|
|
Dear Sir/Maam,
I'm using visual basic 6 (NOT .net) to capture the screen (Screenshot) of a certain application window (Say, cmd.exe).
I already know how to capture the ACTIVE WINDOW. Is it possible to capture (Screenshot) an external proccess (cmd.exe) that is not the current ACTIVE WINDOW?
Please point me to the right direction.
Thank You.
PS: I did search codeproject for a possible article, all articles were all for VB.NET.
|
|
|
|
|
It's done using the exact same process. All you need is the window handle.
BUT!! (there's always one of these ) You can only capture what you see on the screen. If the window is not visible at all, you won't see anything in your captured image at all either.
|
|
|
|
|
Dear Sir Dave,
Is there any work around for that problem?
PS: How do I make use of the the Window Handler? Do you know any articles that might guide me?
Thank You Very Much.
|
|
|
|
|
Only if you can get the other application to render to a new device context. I don't exactly know how to do it myself, but I know it's doable. Warning! Not for the faint of heart, or newbie of skill! Google for "VNC VB.NET" for some library possibilities.
|
|
|
|
|
hi all
I have a banking project developed in vb and oracle( in cd). now i want to copy that project into a new system. So i created all the tables in oracle, but when i am trying to openthe proj in vb this message is poping out can any one help me. I am running out of time pl.
"d:/ documentand settings/....../New/MSRDC20.OCX could not be loaded continue loading Project?"
DO i need to make any changes in the settings for connectivity ans all. i just want to run my project. my tables are ready in oracle.
Regards
Prakash Mishra(Banglore,India)
|
|
|
|
|
Your project is using this component but it's not found on your machine. It WAS on the original machine, but it not installed on the machine you transferred the project to. Either the file is not found, or the control is not registered properly.
The MSRDC20.OCX is part of RemoteData Control. This control shipped with Visual Basic 5.0 and 6.0 Enterprise Edition only. It did NOT ship with the Learning or Professional Editions.
You should find this file under C:\WINDOWS\SYSTEM32. If it's there, open a CMD prompt and type:
C:\> CD C:\WINDOWS\SYSTEM32
C:\WINDOWS\SYSTEM32> REGSVR32 /U MSRD20.OCX
C:\WINDOWS\SYSTEM32> REGSVR32 MSRD20.OCX
|
|
|
|
|
thanks sir
I installed vb6 and removed the professional edition and it really worked
Regards
Prakash Mishra(Banglore,India)
|
|
|
|
|
hello frnds,
how can i want to fetch some value from BLABLA table in to combobox using VB 6 how can i code ????
i am using SQL Server 2000 as a database.
how can i write connection string?
please help..
thankx and regards,
koolprasad2003
Be A Good S/W Eng... Life is swing with you..Enjoy..
|
|
|
|
|
|
Hi,
I have this error:
"The CLR has been unable to transition from COM context 0x1a6e78 to COM context 0x1a6d08 for 60 seconds. The thread that owns the destination context/apartment is most likely either doing a non pumping wait or processing a very long running operation without pumping Windows messages. This situation generally has a negative performance impact and may even lead to the application becoming non responsive or memory usage accumulating continually over time. To avoid this problem, all single threaded apartment (STA) threads should use pumping wait primitives (such as CoWaitForMultipleHandles) and routinely pump messages during long running operations."
this piece of code:
sqlcode = sqlcode & "'" & conv_str(System.Text.Encoding.Default.GetString(crs.Fields(cfieldix).Value), "mysql") & "'"
return the information from a blob field
and the function where the error is being thrown is:
Private Function conv_str(ByVal str As String, ByVal provider As String) As String<br />
<br />
Dim i As Integer, nlstr As String, rstr As Object<br />
' string validation check the string for invalid characters<br />
' keep characters that have the Asci code 32-165, 192-255 and 0,8,9,10,13<br />
' fix here the euro_symbol probleme :p<br />
' provider can either be MySQL or MSSQL<br />
Try<br />
str = str.Normalize()<br />
Catch ex As Exception<br />
'remember to make a detailed report of the error here<br />
conv_str = "NULL"<br />
<br />
Exit Function<br />
End Try<br />
<br />
Dim chrCode As Long, j As Long<br />
For j = 1 To Len(str) Step 1<br />
chrCode = Asc(Mid(str, j, 1))<br />
If chrCode < 32 Then<br />
If chrCode <> 0 And chrCode <> 8 And chrCode <> 9 And chrCode <> 10 And chrCode <> 13 Then<br />
str = Left$(str, j - 1) & " " & Right$(str, Len(str) - j)<br />
End If<br />
End If<br />
If chrCode > 165 And chrCode < 192 And chrCode <> 180 Then<br />
str = Left$(str, j - 1) & " " & Right$(str, Len(str) - j)<br />
End If<br />
<br />
Next j<br />
<br />
nlstr = ""<br />
rstr = ""<br />
i = 1<br />
<br />
If (provider.ToLower() = "mysql") Then<br />
While i <= Len(str)<br />
<br />
Select Case Mid$(str, i, 1)<br />
Case Chr(0) ' ASCII NUL<br />
nlstr = ""<br />
rstr = "\0"<br />
Case Chr(8) ' backspace<br />
nlstr = ""<br />
rstr = "\b"<br />
Case Chr(9) ' tab<br />
nlstr = ""<br />
rstr = "\t"<br />
Case Chr(180)<br />
nlstr = ""<br />
rstr = " '' "<br />
<br />
Case "'"<br />
nlstr = ""<br />
rstr = "\'"<br />
<br />
Case """"<br />
nlstr = ""<br />
rstr = "\"""<br />
Case "\"<br />
nlstr = ""<br />
rstr = "\\"<br />
Case Chr(10), Chr(13) ' line feed and carriage return<br />
If nlstr <> "" And nlstr <> Mid$(str, i, 1) Then<br />
' there was a previous newline and this is its pair: eat it<br />
rstr = ""<br />
nlstr = ""<br />
Else<br />
' this is a fresh newline<br />
rstr = LINE_BREAK<br />
nlstr = Mid$(str, i, 1)<br />
End If<br />
Case Else<br />
nlstr = ""<br />
End Select<br />
<br />
If rstr <> "" Then<br />
str = Left$(str, i - 1) & rstr & Right$(str, Len(str) - i)<br />
i = i + Len(rstr)<br />
rstr = ""<br />
Else<br />
i = i + 1<br />
End If<br />
End While<br />
<br />
End If<br />
<br />
<br />
conv_str = str<br />
<br />
End Function<br />
please help.
thanks
-- modified at 4:33 Monday 4th June, 2007
|
|
|
|
|
I don't use MySql so I don't know how much I'm going to be able to help. But, how many bytes is the value that's you're trying to convert to a string?? It would seem that the operation is retrieving a large block of data from the database and it's taking too long. What is this code supposed to be doing? What's in this field?
|
|
|
|
|
hi,
in the fields are xml documents but in bytes.
The field where I have this error is like 9 Mb
and the function reads the bytes and convert each byte for mysql.
|
|
|
|
|
Well, since 9MB takes a while to come out of the database, you might have run into the problem. Doing this with SQL Server exposes this as a stream, avoiding the blocking call waiting for the entire field to transfer all at once.
|
|
|
|
|
Hello,
I am trying to do as following and I am getting the message
"Cross-thread operation not valid: Control 'ProgressBar1' accessed from a thread other than the thread it was created on.":
My Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim ind As Integer
Button1.Enabled = False
ProgressBar1.Step = 21
ProgressBar1.Value = 0
Dim trd As Threading.Thread = New Threading.Thread(AddressOf ThreadDo)
trd.Start()
ListBox1.Items.Clear()
For ind = 0 To 50000
ListBox1.Items.Add(ind)
Next
Button1.Enabled = True
End Sub
Private Sub ThreadDo()
ProgressBar1.PerformStep()
If ProgressBar1.Value >= ProgressBar1.Maximum Then
Timer1.Enabled = False
End If
End Sub
Please help
Thank you
Eric H.
|
|
|
|
|
You're not allowed to interact with UI components on another thread. I'd use the BackgroundWorker class and use it's progress notification to tell the main thread to update it's progress bar.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Thank you much, have you got any simple example on this.
Eric H.
|
|
|
|
|
|
Thank you, but I already saw it before and it is a litle complicated (I am beginner). I found exactly what I need.
Beginners, see following code:
Option Explicit On
Imports System.ComponentModel
Public Class Form1
Private worker As BackgroundWorker
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
worker = New BackgroundWorker()
worker.WorkerReportsProgress = True
AddHandler worker.DoWork, New DoWorkEventHandler(AddressOf OnWork)
AddHandler worker.ProgressChanged, New ProgressChangedEventHandler(AddressOf OnProgressChanged)
End Sub
Private Sub OnWork(ByVal sender As Object, ByVal e As DoWorkEventArgs)
Dim i As Integer
For i = 1 To 100
System.Threading.Thread.Sleep(10)
worker.ReportProgress(i)
Next
End Sub
Private Sub OnProgressChanged(ByVal sender As Object, ByVal e As ProgressChangedEventArgs)
Invoke(New ChangeProgressBarHandler(AddressOf ChangeProgressBar), e.ProgressPercentage)
End Sub
Private Delegate Sub ChangeProgressBarHandler(ByVal percentage As Integer)
Private Sub ChangeProgressBar(ByVal percentage As Integer)
ProgressBar1.Value = percentage
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
worker.RunWorkerAsync()
End Sub
End Class
Eric H.
|
|
|
|
|
Here is 1 line that will stop that error and you can carry on using a thread.
Control.CheckForIllegalCrossThreadCalls = false
Just put it in the constructor of your form.
There are 10 types of people in the world, those who understand binary and those who dont.
|
|
|
|
|
Yes, but that sucks. The error is there for a reason.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
You're just upset because you didn't think of it or you don't understand it.
I give lessons on Wednesdays and Thursdays if you'd like to attend.
I know that it could give problems but for basic applications where only one thread accesses a control it is perfect. I have used this plenty of times before and had no problems.
There are 10 types of people in the world, those who understand binary and those who dont.
|
|
|
|
|
smyers wrote: You're just upset because you didn't think of it or you don't understand it.
ROTFL - I know about it and know exactly what it does.
smyers wrote: I have used this plenty of times before and had no problems.
If someone has crossed the road with a blindfold on once or twice without problems, does that make it a good thing to do ? I didn't think so.
I prefer to help people learn to code properly, rather than give them nasty shortcuts that are going to bite them down the track when their code gets a little more complex.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Christian Graus wrote: If someone has crossed the road with a blindfold on once or twice without problems, does that make it a good thing to do
It wouldn't be a problem if no cars ever drove down that road.
Like I said, using one thread will give you no problems.
PS - What does ROTFL stand for?
PPS - The lessons offer is still open
There are 10 types of people in the world, those who understand binary and those who dont.
|
|
|
|