Link to home
Start Free TrialLog in
Avatar of AJAY CHADHA
AJAY CHADHAFlag for India

asked on

Get IE Address bar URL before the DNS is resolved

Is it possible in VB to Get IE Address bar URL before the DNS is actualy resolved. I mean to say to get the url of address bar as soon as the url is entered and the enter key is pressed or GO button is clicked.

Thanks for your comments..!

Ajay Chadha
Avatar of priya_pbk
priya_pbk

How are you doing this in Vb, i mean you are opening an IE or you are having a web browser on the form.

Could you elaborate...or tell us what your application is doing?

-priya
Avatar of Ryan Chong
See this example by Ark if it's help:

Receive Events from and Send Events to Open IE Windows:
http://www.freevbcode.com/ShowCode.Asp?ID=1606
Avatar of AJAY CHADHA

ASKER

Hello ryancys,

Yes, That code has exactly what I'm looking for but I hope you will agree on this issue that the part I'm looking for is

Private Sub IEWin_IENavigationBegin(hwnd As Long, ByVal pDisp As Object, URL As Variant, Flags As Variant, TargetFrameName As Variant, PostData As Variant, Headers As Variant, Cancel As Boolean)

Could you pls look into the code and create a simpler version out of it because i don't want to use all that code for just a single purpose.

Thanks for your comments.

Ajay Chadha
Will look through the code tonight, cheers.
Thanks man, I'll wait for your precious comments.

Ajay Chadha ... :-)
Hi ryancys,

Did you found some spare time to have a look at the code..?

Ajay Chadha
ASKER CERTIFIED SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hello Ryansys,

I'm sorry but I was looking for the IE_DownloadComplete event and your code doesn't have it.

Well, to make it more simple. I'm looking for a code which will add the IE url to the a listbox (not listview) as soon as it is typed and this can be done in IE_DownloadComplete event.

Thanks and Will wait for your reply..!

Ajay Chadha
Also, I'm gettign the 429 error "ActiveX Component can't create object" on the following line

Dim eIEShellWindow As New SHDocVw.ShellWindows

Ajay Chadha
Are you there ryansys..?
Sorry for the delay Chadhaajay.

> "ActiveX Component can't create object" on the following line

Dim eIEShellWindow As New SHDocVw.ShellWindows

We need to add the M$ HTML Object Library from the Reference.

and

> Well, to make it more simple. I'm looking for a code which will add the IE url to the a listbox (not listview) as soon as it is typed and this can be done in IE_DownloadComplete event.

So is that means Add an item to ListBox after the IE_DownloadComplete event fired? Anyway, i will try figure it..

* I'm now only will be available online 3 times a week (typically Mon,Wed & Fri in my timezone, +8 hours), so you'll not able to see me tomorrow.. Sorry about that.

regards,
ryancys
I need to add the url from address bar to listbox as soon as the IE_BeforeNaviage option is fired

Thanks..!!

Ajay Chadha
Sorry, but it should add the url to list box at this event
IENavigationBegin

Ajay Chadha
Dear chadhaajay,
I think this should be the simplest one!
This time i use the Timer to keep trick the URL from the IE Windows. (Don't know whether you like to use Timer or not, but since using Timer, we don't need IENavigationBegin event already..). Hope this will finally solve your problem.

regards,
ryancys

Private Const HWND_TOPMOST = -1
Private Const HWND_NOTOPMOST = -2
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Declare Function GetDesktopWindow Lib "user32" () As Long

Dim i As Long, j As Long

Private Sub UpdateIEList()
    Dim eIEShellWindow As New SHDocVw.ShellWindows
    Dim eIE As SHDocVw.InternetExplorer
    List1.Clear
    i = 0
    For Each eIE In eIEShellWindow
        List1.AddItem "" & eIE.LocationURL, i
        'Save the Handle for futher use if needed
        List1.ItemData(i) = eIE.hwnd
        i = i + 1
        DoEvents
    Next
End Sub

Private Sub Command1_Click()
    Timer1.Enabled = True
End Sub

Private Sub Command2_Click()
    Timer1.Enabled = False
End Sub

Private Sub Form_Activate()
    UpdateIEList
End Sub

Private Sub Form_Load()
    StayOnTop Me, True
    Timer1.Interval = 1000 '10 ?
    Timer1.Enabled = False
    Command1.Caption = "Monitoring"
    Command1.Caption = "Stop Monitoring"
End Sub

Private Sub List1_Click()
    On Error Resume Next
    Label1.Caption = "Window Handle: " & List1.ItemData(List1.ListIndex)
End Sub

Private Sub Timer1_Timer()
    UpdateIEList
End Sub

Private Sub StayOnTop(frm As Form, fOnTop As Boolean)
    Dim lState As Long
    Dim iLeft As Integer, iTop As Integer, iWidth As Integer, iHeight As Integer
    With frm
        iLeft = .Left / Screen.TwipsPerPixelX
        iTop = .Top / Screen.TwipsPerPixelY
        iWidth = .Width / Screen.TwipsPerPixelX
        iHeight = .Height / Screen.TwipsPerPixelY
    End With
    If fOnTop Then
        lState = HWND_TOPMOST
    Else
        lState = HWND_NOTOPMOST
    End If
    Call SetWindowPos(frm.hwnd, lState, iLeft, iTop, iWidth, iHeight, 0)
End Sub
Hello Ryansys,

you are still not on my point. I was talking to get the url as soon as it is typed in address bar text box, but yours is not the one i asked for.

I want to have the url added to the listbox as soon as it is typed in adress bar and enter key is pressed.

I don't expected the coe above. I need the modification to Ark's Code..!

Will you pls look in that code and specially at the IEBeforeNavigate event

Ajay Chadha
So the code posted on 06/27/2002 11:34PM PST is not working too? But i think you can customize the code yourself, isn't it?..
if you can figure ot out. I tried to do it but its too messy code to get something out of it
That's the problem, i face some difficulties to remove unused code from Ark's sample. So, that's why i only can do what i can do :(
Hi chadhaajay,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept ryancys's comment(s) as an answer.

chadhaajay, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
Per recommendation, force-accepted.

Netminder
EE Admin