Is Explorer.FolderSwitch the best event for hiding commandbarbutton?

  • Thread starter tneslony@gmail.com
  • Start date Views 1,624
Status
Not open for further replies.
T

tneslony@gmail.com

Greetings all,

I recently developed an outlook addin that adds a button to the

command bar. I need to hide this when not viewing emails. I took the

following strategy to do so:

Private Sub m_olExplorer_FolderSwitch()

Select Case m_olExplorer.CurrentFolder.Name

Case "Inbox"

objCommandBarButton.Visible = True

Case Else

objCommandBarButton.Visible = False

End Select

End Sub

The problem is that there is quite a bit of flicker (looks horrible).

The commandbar appears, then the Folderswitch event fires, then the

button is (re)enabled. It appears that everything else is occuring at

an earlier event... Any ideas?

-Tim
 
K

Ken Slovak - [MVP - Outlook]

Use Explorer.BeforeFolderSwitch().

<tneslony@gmail.com> wrote in message

news:2a534a55-d6dc-4de0-82e3-af4f793b29f6@z8g2000prd.googlegroups.com...
> Greetings all,

> I recently developed an outlook addin that adds a button to the
> command bar. I need to hide this when not viewing emails. I took the
> following strategy to do so:

> Private Sub m_olExplorer_FolderSwitch()
> Select Case m_olExplorer.CurrentFolder.Name
> Case "Inbox"
> objCommandBarButton.Visible = True
> Case Else
> objCommandBarButton.Visible = False
> End Select
> End Sub

> The problem is that there is quite a bit of flicker (looks horrible).
> The commandbar appears, then the Folderswitch event fires, then the
> button is (re)enabled. It appears that everything else is occuring at
> an earlier event... Any ideas?

> -Tim
 
T

tneslony@gmail.com

Re: Is Explorer.FolderSwitch the best event for hidingcommandbarbutton?

Hi Ken,

Thank you for your quick reply. I tried using the BeforeFolderSwitch

event, however I can't seem to figure out which folder will be

selected next. The m_olExplorer.CurrentFolder.Name returns (as one

would expect) the current folder.

Just to give you some background, I'm trying to hide or disable a

commandbarbutton when not viewing email (i.e. hide for calendar,

tasks, journal, etc...). Sorry if this a backwards method for

accomplishing this task. Can you suggest a better strategy?

PS: Thank you very much for sharing your VB6 template... It has made

learning Outlook programming a much more pleasant experience.

-Tim

On May 1, 11:12 am, "
<kenslo...@mvps.org> wrote:
> Use Explorer.BeforeFolderSwitch().

> >

> http://www.slovaktech.com

> <tnesl...@gmail.com> wrote in message

> news:2a534a55-d6dc-4de0-82e3-af4f793b29f6@z8g2000prd.googlegroups.com...
>
> > Greetings all,

>
> > I recently developed an outlook addin that adds a button to the
> > command bar.  I need to hide this when not viewing emails.  I took the
> > following strategy to do so:

>
> > Private Sub m_olExplorer_FolderSwitch()
> >    Select Case m_olExplorer.CurrentFolder.Name
> >        Case "Inbox"
> >            objCommandBarButton.Visible = True
> >        Case Else
> >            objCommandBarButton.Visible = False
> >    End Select
> > End Sub

>
> > The problem is that there is quite a bit of flicker (looks horrible).
> > The commandbar appears, then the Folderswitcheventfires, then the
> > button is (re)enabled. It appears that everything else is occuring at
> > an earlierevent...  Any ideas?

>
> > -Tim
 
T

tneslony@gmail.com

Re: Is Explorer.FolderSwitch the best event for hidingcommandbarbutton?

And sorry for the double post... Didn't realize that I'd already done

so. I appreciate your support.

-Tim

On May 1, 11:12 am, "
<kenslo...@mvps.org> wrote:
> Use Explorer.BeforeFolderSwitch().

> >

> http://www.slovaktech.com

> <tnesl...@gmail.com> wrote in message

> news:2a534a55-d6dc-4de0-82e3-af4f793b29f6@z8g2000prd.googlegroups.com...

>
> > Greetings all,

>
> > I recently developed an outlook addin that adds a button to the
> > command bar.  I need to hide this when not viewing emails.  I took the
> > following strategy to do so:

>
> > Private Sub m_olExplorer_FolderSwitch()
> >    Select Case m_olExplorer.CurrentFolder.Name
> >        Case "Inbox"
> >            objCommandBarButton.Visible = True
> >        Case Else
> >            objCommandBarButton.Visible = False
> >    End Select
> > End Sub

>
> > The problem is that there is quite a bit of flicker (looks horrible).
> > The commandbar appears, then the Folderswitch event fires, then the
> > button is (re)enabled. It appears that everything else is occuring at
> > an earlier event...  Any ideas?

>
> > -Tim-


 
K

Ken Slovak - [MVP - Outlook]

The VB6 signature of that event is:

BeforeFolderSwitch(NewFolder As Object, Cancel As Boolean)

NewFolder is the MAPIFolder that will be switched to, so just use that.

NewFolder.Name will return the name of the new folder.

If you set Cancel = True that will prevent the switch from occurring. If you

set it False or don't touch it at all the switch will occur.

<tneslony@gmail.com> wrote in message

news:f35ec698-52ad-4691-b414-7dae2de739fd@w31g2000prd.googlegroups.com...

Hi Ken,

Thank you for your quick reply. I tried using the BeforeFolderSwitch

event, however I can't seem to figure out which folder will be

selected next. The m_olExplorer.CurrentFolder.Name returns (as one

would expect) the current folder.

Just to give you some background, I'm trying to hide or disable a

commandbarbutton when not viewing email (i.e. hide for calendar,

tasks, journal, etc...). Sorry if this a backwards method for

accomplishing this task. Can you suggest a better strategy?

PS: Thank you very much for sharing your VB6 template... It has made

learning Outlook programming a much more pleasant experience.

-Tim
 
T

tneslony@gmail.com

Re: Is Explorer.FolderSwitch the best event for hidingcommandbarbutton?

Thank you so much Ken! Worked exactly as you described. Have a great

week.

-Tim

On May 4, 4:17 am, " - " <kenslo...@mvps.org
wrote:
> The VB6 signature of that event is:

>     BeforeFolderSwitch(NewFolder As Object, Cancel As Boolean)

> NewFolder is the MAPIFolder that will be switched to, so just use that.
> NewFolder.Name will return the name of the new folder.

> If you set Cancel = True that will prevent the switch from occurring. If you
> set it False or don't touch it at all the switch will occur.

> >

> http://www.slovaktech.com

> <tnesl...@gmail.com> wrote in message

> news:f35ec698-52ad-4691-b414-7dae2de739fd@w31g2000prd.googlegroups.com...
> Hi Ken,

> Thank you for your quick reply.  I tried using the BeforeFolderSwitch
> event, however I can't seem to figure out which folder will be
> selected next.  The m_olExplorer.CurrentFolder.Name returns (as one
> would expect) the current folder.

> Just to give you some background, I'm trying to hide or disable a
> commandbarbutton when not viewing email (i.e. hide for calendar,
> tasks, journal, etc...).  Sorry if this a backwards method for
> accomplishing this task.  Can you suggest a better strategy?

> PS:  Thank you very much for sharing your VB6 template...  It has made
> learning Outlook programming a much more pleasant experience.

> -Tim
 
Status
Not open for further replies.
Top