|
Hello all! Is there a way in VB.NET to enable the "Show window contents while dragging" option in code? Or perhaps, to bypass it if its set to disabled? Or check its status?
Thank you for your time.
|
|
|
|
|
Hi All,
First off all, I want to THANK everyone on this site for whatever contribution they delivered. As a starting Developer ( used-to-be sysadmin) I can't even count anymore how many articles here i've read which helped me out A LOT.
But now. i'm stuck...
I've written an application using an ASync SocketClient which communicates with a server. Now that it has become clear that several applications should communicate with the same TCP server using same protocol and logic, i wanted to pull the socketclient from the app, built a dll from it and "voila".. however, I'm having a problem with Cross-Thread errors..
What i've done:
My Dll
Public Class NoctrisClient
Public Event ClientConnected()
Public Delegate Sub SimpleCallBack()
Public isConnected as boolean = false
Private endpoint as new IPEndPoint(system.net.dns.GetHostEntry("my.server.com").addresslist(0),1234)
Private SocketClient as Socket
Public Sub New()
me.connect()
End sub
Public sub Connect()
ClientSocket = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
ClientSocket.BeginConnect(endpoint, AddressOf Connected, Nothing)
end sub
Private Sub Connected(ByVal ar As IAsyncResult)
Try
ClientSocket.EndConnect(ar)
'-- Ok, we are connected
EventClientConnected()
'-- Start Receiving Data
ClientSocket.BeginReceive(RecvBuffer, 0, RecvBuffer.Length, _
SocketFlags.None, AddressOf ReceivedData, Nothing)
Catch ex As Exception
'-- Call DisconnectedUI
' Make call to raise ClientDisconnectedEvent
' EventClientDisconnected()
End Try
End Sub
'... and so on.. all code from the socketclient is ok..it worked before so...
Private Sub RaiseClientConnected()
RaiseEvent ClientConnected()
isConnected = True
End Sub
Private Sub EventClientConnected()
' Doing this here because i call these events on several places and did not wanted to keep repeating code.
Dim cb As New SimpleCallback(AddressOf RaiseClientConnected)
cb.Invoke()
End Sub
end class
So this, in a VERY short nutshell, is the socketclient component..
So far, so good.. the events are raised as they should... But ...
Then the form does something like this:
imports my.namepace.NoctrisClient
Public Class Myform
Private WithEvents Client as new NoctrisClient
Private Delegate Sub SimpleCallBack()
Private Sub HandleClientConnected() Handles Client.ClientConnected
Dim cb As New SimpleCallBack(AddressOf ConnectedUi)
cb.Invoke()
End Sub
Public Sub ConnectedUi()
Try
LblServerStatus.Text = "Connected"
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
end class
So as you can see, in my form HandleClientConnected handles the event from the dll and does a callback to ConnectedUi to change the control(s) on the form..
However, I keep getting Cross-thread exceptions:
System.InvalidOperationException: Cross-thread operation not valid: Control 'LblServerStatus' accessed from a thread other than the thread it was created on.
at System.Windows.Forms.Control.get_Handle()
at System.Windows.Forms.Control.set_WindowText(String value)
at System.Windows.Forms.Control.set_Text(String value)
at System.Windows.Forms.Label.set_Text(String value)
at tp2player.FrmStandardPlayer.ConnectedUi() in D:\Development\solution\project\Forms\MyForm.vb:line 35
I've been reading a lot about it ( ok.. i admit, i don't always understand the articles either )
but i just can't see where i am going wrong ?
I've tryed different ways for callback and direct but they all keep ging errors :s (only messagebox, which doesn't care about threads anyways, works..)
Could someone please shine a little light on it ?
Many thanks !
|
|
|
|
|
controls are only available on the main thread(where all presentation takes place). since you are on a different thread it complains when you try to use something on the main thread without getting on that thread. you need to use the INVOKE command of the control that will place the assignment of the text property on the main thread. to do this, you will need to use a DELEGATE which will need the same signature that the routine has that will contain the invoke call...
this idea is like this
define the delegate
in your routine change to this
Public Sub ConnectedUi()
if LblServerStatus.InvokeRequired Then
LblServerStatus.Invoke(....) 'new instance of the delegate pointing to this routine
Exit Sub
End If
LblServerStatus.Text = "Connected"
End Sub
'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous
'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous
|
|
|
|
|
I have problems to show images in a datagrid. I was looking for some answer and I found that if I use this code it should be work.
Dim Comm As New OleDbCommand(QPhoto, con.Con)
Conexion.Open()
Dim OledbRead As OleDbDataReader
OledbRead = Comm.ExecuteReader(CommandBehavior.CloseConnection)
Do While (OledbRead.Read)
Response.ContentType = OledbRead.Item("IDArti")
Response.BinaryWrite(OledbRead.Item("Image"))
Loop
con.Con.Close()
But, unfortunatelly it doesn't work. When I try to run this code, it asks me if I want to open or save and the both options don't do anything.
Could you help me?
I have the images in Access database and I want to display them in the datagrid with the information of each row
Please, help me I'm stressed out
|
|
|
|
|
Well, this is ASP.NET code. And it's never going to work, no. Nor could it hope to. Perhaps you need to ask in the right forums, and understand the code you're using.
A HTTP Handler to stream images is what you need.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi,
I am trying to create the shortcut menu for MS Access application. I am sucessful in creating shortcut menu for all options other than "Filter For" menu option (right click).
Could you please help me how to get this option.
Thanks
KP
|
|
|
|
|
Hello ,
I am using this code to send an E-mail from a Gmail account :
Dim SmtpServer As New SmtpClient()
SmtpServer.Credentials = New Net.NetworkCredential("xxx@gmail.com", "password")
'SmtpServer.Credentials = New Net.w
SmtpServer.Port = 587
SmtpServer.Host = "smtp.gmail.com"
SmtpServer.EnableSsl = True
mail = New MailMessage()
Dim addr() As String = TextBox1.Text.Split(",")
Try
mail.From = New MailAddress("bankersystem@gmail.com", "Web Developers", System.Text.Encoding.UTF8)
Dim i As Byte
For i = 0 To addr.Length - 1
mail.To.Add(addr(i))
Next
mail.Subject = TextBox3.Text
mail.Body = TextBox4.Text
If ListBox1.Items.Count <> 0 Then
For i = 0 To ListBox1.Items.Count - 1
mail.Attachments.Add(New Attachment(ListBox1.Items.Item(i)))
Next
End If
mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure
mail.ReplyTo = New MailAddress(TextBox1.Text)
SmtpServer.Send(mail)
Catch ex As Exception
MsgBox(ex.ToString())
End Try
When I use the broadband connection at home , all work fine . However when I use the wireless connection at uni , It gives me always an error that it cannot connect to host and cant send the message !!!
Any idea ?!
J ,
|
|
|
|
|
Hi,
When you say it works at home? Alarm bell should be ringing here! if it works what are you doing differently at uni, i.e. are you using a wired connection at home and a wireless connection at uni etc...
Many uni's have proxy servers and this could also be an issue - you need to take the uni out of the equation try it on a different wireless network and eliminate the problem down.
To test your code try and a do a simple web request i.e get the html or a website,you can get the code off google, if it this in both places then this tells you you can acces the web your uni's proxy if not then its got to be your code, and you may have to pass up them credentials also.
Andy
|
|
|
|
|
Hy ,
At uni it is wireless connection and at home the connection is wired !! I mentioned that befor in the first messaged i posted !
Thx for the help Andy .
J ,
|
|
|
|
|
I use Vb 2005. I haven't experience in this technology so I don't know how can I reference a C sharp Class - NavigationPane - from my project in vb net.
Thanks!
|
|
|
|
|
You can put it in a dll and reuse it from there.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi
I am facing problem while using windows API in VB.net 2005.
This is the code i am using.
<br />
Private Structure WSADATA<br />
Dim wVersion As Short<br />
Dim wHighVersion As Short<br />
<vbfixedarray(wsadescription_len)> Dim szDescription() As Byte<br />
<vbfixedarray(wsasys_status_len)> Dim szSystemStatus() As Byte<br />
Dim iMaxSockets As Short<br />
Dim iMaxUdpDg As Short<br />
Dim lpszVendorInfo As Integer<br />
<br />
Public Sub Initialize()<br />
ReDim szDescription(WSADescription_Len)<br />
ReDim szSystemStatus(WSASYS_Status_Len)<br />
End Sub<br />
End Structure<br />
<br />
Private Const WS_VERSION_REQD As Short = &H101S<br />
<br />
Dim WSAD As New WSADATA<br />
Dim iReturn As Short<br />
iReturn = WSAStartup(WS_VERSION_REQD, WSAD)------>This statement is returning an error saying that<br />
<br />
"System.AccessViolationException was unhandled<br />
Message="Attempted to read or write protected memory. This is often an indication that other memory is corrupt.""<br />
</vbfixedarray(wsasys_status_len)></vbfixedarray(wsadescription_len)>
Please give the suggestions .
Thanks ,
Chaitanya
|
|
|
|
|
Hi
i have populated data to treeview from sql so i want display information on the list box about certain childnodes e.g(product id ,product price)when ever a node is selected from treeview.
Mamphekgo
|
|
|
|
|
Sorry, what is the question? You probably have all the info you need in the node/children.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
You should use the code on AfterCheck of Treeview.
Cheers
Anubhava Dimri
anubhava.prodata@gmail.com
925016195
|
|
|
|
|
how do i create my own real media player on vb6 and if possible the media player should also play avi and mp3 formats too (an all in player). Is there a tutorial that can tell me how to make the player.
|
|
|
|
|
Bad Spinky !
No yelling, we are not blind.
Using vb6 when you don't have to is bad, no supper for you tonight.
First download a newer programming tool, for example from here: http://www.microsoft.com/express/default.aspx[^] and learn about .net
To answer your question: you could use google to find programming tutorials, but it is very unlikely that you'll find one that will teach you exactly what you want.
You'll probably have better luck breaking down the idea of a mediaplayer into functionality-parts:
(find media files, how to determine which file is video, and which is music, etc, etc). On such smaller functionalities you are more likely to find tutorials, articles and/or examples. At least you should be able to find tutorials or examples that show similar processes, which you can then adapt to your needs.
Good luck with your project,
Johan
My advice is free, and you may get what you paid for.
|
|
|
|
|
Johan Hakkesteegt wrote: Bad Spinky !
gold
|
|
|
|
|
1. TURN CAPS LOCK off
2. I suggest using .NET - the express versions are free
3. Try Google, you will probably get some guidelines if you look for individual bits like how to play an mp3, how to play an avi etc
4. Good Luck
Bob
Ashfield Consultants Ltd
|
|
|
|
|
VB6 is rubbish. It's also a dead language.
You can only create your own media player in C++. Or, you can just import a media player control and pretend you wrote a media player, I suspect that's what you really want to do.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Christian Graus wrote: You can only create your own media player in C++.
Why not in C#?
|
|
|
|
|
I am using vb.net 2005 with Crystal reports version 10.
I get this problem when I try and load my application on a users PC. Works great with me but I have a problem in a user's PC.
Any ideas?
"Could not load file or assembly 'CrystalDecisions.Shared,
Version=10.2.3600.0, Culture=neutral, PublicKeyToken=692fbea5521e1304' or one
of its dependencies. "
|
|
|
|
|
IS_Assessor wrote: I am using vb.net 2005 with Crystal reports version 10.
I get this problem when I try and load my application on a users PC. Works great with me but I have a problem in a user's PC.
Any ideas?
"Could not load file or assembly 'CrystalDecisions.Shared,
Version=10.2.3600.0, Culture=neutral, PublicKeyToken=692fbea5521e1304' or one
of its dependencies. "
Does your project setup on the user's PC contain the Crystal distribution files?
|
|
|
|
|
In my references I have,
CrystalDecisions.CrystalReports.engine
CrystalDecisions.ReportSources
CrystalDecisions.Windows.Forms
On the installation setup I have
Crystal_Database_Access2003.msm
Crystal_Database_Access2003_enu.msm
Crystal_Managed2003
Crystal_regwiz2003
On the user's PC they have no Crystal report references.
I hope this is helpfull.
|
|
|
|
|
The Business Objects site will have a list of runtime distribution requirements for Crystal Reports.
|
|
|
|