|
Hi!
I use the beginread() method to read data asynchrounously from a networkStream.In the documentation says that the callback method will run in another thread, and so it happens.The thing is that after the callback function ends (if i do another beginRead() or not) the thread doesn't terminate, it just stays there and if there is another async. read the same thread will respond.(different networkstreams with different threads). Shouldn't the thread terminate?If not how do i end it.
When i use delegates and beginInvoke() for each call the respective thread terminates and another different thread will run the callback function, after a new beginInvoke...but when i do this with beginRead and EndRead it doesn't happen.
Is this correct or am i doing anything wrong?
Thanks in advance.
Never say never
|
|
|
|
|
Hi!
Oops.After all the thread also stays there in the list but the threadpool says that there is no socket taken...shouldn't the thread leave the thread list (in the VStudio thread list) after it terminates?
Never say never
|
|
|
|
|
Hello
I have some problems with integrating dll (written in VC++) into VB application. I looked for some advices through google.
I create three functions packed in dll:
int_4 __stdcall Konec_RecToR(); //Stop
int_4 __stdcall Start_RecToR(); //Start
int_4 __stdcall RecToR_Init_Cap(void (*tmp)(unsigned char* array, int size, unsigned char first_frame, unsigned char last_frame, void* ex_param), void* ex_param);
First two functions work well in VB application. The problem is the third function which includes two parameters: callback function with five parameters and extra parameter.
The syntax in VB is:
Private Declare Function Start_RecToR Lib "RecToR.dll" () As Long
Private Declare Function Konec_RecToR Lib "RecToR.dll" () As Long
Private Declare Function RecToR_Init_Cap Lib "RecToR.dll" (ByVal CalBckFunc As Long, ByRef param As Long) As Long
Dim Success As Long
Dim param As Long
Private Sub Command1_Click()
Text1.Text = "ASCII" & vbCrLf & "FG"
param = 10
Success = RecToR_Init_Cap(AddressOf CallBackFunc, param)
Success = Start_RecToR
End Sub
Private Sub Command2_Click()
Success = Konec_RecToR
End Sub
//this is in separate module.bas file
Public Sub CallBackFunc(ByRef inarray As Byte, ByVal size As Long, ByVal flag_start As Byte, ByVal flag_stop As Byte, ByRef param As Long)
Text1.Text = Text1.Text & "TEST"
End Sub
Application crashes when my dll calls calback function. Did I miss something?
Tomaz Rotovnik
|
|
|
|
|
The problem is that you need to declare a "delegate" callback function. Here is some example code for enumerating thru windows using callbacks just like you need to implement in your code. You shouldn't have any problems figuring out what you need to do from here.
Module EnumWindows
Delegate Function EnumWindows_Callback(ByVal hWnd As Integer, ByVal lParam As Integer) As Integer
Public Declare Function EnumWindows Lib "user32" _
(ByVal lpEnumFunc As EnumWindows_Callback, _
ByVal lParam As Integer) As Integer
Public Declare Function EnumChildWindows Lib "user32" _
(ByVal hWndParent As Integer, ByVal lpEnumFunc As EnumWindows_Callback, _
ByVal lParam As Integer) As Integer
Public Declare Function GetClassName Lib "user32" Alias "GetClassNameA" _
(ByVal hWnd As Integer, ByVal lpClassName As System.Text.StringBuilder, _
ByVal nMaxCount As Integer) As Integer
Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" _
(ByVal hWnd As Integer, ByVal lpString As System.Text.StringBuilder, _
ByVal cch As Integer) As Integer
' The callback routine, common to both EnumWindows and EnumChildWindows.
' the argument passed in lParam is the indent level.
Function EnumWindows_CBK(ByVal hWnd As Integer, ByVal lParam As Integer) As Integer
' display information on this window, with correct indentation
Console.WriteLine(New String(" "c, lParam * 3) & WindowDescription(hWnd))
' then display all child windows, but indent them to the right
EnumChildWindows(hWnd, AddressOf EnumWindows_CBK, lParam + 1)
' Return 1 to continue enumeration.
Return 1
End Function
' return a windows description given its hWnd
Function WindowDescription(ByVal hWnd As Integer) As String
Dim text As String
text = WindowText(hWnd)
WindowDescription = "[" & Right$("0000000" & Hex$(hWnd), 8) & "] " _
& WindowClassName(hWnd)
If Len(text) > 0 Then
WindowDescription &= " - """ & text & """"
End If
End Function
' Return the caption/text of a window.
Function WindowText(ByVal hWnd As Integer) As String
Dim buffer As New System.Text.StringBuilder(256)
Dim length As Integer
length = GetWindowText(hWnd, buffer, buffer.Capacity)
WindowText = buffer.ToString.Substring(0, length)
End Function
Function WindowClassName(ByVal hWnd As Integer) As String
Dim buffer As New System.Text.StringBuilder(256)
Dim length As Integer
length = GetClassName(hWnd, buffer, buffer.Capacity)
WindowClassName = buffer.ToString.Substring(0, length)
End Function
End Module
Sub TestAPICallback()
EnumWindows(AddressOf EnumWindows_CBK, 0)
End Sub
|
|
|
|
|
Thank you for your help.
I will try with VB.NET framework (as I can see from example), because "Delegate" is not supported in VB 6.
I will give feedback as soon as possible.
Tomaz
Tomaz Rotovnik
|
|
|
|
|
Im so far removed from VB6 that I didn't even consider that you maybe using it.
|
|
|
|
|
I have 5 textboxes. I also have a datagrid. the datagrid has 5 columns.ItemID,CheckNo,Payee,Amount,Date.
I need textbox1 to go to ItemID(column1,row1)
I need textbox2 to go to CheckNo.(column2,row1)
Textbox3 to payee(column3,row1)
textbox4 to amount(column4,row1)
textbox5 to date(column5,row1)
I need these to do so on a button click and I already know that the code must be placed in the Private Sub Button1_Click part.
How do I get these textboxes to do so?
|
|
|
|
|
Hi,
I assume your Grid'd Datasource is dtGrid (Datatable)
in that case in Button_Click Event u can Create a New Datarow of dtGrid
dim drNew as Datarow
drNew = drGrid.NewRow
than just pass on the Values of TextBoxes........as
drNew.Item("ItemID") = txtItem.text......
..............
after that just add this Row to ur Table as
dtGrid.Rows.add(drNew)
dgGrid.Refresh......
I hope this is what u want.....
Regards,
Ritesh
|
|
|
|
|
Hey It Seems to be ok but the part that says drNew = drGrid.NewRow it says NewRow is not declared. am I supposed to replace this with something.
|
|
|
|
|
hello
i have build a database using MS ACCESS and write a coding in VB.NET to connect it as below
Imports System.Data.OleDb<br />
<br />
Public Class addItem<br />
Inherits System.Windows.Forms.Form<br />
Dim myconnection As New OleDbConnection("provider=microsoft.jet.oledb.4.0; datasource = Application.ExecutablePath + \LibrarySystem.mdb")<br />
<br />
Private Sub saveB_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles saveB.Click<br />
myconnection.Open()<br />
Dim mycom As New OleDbCommand("INSERT INTO Product(product_code) VALUES ('" & productTb.Text & "')", myconnection)<br />
Dim MyReader As OleDbDataReader = mycom.ExecuteReader()<br />
mycom.ExecuteNonQuery()<br />
myconnection.Close()<br />
MyReader.Close()<br />
mycom.Dispose()<br />
End Sub
but when i click on the saveB button, the error below show up
An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll
which point to
myconnection.Open()
may i know what i did wrong?
thank you in advance
Gary
|
|
|
|
|
GaryKoh wrote:
Dim myconnection As New OleDbConnection("provider=microsoft.jet.oledb.4.0; datasource = Application.ExecutablePath + \LibrarySystem.mdb")
This is your connection string. So it actually evaluates the variable you put in it, shouldn't it look more like this:
Dim myconnection As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Application.ExecutablePath & "\LibrarySystem.mdb")
Better yet, assemble the path name to the database using the proper function:
Dim dbPath As String = Path.Combine(Application.ExecutablePath, "LibrarySystem.mdb")
Then use this to open you database:
Dim myconnection As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dbPath)
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi i have a list of data in a listview.
how do i set specifice item to have Imageicon, certain item don't
I'm using VB.net
|
|
|
|
|
Is it possible work with ADO and MySql Database in VB6?
|
|
|
|
|
Check here[^] for an example using VB and the MySQL ODBC 3.51 Driver using ADO. You'll need the driver, in addition to MySQL - it's available from this site[^].
"If it's Snowbird season, why can't we shoot them?" - Overheard in a bar in Bullhead City
|
|
|
|
|
hi i would like to write a code that let me drag files from a specified folder automatically on a richtextbox not manually, i want to drag all file types on this richtextbox thanks for any help i need code of u can plz
Thanks alot
Metal Man
|
|
|
|
|
I am looking for tourtials to add password/key protection to a source to keep it as safe as possible. Thank You
|
|
|
|
|
Add to a source? Source of what?
Keep what as safe as possible? If you're talking about files, trying checking into the security features of NTFS.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
How would i set a url in an images property? so the image can be automatically downloaded into a program
|
|
|
|
|
Here you go:
Dim webRequest As System.Net.WebRequest = System.Net.WebRequest.Create("http://www.microsoft.com/h/en-us/r/ms_masthead_ltr.gif")
Dim webResponse As System.Net.WebResponse = webRequest.GetResponse
PictureBox3.Image = Image.FromStream(webResponse.GetResponseStream)
Hope this helps.
Tom
|
|
|
|
|
|
I have several date fields in a database I am displaying. Some of the fields do not have a date value yet (they are set to null), but I would like to use the datepicker to put data into them. The problem is that fields that don't have a date in them from the database are filled in with the current date. If the user saves the record the current date will be saved to all the fields that should be blank (null).
Is there a way to display (or not to display) the datepicker field without a date in it?
|
|
|
|
|
How to invoke mouse hover event on task bar menues indiviual buttons. Please if some one help me,answer my question as soon as possible iwll be thank ful to u.. thanks in advance.....
☺«««DTA»»»☺
|
|
|
|
|
How can I compare 2 images using Visual Basic.
I want to compare a image with its master image and see if it has a spot at certain position
Jack
|
|
|
|
|
I use vb6. I want to read bmp's pixel. For example 1st pixel, 2nd pixel or coordinate system (1,1), (5,12).
I examinated a few example about change bmp's . I modified them. I didn't read pixel right.
1st pixel black and 2nd px white > I use "for ... next" read value 1.0 2.0 3.255 4.233
|
|
|
|
|
I'm trying to make a video game on visual basic. it has to have a christmas theme and incorporate random numbers. does anybody have any ideas or tips that i could use???? thanks
|
|
|
|