Re: How can I tell if my Ribbon is visible?
- From: "Patrick Schmid [MVP]" <pdschmid@xxxxxxxxxxxxxxx>
- Date: Wed, 11 Apr 2007 00:11:25 +0000
Something like this:
RibbonX:
<button id="InvisibleButton" getVisible="getRibbonVisible" />
C#:
public bool getRibbonVisible(IRibbonControl control) {
ribbonVisible=true;
return false;
}
private bool ribbonVisible=false;
private IRibbonUI ribbon; //assuming you set this with onLoad
void checkRibbonVisibility() {
ribbonVisible=false;
ribbon.InvalidateControl("InvisibleButton");
}
You only have to decide when to call checkRibbonVisibility(). Depending on the performance cost of executing the callback (you might have to do some checking to see what it is), you could do this whenever your event gets triggered, but before you execute your parsing. Or you could do it with a timer every 5-10 seconds or longer.
The callback will be executed once your tab is brought into the foreground. There is no guaranteed order of execution for callbacks, so you should have ribbonVisible=true on the top of all your callbacks for the controls on that tab. While your tab is visible, getRibbonVisible will always be executed right away after you called checkRibbonVisibility. When your tab becomes invisible, it won't execute the callback until it becomes visible again.
You can do this approach with any of your controls and callbacks, there is no need to create a special one for it. However, I'd suggest you create a dedicated one that has only one callback (your other controls prob. have more than one each) and hence has the minimum performance impact possible.
As I said before, you can use the Accessibility API alternatively to query what the foreground tab is. I have only played around with this a little bit, so I can't give you more than a few hints as to how to get started with it.
That's really it though. There are no events in the object model that would allow you query this kind of information directly. It's either one of those two hacks.
Patrick Schmid [OneNote MVP]
--------------
http://pschmid.net
***
Office 2007 RTM Issues: http://pschmid.net/blog/2006/11/13/80
***
Customize Office 2007: http://pschmid.net/office2007/customize
RibbonCustomizer Add-In: http://pschmid.net/office2007/ribboncustomizer
OneNote 2007: http://pschmid.net/office2007/onenote
***
Subscribe to my Office 2007 blog: http://pschmid.net/blog/feed
"David Thielen" <thielen@xxxxxxxxxxxxx> wrote in message news:92ABFEFE-E366-42F1-A0EA-92B691E9A386@xxxxxxxxxxxxx:
How would the hidden button approach work?
--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com
Cubicle Wars - http://www.windwardreports.com/film.htm
"Patrick Schmid [MVP]" wrote:
> You could make yourself a special hidden button that you can keep around
> only for the purpose of figuring out whether they are still using your
> tab or not.
> Alternatively, you can get some info about the currently active tab via
> the Accessibility API. It's not ideal as it would only give you labels,
> but it might give you what you need...
>
> Patrick Schmid [OneNote MVP]
> --------------
> http://pschmid.net
> ***
> Office 2007 RTM Issues: http://pschmid.net/blog/2006/11/13/80
> ***
> Customize Office 2007: http://pschmid.net/office2007/customize
> RibbonCustomizer Add-In: http://pschmid.net/office2007/ribboncustomizer
> OneNote 2007: http://pschmid.net/office2007/onenote
> ***
> Subscribe to my Office 2007 blog: http://pschmid.net/blog/feed
>
> "David Thielen" <thielen@xxxxxxxxxxxxx> wrote in message
> news:53112C16-C34F-4BFC-96C3-97B6E09F9534@xxxxxxxxxxxxx:
>
> > It helps a little. Once they start using us and then go back to standard
> > editing we then have this overhead from then on.
> >
> > This is frustrating because about 3 years ago I talked to a Program Manager
> > and developer in the Word group and one of the biggies I told him we could
> > use was this functionality.
> >
> > --
> > thanks - dave
> > david_at_windward_dot_net
> > http://www.windwardreports.com
> >
> > Cubicle Wars - http://www.windwardreports.com/film.htm
> >
> >
> >
> >
> > "Patrick Schmid [MVP]" wrote:
> >
> > > No.
> > > There is one rule you can apply though: If your callbacks for that tab
> > > haven't been executed yet, then the tab has never been visible. So let's
> > > say you are changing a button every time you parse a paragraph. The
> > > callback will only be executed once the tab is visible. So if the tab
> > > hasn't been shown yet, the callback will not have been called. If the
> > > tab is currently invisible, the callback won't be executed either.
> > >
> > > Does that help?
> > >
> > > Patrick Schmid [OneNote MVP]
> > > --------------
> > > http://pschmid.net
> > > ***
> > > Office 2007 RTM Issues: http://pschmid.net/blog/2006/11/13/80
> > > ***
> > > Customize Office 2007: http://pschmid.net/office2007/customize
> > > RibbonCustomizer Add-In: http://pschmid.net/office2007/ribboncustomizer
> > > OneNote 2007: http://pschmid.net/office2007/onenote
> > > ***
> > > Subscribe to my Office 2007 blog: http://pschmid.net/blog/feed
> > >
> > > "David Thielen" <thielen@xxxxxxxxxxxxx> wrote in message
> > > news:4AD1603B-A359-49CF-A0B9-BCA422500839@xxxxxxxxxxxxx:
> > >
> > > > Yeah. I have to sit on the WindowSelectionChange event and when it triggers I
> > > > have to parse the paragraph I am on. Much better if I only do it when my tab
> > > > is visible.
> > > >
> > > > If not the tab, is there a way to tell if any of 4 buttons are visible?
> > > >
> > > > --
> > > > thanks - dave
> > > > david_at_windward_dot_net
> > > > http://www.windwardreports.com
> > > >
> > > > Cubicle Wars - http://www.windwardreports.com/film.htm
> > > >
> > > >
> > > >
> > > >
> > > > "Patrick Schmid [MVP]" wrote:
> > > >
> > > > > You mean when your tab is visible?
> > > > > Nope...
> > > > >
> > > > > Patrick Schmid [OneNote MVP]
> > > > > --------------
> > > > > http://pschmid.net
> > > > > ***
> > > > > Office 2007 RTM Issues: http://pschmid.net/blog/2006/11/13/80
> > > > > ***
> > > > > Customize Office 2007: http://pschmid.net/office2007/customize
> > > > > RibbonCustomizer Add-In: http://pschmid.net/office2007/ribboncustomizer
> > > > > OneNote 2007: http://pschmid.net/office2007/onenote
> > > > > ***
> > > > > Subscribe to my Office 2007 blog: http://pschmid.net/blog/feed
> > > > >
> > > > >
> > > > > "David Thielen" <thielen@xxxxxxxxxxxxx> wrote in message
> > > > > news:AE1215E9-2935-479B-BB24-1D470587E124@xxxxxxxxxxxxx:
> > > > >
> > > > > > I have to sit on a very expensive Word event when my Ribon is visible. Is
> > > > > > there a way to get a call from Word when it is displayed and another call
> > > > > > when it is hidden?
> > > > > >
> > > > > > --
> > > > > > thanks - dave
> > > > > > david_at_windward_dot_net
> > > > > > http://www.windwardreports.com
> > > > > >
> > > > > > Cubicle Wars - http://www.windwardreports.com/film.htm
> > > > >
> > > > >
> > >
> > >
>
>
.
- Follow-Ups:
- Re: How can I tell if my Ribbon is visible?
- From: David Thielen
- Re: How can I tell if my Ribbon is visible?
- References:
- Re: How can I tell if my Ribbon is visible?
- From: David Thielen
- Re: How can I tell if my Ribbon is visible?
- Prev by Date: Re: How can I tell if my Ribbon is visible?
- Next by Date: RE: Is there a Word 2007 event when the caret moves?
- Previous by thread: Re: How can I tell if my Ribbon is visible?
- Next by thread: Re: How can I tell if my Ribbon is visible?
- Index(es):
Relevant Pages
|