Community
Showing results for 
Search instead for 
Do you mean 
Reply

Custom TabPage disappears when

Copper Contributor
Posts: 12
Country: USA

Custom TabPage disappears when

[ Edited ]

I have a custom TabPage on a Contacts detail view that shows up fine.  After the TabPage has been initiated, though, if I run the Tools -> Design Layouts for any page, my custom TabPage disappears.

 

Also, if I change the database schema using ActFwk.Fields.Save(myField) or ActFwk.Fields.Delete(myField), the TabPage similarly is gone.

 

If I restart Act, the TabPage is back again.

 

How do I prevent my TabPage from disappearing in these circumstances?

Employee
Posts: 1,163
Country: USA

Re: Custom TabPage disappears when

I'd say that this is certainly not the desired behavior and I'll submit this to development. WIth that being said, opening the layout designer or saving the fields requires that the database be locked, after the database is unlocked you could re-add the tab back to the UI and then at least from the user perspective nothing has changed.

Matthew Wood
Act! SDK Support
Community Moderator
Copper Contributor
Posts: 12
Country: USA

Re: Custom TabPage disappears when

[ Edited ]

How do I get access to the database.unlocked event?  I need something like the following method for getting access to "AfterLogon", but for AfterUnlocked or some such:

 

 

 

Public Class Plugin

    Friend HostApplication As ActApplication 'Reference to the ACT! Application

    Friend Sub OnLoad(ByVal App As ActApplication) Implements IPlugin.OnLoad
        Me.HostApplication = App
        AddHandler HostApplication.AfterLogon, AddressOf HostApplicationAfterLogon
    End Sub 'OnLoad

    Private Sub HostApplicationAfterLogon(ByVal Sender As Object, ByVal e As System.EventArgs)
        MsgBox("HostApplicationAfterLogon fired")
    End Sub

End Class

 

Bronze Super Contributor
Posts: 1,231
Country: USA

Re: Custom TabPage disappears when

Try

 

  Friend Sub OnLoad(ByVal App As ActApplication) Implements IPlugin.OnLoad
        Me.HostApplication = App
        AddHandler HostApplication.AfterLogon, AddressOf HostApplicationAfterLogon

' Add Unlock
Addhanler HostApplication.Database.AfterDatabaseLock, AddressOf HostApplicationAfsterDatabaseLock End Sub 'OnLoad

 

  Friend Sub HostApplicationAfterdatabaseLock(ByVal sender as Object, databaseLockInformation as ACt.Framework.Database.DatabaseLockInformation)               
' Your code here
End Sub 'OnLoad

 

- Jim Durkin

Copper Contributor
Posts: 12
Country: USA

Re: Custom TabPage disappears when

[ Edited ]

Hi Jim,

 

Not working for me.  When I try to add this:

 

        AddHandler HostApplication.Database.AfterDatabaseLock, AddressOf HostApplicationAfterDatabaseLock

 I get the message "Database is not a member of Act.UI.Application."  When I change it to the following, there are no errors:

 

        AddHandler HostFramework.Database.AfterDatabaseLock, AddressOf HostApplicationAfterDatabaseLock

 Then, I add the sub as directed:

    Private Sub HostApplicationAfterDatabaseLock(ByVal Sender As Object, ByVal databaseLockInformation As Act.Framework.Database.DatabaseLockInformation)

        MsgBox("fired HostApplicationAfterDatabaseLock")

    End Sub

 No errors and it compiles.  But the msgbox is never fired when I run ACT!  The method does not seem to be firing.

 

By the way, adding this activity causes my plugin to be added to the DependentDlls.xml list.  There is no error while running (and no message regarding the DatabaseLock), but the plugin will not be started the next time I start ACT. 

 

Bronze Super Contributor
Posts: 1,231
Country: USA

Re: Custom TabPage disappears when

My Bad.

 

Add the new handler into the HostApplicationAfterLogon event.

 

This event is raised on all database lock and unlocks.  Your new routine will look like this:

 

    Private Sub AfterDatabaseLock(ByVal sender As Object, ByVal databaseLockInformation As Act.Framework.Database.DatabaseLockInformation)
      
        Select Case databaseLockInformation.LockType
            Case Act.Framework.DatabaseLockType.LOCK

            Case Act.Framework.DatabaseLockType.PENDING_LOCK

            Case Act.Framework.DatabaseLockType.UNLOCK
                ' UNLOCK!
                MessageBox.Show("Lock removed", "Durkin", MessageBoxButtons.OK, MessageBoxIcon.Information)

        End Select
    End Sub

 

Hope this helps

-- Jim Durkin

Copper Contributor
Posts: 12
Country: USA

Re: Custom TabPage disappears when

[ Edited ]

Jim,

 

It worked, thank you very much!  I see the message when I have an internal database.lock, unlock sequence going on.

 

Unfortunately, the AfterDatabaseLock sub does not get triggered when the Tools -> Design Layouts process is finished.  It seems that a database lock is not part of that process.  Whether the new layout is saved or not, the AfterDatabaseLock sub does not fire and my custom tab page goes away.

 

Is there some other event I might capture after a Layout has been redesigned?

 

I guess I need to know if the "current layout" has changed.

 

Alternatively, I could improve this sub:

 

    Private Sub AddTab()

        ' If MyTabPage is nothing, then this is the first time here
        ' We do not want to add MyTabPage each time the user navigates to the contact details view
        If MyTabPage Is Nothing Then
            ' First Time here
            MyTabPage = New TabPage
            MyTabPage.Text = "Call Trunk"
            Dim UserControl1 As UserControl1 = New UserControl1(Me.HostApplication)
            UserControl1.Dock = DockStyle.Fill
            MyTabPage.Controls.Add(UserControl1)
            HostApplication.UILayoutDesignerManager.AddTabToCurrentLayout(MyTabPage)

        End If

    End Sub

 

What is happening after a design change is that the MyTabPage is still "something" while it evidently is not part of the the CurrentLayout.  Perhaps I could check to see if MyTabPage is part of the CurrentLayout.

 

Bronze Super Contributor
Posts: 1,231
Country: USA

Re: Custom TabPage disappears when

Look at these

   

AddHandler HostApplication.ApplicationState.LayoutChanged, AddressOf ACTAppState_LayoutChanged

       

AddHandler HostApplication.ApplicationState.LayoutChanging, AddressOf ACTAppState_LayoutChanging

       

AddHandler HostApplication.ApplicationState.LayoutLoaded, AddressOf ACTAppState_LayoutLoaded

       

AddHandler HostApplication.ApplicationState.LayoutLoading, AddressOf ACTAppState_LayoutLoading

 

  Private Sub ACTAppState_LayoutLoaded(ByVal layoutFileInfo As Act.UI.LayoutDesigner.LayoutFileInfo)
        Select Case layoutFileInfo.layoutType
            Case LayoutDesigner.LayoutType.company

            Case LayoutDesigner.LayoutType.contact
                MessageBox.Show("Contact layout loaded", "Durkin", MessageBoxButtons.OK, MessageBoxIcon.Information)
            Case LayoutDesigner.LayoutType.group

            Case LayoutDesigner.LayoutType.opportunity

            Case LayoutDesigner.LayoutType.unknown

        End Select

    End Sub

 

 

-- Jim Durkin

Copper Contributor
Posts: 12
Country: USA

Re: Custom TabPage disappears when

[ Edited ]

Sweet, thanks.  My code ended up looking like this:

 

Private HostState As ActApplicationState

Friend Sub OnLoad(ByVal App As ActApplication) Implements IPlugin.OnLoad

	Me.HostState = App.ApplicationState
	AddHandler HostState.LayoutLoaded, AddressOf ACTAppState_LayoutLoaded

End Sub 'OnLoad

Private Sub ACTAppState_LayoutLoaded(ByVal layoutFileInfo As LayoutFileInfo)

	Select Case layoutFileInfo.layoutType
		Case LayoutDesigner.LayoutType.company

		Case LayoutDesigner.LayoutType.contact

			MyTabPage = Nothing
			If HostApplication.CurrentViewName = "Act.UI.IContactDetailView" Then
				Me.AddTab()
			End If

		Case LayoutDesigner.LayoutType.group

		Case LayoutDesigner.LayoutType.opportunity

		Case LayoutDesigner.LayoutType.unknown

	End Select

End Sub

Private Sub AddTab()

	If MyTabPage Is Nothing Then

		MyTabPage = New TabPage
		MyTabPage.Text = "Call Trunk"
		Dim UserControl1 As UserControl1 = New UserControl1(Me.HostApplication)
		UserControl1.Dock = DockStyle.Fill
		MyTabPage.Controls.Add(UserControl1)

		' remove any extra Call Trunk tabs, if they exist
		HostApplication.UILayoutDesignerManager.RefreshAvailableLayouts()
		' then add the new tab
		HostApplication.UILayoutDesignerManager.AddTabToCurrentLayout(MyTabPage)

	End If

End Sub

 

Tuned Listener
Posts: 44
Country: Canada

Re: Custom TabPage disappears when

Hello Jim, since you were able to help with his problem maybe you can help me with mine, the Act_Open event only runs when the shortcut or exe is used to open ACT!, when a .pad file is used to open up ACT! it does not run, i need an event that is similiar, an event that runs after everything is loaded, including the left nav bar, so far the only one i can find is the open event but like i mentioned it does not work all the time, do you know any other way to make this work?

 

Matt