Semafoor
Gebruiker
- Lid geworden
- 29 aug 2007
- Berichten
- 129
Hallo,
Ik ben bezig met een applicatie te maken. Ik heb er een MRu aan toe gevoegd. Het enigste probleem is dat er wanneer je op een mru item klikt niks gebeurd.. tenminste.. Niet wat ik wil dat er gebeurt.
Dit is de code die ik gebruikt heb.
Ik dat als je op een mru item klikt label1.caption het woord krijgt. dim : lbl
en dat windowsmediaplayer1.url de url krijgt dim: player
Als je op een van de images klikt krijg je wel een mru item maar als je daar op klik stopt de player en krijgt label1 geen tekst.
Wat doe ik fout of is er een betere manier?
Met vriendelijke groet
Stefan
Ik ben bezig met een applicatie te maken. Ik heb er een MRu aan toe gevoegd. Het enigste probleem is dat er wanneer je op een mru item klikt niks gebeurd.. tenminste.. Niet wat ik wil dat er gebeurt.
Dit is de code die ik gebruikt heb.
Ik dat als je op een mru item klikt label1.caption het woord krijgt. dim : lbl
en dat windowsmediaplayer1.url de url krijgt dim: player
Code:
Option Explicit
Private Const MaxMRU = 2 'Maximum number of MRUs in list (-1 for no limit)
Private Const NotFound = -1 'Indicates a duplicate entry was not found
Private Const NoMRUs = -1 'Indicates no MRUs are currently defined
Private MRUCount As Long 'Maintains a count of MRUs defined
Private Sub Form_Load()
' Initialize the count of MRUs
MRUCount = NoMRUs
' Call sub to retrieve the MRU filenames
GetMRUFileList
End Sub
Private Sub Form_Unload(Cancel As Integer)
' Call sub to save the MRU filenames
SaveMRUFileList
End Sub
Private Sub Image1_Click()
Dim player As String
Dim lbl As String
Label1.Caption = "3fm"
player = WindowsMediaPlayer1.URL
lbl = Label1.Caption
WindowsMediaPlayer1.URL = "http://switch.streamgate.nl/cgi-bin/streamswitch?streamid=46&a=.asx"
AddMRUItem lbl & " - " & player
End Sub
Private Sub Image2_Click()
Dim player As String
Dim lbl As String
Label1.Caption = "538 40"
player = WindowsMediaPlayer1.URL
lbl = Label1.Caption
WindowsMediaPlayer1.URL = "http://www.klikradio.nl/asx/redirector.php?index=10"
AddMRUItem lbl & " - " & player
End Sub
Private Sub mnuMRU_Click(Index As Integer)
Dim player As String
Dim lbl As String
' Call sub to reorder the MRU list
ReorderMRUList mnuMRU(Index).Caption, CLng(Index)
WindowsMediaPlayer1.URL = player
Label1.Caption = lbl
End Sub
Private Sub mnuOpen_Click()
' Show the file open common dialog
Me.CommonDialog1.ShowOpen
' Call sub to add this file as an MRU
AddMRUItem Me.CommonDialog1.FileName
End Sub
Private Sub AddMRUItem(NewItem As String)
Dim result As Long
' Call sub to check for duplicates
result = CheckForDuplicateMRU(NewItem)
' Handle case if duplicate found
If result <> NotFound Then
' Call sub to reorder MRU list
ReorderMRUList NewItem, result
Else
' Call sub to add new item to MRU menu
AddMenuElement NewItem
End If
End Sub
Private Function CheckForDuplicateMRU(ByVal NewItem As String) As Long
Dim i As Long
' Uppercase newitem for string comparisons
NewItem = UCase$(NewItem)
' Check all existing MRUs for duplicate
For i = 0 To MRUCount
If UCase$(Me.mnuMRU(i).Caption) = NewItem Then
' Duplicate found, return the location of the duplicate
CheckForDuplicateMRU = i
' Stop searching
Exit Function
End If
Next i
' No duplicate found, so return -1
CheckForDuplicateMRU = -1
End Function
Private Sub mnuQuit_Click()
' Close the program
Unload Me
End Sub
Private Sub AddMenuElement(NewItem As String)
Dim i As Long
' Check that we will not exceed maximum MRUs
If (MRUCount < (MaxMRU - 1)) Or (MaxMRU = -1) Then
'Increment the menu count
MRUCount = MRUCount + 1
' Check if this is the first item
If MRUCount <> 0 Then
' Add a new element to the menu
Load mnuMRU(MRUCount)
End If
' Make new element visible
mnuMRU(MRUCount).Visible = True
End If
' Shift items to maintain most recent to least recent
For i = (MRUCount) To 1 Step -1
' Set the captions
mnuMRU(i).Caption = mnuMRU(i - 1).Caption
Next i
' Set caption for new item
mnuMRU(0).Caption = NewItem
End Sub
Private Sub ReorderMRUList(DuplicateMRU As String, DuplicateLocation As Long)
Dim i As Long
' Move entries previously "more recent" than the
' duplicate down one in the MRU list
For i = DuplicateLocation To 1 Step -1
mnuMRU(i).Caption = mnuMRU(i - 1).Caption
Next i
' Set caption of newitem
mnuMRU(0).Caption = DuplicateMRU
End Sub
Private Sub GetMRUFileList()
Dim i As Long 'Loop control variable
Dim result As String 'Name of MRU from registry
' Loop through all entries
Do
' Retrieve entry from registry
result = GetSetting(App.Title, "MRUFiles", Trim$(CStr(i)), "")
' Check if a value was returned
If result <> "" Then
' Call sub to additem to MRU list
AddMRUItem result
End If
' Increment counter
i = i + 1
Loop Until (result = "")
End Sub
Private Sub SaveMRUFileList()
Dim i As Long ' Loop control variable
' Loop through all MRU
For i = 0 To MRUCount
' Write MRU to registry with key as it's position in list
SaveSetting App.Title, "MRUFiles", Trim$(CStr(i)), mnuMRU(i).Caption
Next i
End Sub
Als je op een van de images klikt krijg je wel een mru item maar als je daar op klik stopt de player en krijgt label1 geen tekst.
Wat doe ik fout of is er een betere manier?
Met vriendelijke groet
Stefan
Laatst bewerkt: