Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Option Explicit
- Public Sub OpenBrowserWindowByFilterAndClass( _
- ByRef oFilter As LDE.Filter, _
- ByVal sClassName As String, _
- ByVal sBrowserName As String, _
- ByVal sExplorerName As String, _
- ByVal bIncludeExistingFilters As Boolean _
- )
- On Error GoTo ErrorHandler
- Dim oClass As LDE.Class
- Dim oBrowser As Lime.Browser
- Dim oNewExplorer As Lime.Explorer
- Dim oNewExplorerRecords As LDE.Records
- Dim oNewExplorerSettings As LDE.Settings
- Dim PageSize As Long
- ' We will open an explorer containing companies in our new browser
- Set oClass = Application.Database.Classes.Item(sClassName)
- If Not oClass Is Nothing Then
- PageSize = Application.Settings.Read("Application\Explorer\PageSize", 0)
- Set oNewExplorerRecords = New LDE.Records
- Call oNewExplorerRecords.Open(oClass, , , PageSize)
- ' Create the browser
- Set oBrowser = New Lime.Browser
- oBrowser.Caption = VBA.IIf(sBrowserName = "", oClass.LocalName, sBrowserName)
- ' Get settings for the explorer type we will create
- Set oNewExplorerSettings = oBrowser.Explorers.Settings.Item(oClass.GUID)
- ' Create the new explorer and assign it settings, records and name. All
- ' these attributes are required by the explorer
- Set oNewExplorer = New Lime.Explorer
- Set oNewExplorer.Settings = oNewExplorerSettings
- Set oNewExplorer.Records = oNewExplorerRecords
- oNewExplorer.Name = VBA.IIf(sExplorerName = "", oClass.LocalName, sExplorerName)
- ' Set filter and view as well. Use the ones associated with the
- ' explorer's class
- If bIncludeExistingFilters Then
- Set oNewExplorer.Filters = oClass.Filters
- Else
- Set oNewExplorer.Filters = New LDE.Filters
- End If
- Call oNewExplorer.Filters.Add(oFilter)
- Set oNewExplorer.Views = oClass.Views
- ' Make sure it's visible
- Call oNewExplorerSettings.Write("Visible", 1)
- ' Put the explorer in search mode
- Call oNewExplorerSettings.Write("SearchMode", 0)
- 'Set oNewExplorer.ActiveFilter = oFilter
- ' Add the explorer to the browser
- Call oBrowser.Explorers.Add(oNewExplorer)
- ' Display it
- Call oBrowser.show
- Set oBrowser.ActiveExplorer.ActiveFilter = oFilter
- End If
- Exit Sub
- ErrorHandler:
- Call UI.ShowError("BrowserHelper.OpenBrowserWindowByFilterAndClass")
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement