I am writing a program to control iTunes using the iTunes COM Interface and VB.NET. I am trying to figure out how to update labels in my program with the new track information when the track changes in iTunes. I haven't been able to figure this out. When the track changes, how do I update my labels with that new information? My program doesn't seem to know that the track changed. I try to update the information, but the program doesn't seem to get the new track information from iTunes. What do I need to do? I am using this method to update the labels:
Private Sub UpdateLabels()
Label1.Text = "Current Track: " + track.Name
Label2.Text = "Current Artist: " + track.Artist
Label3.Text = "Length: " + track.Time
End Sub
I think the labels are technically being updated, but as I said before, I don't think the program is getting the new track information, so it doesn't appear that they changed. If I restart my program, it gets the new information and updates the label accordingly.
The documentation is here.
Related
I'm trying to get started with my first add-in for Autodesk Inventor, and of course, I'm starting from an existing sample to make this task easier for a newbie like me.
I have a decent command of VB.NET, but I cannot understand what's going on here.
In this link: https://drive.google.com/drive/folders/1rs2zVzf8Ib8iwd8JjCWZ-KQbWJUAqFyJ?usp=sharing
There are two ZIP files with VS2019 Solutions:
This_Sample_Works.zip - I used this as the baseline for my new project
This_Sample_Does_Not.zip
In both, there is this line of code:
dc.Show(New WindowWrapper(ThisApplication.MainFrameHWND))
But it only compiles in the project This_Sample_Works.zip - In the project within This_Sample_Does_Not.zip, I get the error in the image below.
Frankly, I'm not even asking someone to fix it for me. I just wanted to understand why it works in one project and not in another, despite the code being virtually the same.
What is bugging me is what piece of information/skills I currently don't have to understand what the compiler is telling me.
Public Function CreateChildDialog() As Long
CreateChildDialog = Nothing
Try
'Dim dc As Object
If Not dc Is Nothing Then
dc.Dispose()
dc = Nothing
End If
dc = New dockable_form(ThisApplication)
dc.Show(New WindowWrapper(ThisApplication.MainFrameHWND))
MsgBox("Handle ID:" & dc.Handle.ToInt64(), MsgBoxStyle.OkCancel, "Debug Info")
Return dc.Handle.ToInt64()
Catch ex As Exception
MsgBox("There is problem in CreateChildDialog" & vbCrLf & vbCrLf & ex.Message & vbCrLf & vbCrLf & ex.StackTrace & vbCrLf & vbCrLf & ex.ToString)
End Try
End Function
Any help is welcome - Thanks in advance!
In your project This_Sample_Does_Not the class dockable_form is a Control (the class inherits from System.Windows.Forms.UserControl).
In the reference project This_Sample_Works the class form_dockable is a Form (the class inherits from System.Windows.Forms.Form).
The two are very different types, though a Form can behave like a Control, the opposite is not true. A control will need a containing form.
Thus, the Control does not have a Parent that can be assigned when the method Show is called, it already has a parent.
From MSDN - Control.Show Method
Showing the control is equivalent to setting the Visible property to true. After the Show method is called, the Visible property returns a value of true until the Hide method is called.
Questions for your final preferred solution:
Do you really want to create a Control that is placed on another form? or
Do you want a Form that can be shown or popped up as required?
I start a small application from my main application using process.start. Here is an abstract of my code: (I removed all the error-checking just for clarity...)
Dim proc as New Process
Dim si As New ProcessStartInfo
si.FileName = "SourceMonitor.exe"
si.Arguments = "guid=" & GUID & " name=" & Name & " timeout=0"
si.UseShellExecute = True
si.CreateNoWindow = True
Proc.StartInfo = si
Proc.EnableRaisingEvents = True
AddHandler Proc.Exited, AddressOf procExitEventHandler
Proc.Start()
What happens is that the new app SourceMonitor will not show up in Task Manager - but I want it to. However, it Does show up as soon as the program that launched it (using process.start) exits. This seems odd to me!
I've tried setting UseShellExecute to False, and even tried a different approach using si (my ProcessStartInfo) to
WindowStyle = ProcessWindowStyle.Hidden
si.UseShellExecute = False 'this is required when using processWindowStyle.hidden
In every case the app does not show up in Task Manager until the main program exits.
Does anyone know of a way to make sure my app does show up in Task Manager? It helps when I need to diagnose a customer issue - because I need to see if the SourceMonitor is running.
Ok - found the "issue" - and it was rather obvious...
The second process is owned by the first. It doesn't show up in the list as an independent process, rather it shows up as a child of the main process. The Task Manager has a drop-down arrow on the main application.
v MainApplication
- SourceMonitor
Clicking the dropdown shows the SourceMonitor it shelled. If I stop the main application the SourceMonitor does become an independent app and then shows up on the regular list. This actually works better than I had hoped.
I have a program which loads data from text files contained in directories back into text boxes on the user interface.
What I want to achieve is:
if the user changes a text of one of the text boxes and then clicks an "Update" button, the old record and its holding directory should be deleted the new record, saved in a new directory.
The code I am using now is:
Dim dtl = New DirectoryInfo(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "Cake Orders\" & TextBox1.Text))
'Delete the culled record
Try
If Directory.Exists(dtl.FullName) Then
Dim oDirectory As New DirectoryInfo(dtl.FullName)
If oDirectory.GetFiles.Count > 0 Then
For Each oFile As FileInfo In oDirectory.GetFiles
oFile.Delete()
Next
End If
If oDirectory.GetDirectories.Count > 0 Then
For Each oDir As DirectoryInfo In oDirectory.GetDirectories
oDir.Delete(True)
Next
dtl.Delete()
End If
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
'Continue to save the updated record
The above code just saves the current data in a new directory (which is fine), but does not delete the original directory like I want it to; that is to say that my code is not executing the above delete routine.
How can I achieve my objective? I am using Visual Basic 2010 Express. Thank you.
What I would suggest is that you find a way to walk around your problem, to get your program to do what you want it to.
Granted, some may provide you with some more advanced, Einstein-esque codes that will do what you want and by all means, I would encourage you try them out. In the meantime, why not consider this approach?
During the cull event when you load data from the root directory, why not save the name of your sub-directory to a redundant textbox so that your delete routine can ‘see’ it and execute the delete routine before the rest of your code, which you say works fine, runs?
This is to say:
Dim dtl = New DirectoryInfo(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "Cake Orders\" & RedundantTextbox.Text))
Surely, you would not be charged with finding a cheeky way to avoid being eaten alive by software programming which sometimes can be a brain-eating dinosaur.
I'm using the sample app from microsoft here:
http://msdn.microsoft.com/en-us/library/hh394041(v=vs.92).aspx
as a starting point to develop an app that allows the user to record multiple videos in the app to a collection.
What is the best way to accomplish this? I noticed that the example uses a fileSink object to specify the capture source and file name in isolated storage.
Private Sub StartVideoRecording()
Try
' Connect fileSink to captureSource.
If captureSource.VideoCaptureDevice IsNot Nothing AndAlso captureSource.State = CaptureState.Started Then
captureSource.Stop()
' Connect the input and output of fileSink.
fileSink.CaptureSource = captureSource
fileSink.IsolatedStorageFileName = isoVideoFileName
End If
' Begin recording.
If captureSource.VideoCaptureDevice IsNot Nothing AndAlso captureSource.State = CaptureState.Stopped Then
captureSource.Start()
End If
' Set the button states and the message.
UpdateUI(ButtonState.Recording, "Recording...")
' If recording fails, display an error.
Catch e As Exception
Me.Dispatcher.BeginInvoke(Sub() txtDebug.Text = "ERROR: " & e.Message.ToString())
End Try
End Sub
How would I then query that collection and allow the user to select that video for viewing in a listview? Is there no way to specify a folder to keep the video files organized?
Just looking for some advice on best practices to get this done. I wanted to use a video chooser that would allow the user to choose a video from their photo roll, but Windows Phone doesn't currently allow this.....
Well, is there any need to use a folder? noone can browse the ISO storage, so I see no need for folders :).
Using that tutorial, two files are created: "CameraMovie.mp4" and "CameraMovie.mp4.jpg" (the jpg is at least created on my phone, use ISETool to see the content of the ISO storage).
To record multiple videos, you would have to rename the filename each time
private string isoVideoFileName = "CameraMovie.mp4";
// reset the name when the recording starts
isoVideoFileName = DateTime.Now.ToString("yyyy-MM-dd_HH_mm") + ".mp4";
just change that variable when you start recording.
At the end of each recording, add the name of the video to a list, and once a video is added, you save the list (also to the ISO storage).
While loading the app, you load the list from the ISO, use the jpg's to make video tiles (or w/e you wanna do with it ;))
Hope this will help you a little forward, if not you have found the solution yet.
note, im sorry for using C#, whereas you use VB. It is however that i dont know VB well enough to type it at will ;)
I have the following code:
Dim obj As New Access.Application
obj.OpenCurrentDatabase (CurrentProject.Path & "\Working.mdb")
obj.Run "Routine"
obj.CloseCurrentDatabase
Set obj = Nothing
The problem I'm experimenting is a pop-up that tells me Access can't set the focus on the other database. As you can see from the code, I want to run a Subroutine in another mdb. Any other way to achieve this will be appreciated.
I'm working with MS Access 2003.
This is an intermittent error. As this is production code that will be run only once a month, it's extremely difficult to reproduce, and I can't give you the exact text and number at this time. It is the second month this happened.
I suspect this may occur when someone is working with this or the other database.
The dataflow is to update all 'projects' once a month in one database and then make this information available in the other database.
Maybe, it's because of the first line in the 'Routines' code:
If vbNo = MsgBox("Do you want to update?", vbYesNo, "Update") Then
Exit Function
End If
I'll make another subroutine without the MsgBox.
I've been able to reproduce this behaviour. It happens when the focus has to shift to the called database, but the user sets the focus ([ALT]+[TAB]) on the first database. The 'solution' was to educate the user.
This is an intermittent error. As this is production code that will be run only once a month, it's extremely difficult to reproduce, and I can't give you the exact text and number at this time. It is the second month this happened.
I suspect this may occur when someone is working with this or the other database.
The dataflow is to update all 'projects' once a month in one database and then make this information available in the other database.
Maybe, it's because of the first line in the 'Routines' code:
If vbNo = MsgBox("Do you want to update?", vbYesNo, "Update") Then
Exit Function
End If
I'll make another subroutine without the MsgBox.
I've tried this in our development database and it works. This doesn't mean anything as the other code also workes fine in development.
I guess this error message is linked to the state of one of your databases. You are using here Jet connections and Access objects, and you might not be able, for multiple reasons (multi-user environment, unability to delete LDB Lock file, etc), to properly close your active database and open another one. So, according to me, the solution is to forget the Jet engine and to use another connexion to update the data in the "other" database.
When you say "The dataflow is to update all 'projects' once a month in one database and then make this information available in the other database", I assume that the role of your "Routine" is to update some data, either via SQL instructions or equivalent recordset updates.
Why don't you try to make the corresponding updates by opening a connexion to your other database and (1) send the corresponding SQL instructions or (2) opening recordset and making requested updates?
One idea would be for example:
Dim cn as ADODB.connexion,
qr as string,
rs as ADODB.recordset
'qr can be "Update Table_Blablabla Set ... Where ...
'rs can be "SELECT * From Table_Blablabla INNER JOIN Table_Blobloblo
set cn = New ADODB.connexion
cn.open
You can here send any SQL instruction (with command object and execute method)
or open and update any recordset linked to your other database, then
cn.close
This can also be done via an ODBC connexion (and DAO.recordsets), so you can choose your favorite objects.
If you would like another means of running the function, try the following:
Dim obj As New Access.Application
obj.OpenCurrentDatabase (CurrentProject.Path & "\Working.mdb")
obj.DoCmd.RunMacro "MyMacro"
obj.CloseCurrentDatabase
Set obj = Nothing
Where 'MyMacro' has an action of 'RunCode' with the Function name you would prefer to execute in Working.mdb
I've been able to reproduce the error in 'development'.
"This action cannot be completed because the other application is busy. Choose 'Switch To' to activate ...."
I really can't see the rest of the message, as it is blinking very fast. I guess this error is due to 'switching' between the two databases. I hope that, by educating the user, this will stop.
Philippe, your answer is, of course, correct. I'd have chosen that path if I hadn't developed the 'routine' beforehand.
"I've been able to reproduce this behaviour. It happens when the focus has to shift to the called database, but the user sets the focus ([ALT]+[TAB]) on the first database. The 'solution' was to educate the user." As it is impossible to prevent the user to switch application in Windows, I'd like to close the subject.