|
There's an older article on configuring XP as a kiosk machine[^]; might still have some good clues
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hello everyone! My name is Emmanuel and I'm new to programming. I designed a name dictionary with v6.0, where som1 can search 4 d meaning and origin of his name. Everytin is wrking fine. But when i make d project exe and try to run it in another system, it shows d database path is not a valid path but it will run fine in my system. Som1 out there shud hlp me plzzzzz. Tnx in adv.
|
|
|
|
|
Otekpo Emmanuel wrote: Som1 out there shud hlp me plzzzzz
This will almost certainly not happen as you are coding in a language that is DEAD , as Dave suggested get VB.Net express and start again.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I've a big interrogation concerning sound playback (WMP.lib)!
This code should play a sound, then compute...but it computes then play the sound!
Class MainWindow
Dim writingPath As String = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) & "\_UI Sounds\"
Dim uiPlayer As New WMPLib.WindowsMediaPlayer
Private Sub MainWindow_Loaded(sender As Object, e As System.Windows.RoutedEventArgs) Handles Me.Loaded
RunTest()
End Sub
Private Sub RunTest()
Debug.Print("Started!")
uiPlayer.URL = writingPath & "son1.wav"
uiPlayer.controls.play()
Dim a As Integer = 0
For i As Integer = 0 To 999999999
a = i
Next
Debug.Print("Done!")
End Sub
End Class
I thought that I perhaps should run the sound in a thread to be sure that it's played by its own!?
But this gives the same result
Imports System.Threading
Class MainWindow
Dim writingPath As String = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) & "\_UI Sounds\"
Dim uiPlayer As New WMPLib.WindowsMediaPlayer
Dim uiThread As Thread = New Thread(AddressOf PlayFile)
Private Sub MainWindow_Loaded(sender As Object, e As System.Windows.RoutedEventArgs) Handles Me.Loaded
RunTest()
End Sub
Private Sub RunTest()
uiThread = New Thread(AddressOf PlayFile)
uiThread.Start()
Debug.Print("Started!")
Dim a As Integer = 0
For i As Integer = 0 To 999999999
a = i
Next
Debug.Print("Done!")
End Sub
Private Sub PlayFile()
uiPlayer.URL = writingPath & "son1.wav"
uiPlayer.controls.play()
End Sub
End Class
How should I please proceed to hear my sound 'instantly'?
What's my mistake?
Thanks for your help!!
|
|
|
|
|
You've moved the wrong bit to the background thread.
Dim computeThread As Thread
Private Sub RunTest()
uiPlayer.URL = writingPath & "son1.wav"
uiPlayer.controls.play()
computeThread = new Thread(AddressOf Compute)
computeThread.Start()
End Sub
Private Sub Compute()
Debug.Print("Started!")
Dim a As Integer = 0
For i As Integer = 0 To 999999999
a = i
Next
Debug.Print("Done!")
End Sub
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
There are two possibilities to handle audio playing: one involves the message pump, the other one involves callback methods. I guess the WMPLib.WindowsMediaPlayer uses the message pump, and runs in the GUI thread of your application (as you explicitly call it uiPlayer). In that case, the messages can only be dealt with when the GUI of your apllication is ready to handle them.
You may test that hypotheses by adding an Application.DoEvents() to your for loop (do not do that for production code): playing should now be possible.
|
|
|
|
|
It doesn't work better.
Well, I had posted a simple code, hoping that it would be more clear for users to help me...but I'm afraid that I'd better post something very similar to my actual code..if I want the problem to be clearly exposed...and help you to try to help me
There's a sound class, called UISound:
Imports System.Threading
Public Class UISound
Dim writingPath As String = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) & "\_UI Sounds\"
Public Shared WithEvents uiPlayer As New WMPLib.WindowsMediaPlayer
Public Shared uiThread As Thread = New Thread(AddressOf ReceiveSound)
Public Shared Sub ReceiveSound(ByVal url As String)
uiThread = New Thread(AddressOf PlayFile)
uiThread.Start(url)
End Sub
Public Shared Sub PlayFile(ByVal url As String)
uiPlayer.URL = writingPath & url
uiPlayer.controls.play()
End Sub
End Class
The sound is called from a sub in the MainWindow...which itself fires other subs in cascade that involve a heavy compute time:
Sub one()
UISound.ReceiveSound("sound1.wav")
Dim a As Integer = 0
For i As Integer = 0 To 999999999
a = i
Next
Two()
End Sub
Sub two()
Dim a As Integer = 0
For i As Integer = 0 To 999999999
a = i
Next
Three()
End Sub
Sub Three()
Dim a As Integer = 0
For i As Integer = 0 To 999999999
a = i
Next
End Sub
It appears that the sound is played after the whole "cascade" is runned, so after Sub Three() End.
If you try this code you will verify that inserting
System.Windows.Forms.Application.DoEvents()
after uiPlayer.controls.play()...doesn't work better
Thanks for your help!!
|
|
|
|
|
I have posted similar question on StackOverflow[^]. I am unable to find the solution as yet
|
|
|
|
|
Please don't assume that CodeProject members are going to logon to SO just to read your question.
Veni, vidi, abiit domum
|
|
|
|
|
Right!
I pasted code here:
Code[^]
I get Invalid Object Array error on CopyObject line
|
|
|
|
|
Hi,
I have to get a directory file list, filtered on multiple extensions...and sorted!
I use this, which is the fastest way I've found to get dir content filtered on multiple extensions:
Dim ext As String() = {"*.jpg", "*.bmp","*png"}
Dim files As String() = ext.SelectMany(Function(f) Directory.GetFiles(romPath, f)).ToArray
Array.Sort(files)
and then use an array sort.
I was wondering (and this is my question ) if there would be a way to do the sorting IN the same main line? A kind of:
Dim files As String() = ext.SelectMany(Function(f) Directory.GetFiles(romPath, f)[B].Order By Name[/B]).ToArray
and, if yes, if I would gain speed doing this instead of sorting the array at the end (but I would do my test and report..as soon as I get a solution!!)?
Thanks for your help!!
|
|
|
|
|
Jayme65 wrote: if there would be a way to do the sorting IN the same main line? A kind of: You can combine methods on a line, but that makes it a compound statement; it still execute a statement at a time.
Getting a list and sorting are two distinctly different things.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Jayme65 wrote: ext.SelectMany(Function(f) Directory.GetFiles(romPath, f))
This part gets the list three times, and filters it three times. Next, you turn it into an array, and sort that. It'd (probably) be faster to get the list once and filter it. Since GetFiles already returns an array, there's no need to convert it.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I'd like to have charmap.exe open with the same font I'm using in my application's main window. But I've had no success passing arguments to it. I had assumed that:
Process.Start("charmap.exe", "Arial")
would get it done. But this has no effect. Suggestions?
XAlan Burkhart
|
|
|
|
|
That's because CharMap doesn't take any command line arguments.
AFAIK, the only way to open it at a specific font would be to launch it, make sure the window has the focus and then use SendKeys to send the font name, essentially typing it into the drop down list in CharMap.
|
|
|
|
|
I had considered this but was wanting to send arguments instead. But SendKeys works perfectly. Thanks much for the info.
XAlan Burkhart
|
|
|
|
|
Arguments only work when the target app is expecting them, and only if you use the switches it expects.
|
|
|
|
|
You can do this via the registry.
Dim CharMap_Key As RegistryKey = Registry.CurrentUser.OpenSubKey("Software\Microsoft\CharMap", writable:=True)
Dim currentfont As String = CStr(CharMap_Key.GetValue("Font", defaultValue:=""))
CharMap_Key.SetValue("Font", "Arial")
Dim proc As Process = Process.Start(Environment.SystemDirectory & "\charmap.exe")
|
|
|
|
|
In my case, charmap.exe already opens with "Arial" as the selected value - Of course, if you have a different font in your app you'll need to go the SendKeys-Way.
|
|
|
|
|
I build random character, plot, etc. generators for my fiction writing. I've learned the basics and have been trying to expand. Unable to get a Designer back to Design, I scrapped a major project that I couldn't continue. I than snagged part of the code that worked in that project, in the exact same way, but will not work in the new project. (I would also love to know how to get Designer back to Design as that's eaten multiple projects.)
I click a "Name" button on Form2. Form3 is a pop up with 4 checkbox and a "close" button. The "close button" works. The checkbox to random line selection to Form2 textbox does not work.
Male.txt (which is male names) is in the Debug folder. It has a lengthy name list.
In the original version, I clicked the box, it automatically generated a line from the file which appeared in the appropriate txtbox. In the new version, nothing happens.
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
If CheckBox1.CheckState = 1 Then
Male()
End If
End Sub
Sub Male()
Dim randomnum As New Random()
Dim RandomNumber As Integer
Dim lines = IO.File.ReadAllLines("Male.txt")
RandomNumber = randomnum.Next(0, UBound(lines))
Form2.TextBox1.Text = (lines(RandomNumber))
End Sub
End If
End Sub
|
|
|
|
|
Step through the code with your debugger, it will soon show you what is happening.
Veni, vidi, abiit domum
|
|
|
|
|
One thing you need to do is move the creation of the Random object to class-level. Just create it once and use it throughout your class as required.
Why? Because if you call this code in quick succession, the RNG is initialized with the current time, which can be exactly the same in quick successive calls, resulting in the same number being generated multiple times in a row.
|
|
|
|
|
There are no error messages. I try to "debug" and it simply doesn't work. There is no reason, that I can find, for it not working. I have resolved anything that showed up at the bottom errors/msgs/etc.
I did not understand the other message. I need it explained.
|
|
|
|
|
You're going to have to define "not working". What does it actually do?? Step through the code line by line and watch the variable contents.
As for moving the Random to class-level, it's easy. Oh, and you might want to break your click handler functionality down a bit into simpler methods:
Public MyForm
' This is declared at the class level.
Private RNG As New Random()
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
If CheckBox1.CheckState = 1 Then
Male()
End If
End Sub
' This code really should be in Form2, not in any other form.
' Form code should be responsible only for interacting with the controls
' on its own form, not with controls on another form.
Private Sub Male()
Dim lines() As String = GetLinesFromFile("male.txt")
Form2.TextBox1.Text = lines(RNG.Next(lines.Length))
End Sub
Private Function GetLinesFromFile(ByVal filename As String) As string()
return File.ReadAllLines(filename)
End Function
End Class
|
|
|
|
|
It does nothing. I click the box. The name (from the file) does not appear in the textbox.
If I'm suppose to be reading some line by line file, I don't know where that is.
I will try this.
The multiple forms are pop ups. The alternative is a much larger window that takes much more effort and results in the Designer window popping up and eating all my work (as I'm no longer able to work on a program when I've the Design view.) Hence my strategy change.
|
|
|
|