|
-
Dec 31st, 2005, 12:45 AM
#1
Thread Starter
Frenzied Member
Replacing ComboBox With ImageCombo!
In a WebBrowser project, I want to add those URLs in the address bar ImageCombo which the user types. Such URLs are saved in a text file so that they can be populated in the address bar when the browser starts next time. Also it has to be ensured that URLs that are already listed in the address bar shouldn't get listed again i.e. there shouldn't be any duplicates. This is how I tried it:
VB Code:
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As Any) As Long
'the [b]ImageCombo[/b] has an index of 0
Private Sub [b]imgCboURL_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)[/b]
If (KeyCode = vbKeyReturn) Then
'[u]Call cboURL_Click(0)[/u]
Call imgCboURL_Click(0)
End If
End Sub
Private Sub [b]imgCboURL_Click(Index As Integer)[/b]
'[u]Call AddToCombo(cboURL(0).Text, cboURL(0))[/u]
Call AddToCombo(imgCboURL(0).Text, imgCboURL(0))
End Sub
'[u]Private Sub AddToCombo(pstrComboItem As String, pCB As ComboBox)[/u]
Private Sub [b]AddToCombo(pstrComboItem As String, pCB As ImageCombo)[/b]
On Error Resume Next
Dim lngComboIndex As Long
Dim objNewComboItem As ComboItem
If (InStr(pstrComboItem, "http://") = 0) Then
'if the user hasn't typed http:// in the address bar, append it
pstrComboItem = "http://" & pstrComboItem
Else
'else leave the URL as it is
pstrComboItem = pstrComboItem
End If
lngComboIndex = SendMessage(pCB.hwnd, CB_FINDSTRING, -1, ByVal pstrComboItem)
If (lngComboIndex = -1) Then
Set objNewComboItem = pCB.ComboItems.Add(1, , pstrComboItem, 2)
[u]'pCB.AddItem pstrComboItem[/u]
Dim iFile As Integer
Dim FileName As String
iFile = FreeFile
FileName = App.Path & "\TypedURLs.txt"
Open FileName For Append As #iFile
Write #iFile, pstrComboItem
Close #iFile
End If
End Sub
Earlier I was using a ComboBox as the address bar. The changes I have made to the above-mentioned code when I replaced the ComboBox with the ImageCombo are the underlined commented lines (of course, plus the code to populate the ImageCombo).
The problem is the above code worked perfectly when I was using the ComboBox but the same isn't happening when I changed to the ImageCombo. Using the ImageCombo, URLs that are already listed in the ImageCombo address bar are getting listed again & again if such a URL is typed again by the user. I didn't face this problem when I was using the ComboBox.
Can someone please point out where am I erring?
Last edited by arpan_de; Jan 3rd, 2006 at 11:11 AM.
ARPAN
IF YOU HAVE AN APPLE & I HAVE AN APPLE AND WE EXCHANGE THE APPLES, THEN YOU & I WILL STILL HAVE ONE APPLE BUT IF YOU HAVE AN IDEA & I HAVE AN IDEA AND WE EXCHANGE OUR IDEAS, THEN EACH OF US WILL HAVE TWO IDEAS!
NOTHING IS IMPOSSIBLE IN THIS WORLD.....EVEN THE WORD IMPOSSIBLE SAYS I'M POSSIBLE!
PRACTICE MAKES A MAN PERFECT BUT NOBODY IS PERFECT; SO WHY PRACTICE?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|