How i came into .Net?
Hi all, this is my first technology blog and my first post i would like to share my knowledge gathered in .Net technology through this blog.
While drafting this first post i had couple of questions to myself ‘How did I came into this technology?’, ‘How did I got addicted to this technology?’
I could still remember the classic Microsoft Software development package VBA(VB6.0) which I studied and got used in my school days is the stating place.
I started developing small application in VBA like simple calculator, Notepad, Custom web browser, bill payments, payroll management etc. and more small applications which later driven me to this great platform called .Net.
I believe still VBA is widely used and developers exists working on VBA:)
Even I too got a recent requirement which I have to accomplish in VBA. WOW I am back to you VBA.
But the requirement was little crazy, do let me explain.
I am happy to start my post on VBA.
OPEN URL IN SAME IE INSTANCE IN VBA
Develop a VB6.0 .dll which has class modules with Custom events on implementing an interface from a referred third party .dll.
Assume one of the event is OnMenu_Click(),which has my custom code to handle specific customization on a Menu clicked from third party application.
There can be as many class modules to the count of menus in third-party application.
When a menu is clicked the applications has to open a Pop-up Internet Explorer Browser and navigate to a specific URl assigned for the menu.
Application has to maintain the same IE instance for all the fore coming menu clicks and navigate new URLs instead of opening new IE instance.
I Used SHDocVw.InternetExplorer WebBrowserObject
Since I was using Modules,Class Modules I was not able to have the WithEvents and capture the OnQuit(),Since WithEvents can be applicable only for Object Modules,Finally I decided to handle it programically as below.
Hope this would help someone met with same scenario.
Private objIEWindow As SHDocVw.InternetExplorer
--------------------------------------------------------------
Public Sub LaunchURLinSameIE(ByVal szURLtoLaunch As String)
Dim browserFlag As Boolean
browserFlag = True
If objIEWindow Is Nothing Then 'Create a new IE instance for the first time
Set objIEWindow = New SHDocVw.InternetExplorer
'MsgBox ("first")
objIEWindow.navigate szURLtoLaunch, , ""
objIEWindow.AddressBar = False
objIEWindow.MenuBar = False
' objIEWindow.StatusBar = False
objIEWindow.ToolBar = False
objIEWindow.Visible = True
Else
Dim ShellApp
Set ShellApp = CreateObject("Shell.Application")
Dim ShellWindows
Set ShellWindows = ShellApp.Windows()
Dim i
For i = 0 To ShellWindows.Count - 1'Loop through shell window to ensure if the IE instance is available
If Not ShellWindows.Item(i) Is Nothing Then
If InStr(UCase(ShellWindows.Item(i).FullName), UCase("iexplore.exe")) <> 0 Then
'MsgBox ("is ie")
Set objIEWindow = ShellWindows.Item(i)
If objIEWindow.AddressBar = False And objIEWindow.MenuBar = False And objIEWindow.ToolBar = False Then
browserFlag = False
GoTo SameBrowserInstance:
Else
browserFlag = True
End If
Else
browserFlag = True
End If
End If
Next
If browserFlag = True Then
Set objIEWindow = New SHDocVw.InternetExplorer
'MsgBox ("second")
objIEWindow.navigate szURLtoLaunch, , ""
objIEWindow.AddressBar = False
objIEWindow.MenuBar = False
' objIEWindow.StatusBar = False
objIEWindow.ToolBar = False
objIEWindow.Visible = True
Else
SameBrowserInstance:
'MsgBox ("third")
objIEWindow.Navigate2 (szURLtoLaunch)
End If
End If
End Sub
No comments:
Post a Comment