|
developing user interface form that relies on playing sound files [.wav] after certain user input [users will be predominantly handicapped -blind]. How do I implement, invoke, insert or whatever the appropriate controls or code behind controls to allow me to do this? thanks so much for your replies: i.e user presses button, the code "on-click" then plays the audio file while other actions are being set...
teddy
|
|
|
|
|
There is a good c# article on this http://www.codeproject.com/cs/media/windowssoundevents.asp[^]
I recently took that article and created a VB.Net version. You will need a PlaySound class like this:
Imports System
Imports System.Runtime.InteropServices
Imports System.IO
Public Class WPlaySound
<DllImport("winmm.dll", EntryPoint:="PlaySound", CharSet:=CharSet.Auto)> _
Private Shared Function PlaySound(ByVal pszSound As String, _
ByVal hmod As Integer, ByVal falgs As Integer) As Integer
End Function
<DllImport("winmm.dll", EntryPoint:="PlaySound", CharSet:=CharSet.Auto)> _
Private Shared Function PlaySound(ByVal data() As Byte, _
ByVal hmod As Integer, ByVal falgs As Integer) As Integer
End Function
Public Enum SND
SND_SYNC = 0
SND_ASYNC = 1
SND_NODEFAULT = 2
SND_MEMORY = 4
SND_LOOP = 8
SND_NOSTOP = 16
SND_NOWAIT = 8192
SND_ALIAS = 65536
SND_ALIAS_ID = 1114112
SND_FILENAME = 131072
SND_RESOURCE = 262148
SND_PURGE = 64
SND_APPLICATION = 128
End Enum
Public Shared Sub PlaySound(ByVal fileName As String)
If File.Exists(fileName) Then
PlaySound(fileName, 0, CType((SND.SND_ASYNC Or SND.SND_FILENAME Or SND.SND_NOWAIT), Integer))
End If
End Sub
Public Shared Sub PlaySoundResource(ByVal resourceName As String)
Dim WavStrm As IO.Stream = _
Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream( _
GetType(WPlaySound), resourceName)
If WavStrm Is Nothing Then Return
'Load the .wav from the stream into the byte array
Dim ClickSound(CType(WavStrm.Length, Integer) + 1) As Byte
WavStrm.Read(ClickSound, 0, CType(WavStrm.Length, Integer) + 1)
PlaySound(ClickSound, 0, CType((SND.SND_ASYNC Or SND.SND_MEMORY Or SND.SND_NOWAIT), Integer))
End Sub
Public Shared Sub PlaySoundEvent(ByVal EventName As String)
PlaySound(EventName, 0, _
CType((SND.SND_ASYNC Or SND.SND_ALIAS Or SND.SND_NOWAIT Or SND.SND_NODEFAULT), Integer))
End Sub
End Class
Using this class you can call the PlaySound method in your Click event of each button to play the appropriate WAV file. I have embeded the WAV as a resource and used the PlaySoundResource method.
If you have knowledge, let others light their candles at it.
Margaret Fuller (1810 - 1850)
|
|
|
|
|
Hi guys,
I've been trying to figure a way to store and work with a set of data, and be able to save it to a file. As I'm quite new to vb.net, i'm looking for something that's not too complex.
I need to store data for multiple FTP sites, with information like servername, username, password, port. At the moment, i have a structure called ftpsites, with those said items. Then an array of type ftpsites.
I'm then sequentially on a line by line basis storing this information, and retrieving this info, looping through, on each loop adding 6 to an index. For instance,
<br />
For i = 0 to lines.count -1<br />
ftpsites(i).servername = my_data_array(i + 1)<br />
ftpsites(i).username = my_data_array(i + 2)<br />
.......<br />
i +=5<br />
Next<br />
Could anybody please suggest a better way of doing this, including storing the data? I am hoping to do all of this in a class, along with my other procedures.
Many thanks
Craig
|
|
|
|
|
The best way would be for you to use a class that uses a collection of objects but that may be too complex for you.
If you are happy with the way you are storing (in memory) the data at the moment (array of ftp sites) then I'd recommend you write a "saveasfile" function that basically loops through the array and writes its contents to a file using the streamwriter class.
You can then write the opposite function (read from a file) using the streamreader class.
Streamreader and streamwriter use plain text files so you will have to give some thought as to how you will organize the file itself (one line for all the info relating to each ftp site or multiple lines).
A little fancier than coming up with your own text file organization would be to use an ini file. There is a very easy to use ini file reader/writer for .Net freely available from http://www.mentalis.org/ . Yes, Ini files are old school but this reader will give you results within an hour or two without having to learn much.
|
|
|
|
|
Hi, just wondering if anybody knows how do download from multi hosts using the vb.net sockets.
I have created a class DLL and can download from one host. If i want to connect and download from another host I must disconnect first and reconnect to the new one. I want to get around the so I can download from multi hosts at the same time. My class DLL has events and I have no idea how to have it connect to multi hosts, so I can download multi files at the same time.
I have expermented with with object arrays and threading, but have had no luck as im fairly new to vb.net. I would appeaciate any insite into this.
Thanks in advance..
|
|
|
|
|
You would have to encapsulte your code into it's own class, then you can launch as many of copies of this class as you want, simultaneously.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi,
I am trying to install .Net Service Pack 1 .
My machine is having Windows Xp , .Net Framework 1.0 installed.
And when i run SP1 exe "NDP1.1sp1-KB867460-X86.exe" it gives me this error message,
"The upgrade patch cananot be installed by windows installer service because the program to be upgraded may be missing, or the upgrade patch may update a different version of the program. Verify that the program to be upgraded exists on your computer and that you have the correct upgrade patch."
I am not able to install it,Help needed,what could be the reason??
|
|
|
|
|
It looks like your trying to install SP1 for the .NET Framework 1.1, not 1.0.
The .NET Framework 1.1 is not a patch over the top of 1.0. They are two distinctly different version of the .NET Framework and have their own service pack versions.
The current service pack for the .NET Framework 1.0 is SP3 and can be found here[^].
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
i am creating pictureboxes with images on a panel at runtime & now i want to copy those pictureboxes to another panel in vb.net,how to do it.pls tell me the code for copying not moving them.thanks in advance
parag
|
|
|
|
|
Guys, I have this project that i've deployed and then i needed to do some changes to the code..no matter what, the code keeps ignoring any changes i've done and act as the deployed code!
HELP
|
|
|
|
|
How have you deployed your project?
What do you mean by code changes? You deploy compiled assemblies where you cannot change the code...
|
|
|
|
|
what i meant is, after the deployment, any changes to the original source code won't apply!
|
|
|
|
|
|
Well that's the weird thing, ANY changes to the original source won't apply..i re-compiled so many times but it keeps acting as the old code would!
It's like a fix code!
I don't get any compilation errors tho't
|
|
|
|
|
Are you sure you are using the correct binaries? I mean, the new assemblies do actually have the current date/time on them? The only thing I can think of is that you are getting the assemblies from an old directory, or you are looking in Debug or Release, when it is compiling to the other.
Have you tried deleting the bin directories in your project then getting it to rebuild the whole solution? That way at least you know that the files in the bin directories are new.
If it isn't any of the above, then I am not sure what it could be because I have never come across anything like this.
Do you want to know more?
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and Forums
|
|
|
|
|
also make sure that after u have compiled ur project u rightclick on ur setup project and select rebuild option.
if problem still exist try to remove the setup project from the projectlist and then add a new setup project.
Hope it will work.
Computer... Programming... What That
|
|
|
|
|
how to find the key ascii values of the buttons preseed in vb.net? THANKS
THANKS
|
|
|
|
|
use keypress or keydown event
if u want to get the code at form level don't forget to set the keypreview property of the form to true.
Computer... Programming... What That
|
|
|
|
|
I was wondering if there is a way to show animated Gifs in the program. If so what controll should i use to hold the Gif? Any help would be greatly accepted.
Thanks in Advanced
|
|
|
|
|
Im in the same problem, please help!
|
|
|
|
|
Hi.
I'm trying to play an .AVI file from a .dll, but the mmioInstallIOProcA fails.
It returns NULL (eg. error)
The code is:
In module:
<br />
Declare Function mmioInstallIOProcA Lib "winmm" _<br />
(ByVal fccIOProc_4 As String, ByVal pIOProc As Integer, ByVal dwFlags As Integer) As Integer<br />
<br />
Public Function AsAny(ByVal obj As Object) As IntPtr<br />
Dim MyGC As GCHandle = GCHandle.Alloc(obj, GCHandleType.Pinned)<br />
'get address of variable in pointer variable<br />
AsAny = MyGC.AddrOfPinnedObject()<br />
End Function<br />
<br />
Public Const MMIO_INSTALLPROC = &H10000 'mmioInstallIOProc: install MMIOProc <br />
Public Const MMIO_GLOBALPROC = &H10000000 'mmioInstallIOProc: install globally <br />
Public Const MEY = &H2059454D 'This is the value of "MEY " run through FOURCC <br />
<br />
<br />
In form:
<br />
<br />
Public Delegate Function IOProc(ByRef lpMMIOInfo As MMIOINFO, ByVal uMessage As Integer, ByVal lParam1 As Integer, ByVal lParam2 As Integer) As Integer<br />
<br />
Public Structure MMIOINFO<br />
Public dwFlags As Integer<br />
Public fccIOProc As Integer<br />
Public pIOProc As Integer<br />
Public wErrorRet As Integer<br />
Public htask As Integer<br />
Public cchBuffer As Integer<br />
Public pchBuffer As String<br />
Public pchNext As String<br />
Public pchEndRead As String<br />
Public pchEndWrite As String<br />
Public lBufOffset As Integer<br />
Public lDiskOffset As Integer<br />
Public adwInfo0 As Integer<br />
Public adwInfo1 As Integer<br />
Public adwInfo2 As Integer<br />
Public adwInfo3 As Integer<br />
Public adwInfo4 As Integer<br />
Public dwReserved1 As Integer<br />
Public dwReserved2 As Integer<br />
Public hmmio As Integer<br />
End Structure<br />
<br />
In function:
<br />
hInst = LoadLibrary("C:\test.dll")<br />
hRsrc = FindResource(hInst, "#101", "AVI")<br />
hGlobal = LoadResource(hInst, hRsrc)<br />
lpData = LockResource(hGlobal)<br />
fileSize = SizeofResource(hInst, hRsrc)<br />
<br />
Dim IODlgPro As IOProc<br />
IODlgPro = AddressOf myIOProc<br />
<br />
Dim res As Integer<br />
res = mmioInstallIOProcA(MEY, AsAny(IODlgPro).ToInt32, MMIO_INSTALLPROC + MMIO_GLOBALPROC)<br />
Error comes here.... returns 0
<br />
'Play the AVI file <br />
res = mciSendString("open AVI.MEY+ type avivideo alias AVI parent " & ParentHandle & " style child", 0&, 0&, 0&)<br />
DisplayError(res)<br />
<br />
res = mciSendString("play AVI", 0&, 0&, 0&)<br />
And ideers???
|
|
|
|
|
Never mind..... made it work.
But thanks anyway.
|
|
|
|
|
th error is when i run the project i get "An unhandled exception of type 'System.NullReferenceException' occurred in winpcap Wrapper test.exe
Additional information: Object reference not set to an instance of an object.
-----------------------------------------------------------------------------
Option Strict Off
Public Class Form1
Inherits System.Windows.Forms.Form
Private Declare Function getAdapterNames Lib _
"rvpacket.dll" (ByVal s As String) As Short
Private Declare Function openAdapter Lib _
"rvpacket.dll" (ByVal Adapter As String) As Short
Private Declare Function checkPacketQueue Lib _
"rvpacket.dll" (ByVal Adapter As String) As Short
Private Declare Function GetQueuedPacket Lib _
"rvpacket.dll" (ByVal s As String) As Short
Private Declare Sub closeAdapter Lib _
"rvpacket.dll" (ByVal Adapter As String)
Private Const SIMULTANEOUS_READS As Short = 10
Private Const MAX_ADAPTER_LEN As Short = 512
Private Const ADAPTER_DELIMITER As String = "|"
Private Const MAX_PACKET_SIZE As Short = 10000
Private Const ERR_SUCCESS As Short = 1
Private Const ERR_ADAPTER_ID As Short = 2
Private Const ERR_INVALID_HANDLE As Short = 3
Private Const ERR_INVALID_ADAPTER As Short = 4
Private Const ERR_ALLOCATE_PACKET As Short = 5
Public adapter As String
Private Sub btnstart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnstart.Click
Dim qid As Short
Dim packetbuffer As String
Dim adapters() As String
Dim opensuccess As Short
Dim PacketQueue As Short
Dim packetlen As Short
Dim rawadapterdetails As String
Dim posdefaultadapter As Short
rawadapterdetails = Space(MAX_ADAPTER_LEN)
getAdapterNames(rawadapterdetails)
posdefaultadapter = _
rawadapterdetails.IndexOf(adapter_delimiter)
adapter = rawadapterdetails.Substring(0, posdefaultadapter)
opensuccess = openAdapter(adapter)
If opensuccess <> err_success Then
MsgBox("Unable to start. Check wincap is installed")
Exit Sub
End If
Do
PacketQueue = checkPacketQueue(adapter)
For qid = 1 To PacketQueue
packetbuffer = Space(max_packet_size)
packetlen = GetQueuedPacket(packetbuffer)
packetbuffer = packetbuffer.Substring(0, packetlen)
tbpackets.Text = tbpackets.Text & Replace _
(packetbuffer, Chr(0), " ")
tbpackets.SelectionStart = Len(tbpackets.Text)
System.Windows.Forms.Application.DoEvents()
Next
System.Windows.Forms.Application.DoEvents()
Loop
End Sub
Private Sub btnstop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnstop.Click
closeAdapter(adapter)
End Sub
End Class
|
|
|
|
|
Without further information, like what library your using and a link to it, and what line the error occured on, it's difficult to tell what the problem is.
But, looking at you Declares, my first guess would be that your not passing parameters to all these functions correctly. Without the documentation on the library, it's impossible to tell.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
First thing is to go to
http://network.programming-in.net/downloads/rvpacket.zip
and download the file. file name is "rvpacket"
and then go to
http://winpcap.mirror .ethereal.co
and download "winpcap"
-----------------------------------------------------------------------------
the error is at line PacketQueue = checkPacketQueue(adapter)
im textbook programming this one and i don't have a Clue what I mean to say is in the book it told me to go to those two sites and download the DLLS that I would need to build and run this application I don't know what I have done wrong if you can please take a look and help if you can thank you
|
|
|
|
|