PC Review


Reply
Thread Tools Rate Thread

Context Menu Question

 
 
John Erickson
Guest
Posts: n/a
 
      27th Aug 2009
Hi,

I think I know what you are probably going to say to this, but I thought I'd
give it a shot anyway. I read all the other messages about Context menus and
how they are unsupport, but there's this hack. I've been trying to use the
hack for my Outlook 2000 add-in, but I'm having a really strange problem. I
track down the "Context Menu", then I find the CommandBarPopup on it that I
want to add 3 buttons to. I'm able to do all that and my new buttons work
fine. I can click on them and my event gets triggered and everything is
wonderful. The thing I can't explain is that my new buttons work the first
time the context menu is displayed, but 2nd and subsequent times my buttons
are missing. When I look at the context menu collection on the 2nd and
subsequent attempts to bring it up, the controls I added to the context menu
are still there. They're enabled, visible, have a height and a width, but
they just don't show up. I've attempted to use the Delete method on my
buttons and re-add them, but I can't seem to get that to work. The delete
doesn't seem to do anything. Is there some other call I need to make to have
the delete method work? Anyone have a clue how to fix this? I'd be happy to
share code on it, but it's somewhat lengthy.

John
 
Reply With Quote
 
 
 
 
John Erickson
Guest
Posts: n/a
 
      28th Aug 2009
I have some new info. I just started my testing on Outlook 2002 and my
context menu problem doesn't occur there. My 3 added buttons appear on the
context menu ALL the time. Not just the first time. I'm using the exact same
code as I am for Outlook 2000. Any idea what is different in Outlook 2000
that's making my added buttons only appear the first time? Or better yet any
ideas on a work around?

John

"John Erickson" wrote:

> Hi,
>
> I think I know what you are probably going to say to this, but I thought I'd
> give it a shot anyway. I read all the other messages about Context menus and
> how they are unsupport, but there's this hack. I've been trying to use the
> hack for my Outlook 2000 add-in, but I'm having a really strange problem. I
> track down the "Context Menu", then I find the CommandBarPopup on it that I
> want to add 3 buttons to. I'm able to do all that and my new buttons work
> fine. I can click on them and my event gets triggered and everything is
> wonderful. The thing I can't explain is that my new buttons work the first
> time the context menu is displayed, but 2nd and subsequent times my buttons
> are missing. When I look at the context menu collection on the 2nd and
> subsequent attempts to bring it up, the controls I added to the context menu
> are still there. They're enabled, visible, have a height and a width, but
> they just don't show up. I've attempted to use the Delete method on my
> buttons and re-add them, but I can't seem to get that to work. The delete
> doesn't seem to do anything. Is there some other call I need to make to have
> the delete method work? Anyone have a clue how to fix this? I'd be happy to
> share code on it, but it's somewhat lengthy.
>
> John

 
Reply With Quote
 
Ken Slovak - [MVP - Outlook]
Guest
Posts: n/a
 
      28th Aug 2009
Most of the samples I've used or seen for that hack destroy the UI and
re-create it when OnUpdate() fires. Otherwise the button can go out of scope
and just sit there doing nothing. Look in the samples for a
CommandBar.Reset() call.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"John Erickson" <(E-Mail Removed)> wrote in message
news:53B04674-9152-4014-8DD7-(E-Mail Removed)...
>I have some new info. I just started my testing on Outlook 2002 and my
> context menu problem doesn't occur there. My 3 added buttons appear on the
> context menu ALL the time. Not just the first time. I'm using the exact
> same
> code as I am for Outlook 2000. Any idea what is different in Outlook 2000
> that's making my added buttons only appear the first time? Or better yet
> any
> ideas on a work around?
>
> John
>
> "John Erickson" wrote:
>
>> Hi,
>>
>> I think I know what you are probably going to say to this, but I thought
>> I'd
>> give it a shot anyway. I read all the other messages about Context menus
>> and
>> how they are unsupport, but there's this hack. I've been trying to use
>> the
>> hack for my Outlook 2000 add-in, but I'm having a really strange problem.
>> I
>> track down the "Context Menu", then I find the CommandBarPopup on it that
>> I
>> want to add 3 buttons to. I'm able to do all that and my new buttons work
>> fine. I can click on them and my event gets triggered and everything is
>> wonderful. The thing I can't explain is that my new buttons work the
>> first
>> time the context menu is displayed, but 2nd and subsequent times my
>> buttons
>> are missing. When I look at the context menu collection on the 2nd and
>> subsequent attempts to bring it up, the controls I added to the context
>> menu
>> are still there. They're enabled, visible, have a height and a width, but
>> they just don't show up. I've attempted to use the Delete method on my
>> buttons and re-add them, but I can't seem to get that to work. The delete
>> doesn't seem to do anything. Is there some other call I need to make to
>> have
>> the delete method work? Anyone have a clue how to fix this? I'd be happy
>> to
>> share code on it, but it's somewhat lengthy.
>>
>> John


 
Reply With Quote
 
John Erickson
Guest
Posts: n/a
 
      28th Aug 2009
That's what I'm attempting to do. I'm pretty sure my Unadvise is working
properly. Then I'm using the Delete method (in reverse item# order in case
Delete changes the item numbering as I'm traversing the controls collection).
Is the Office::CommandBarControl:elete method the proper way to remove the
buttons I added on the first context display? I'm asking because it doesn't
seem to actually remove the controls even though it succeeds. What's the real
meaning of the bool argument in that method? There's a method called
__NewEnum (or something to that effect) should I be using that or some other
call after the Deletes to rebuild the controls collection? It's just really
odd that the same code works fine in Outlook 2002 but doesn't in Outlook 2000.

John

"Ken Slovak - [MVP - Outlook]" wrote:

> Most of the samples I've used or seen for that hack destroy the UI and
> re-create it when OnUpdate() fires. Otherwise the button can go out of scope
> and just sit there doing nothing. Look in the samples for a
> CommandBar.Reset() call.
>
> --
> Ken Slovak
> [MVP - Outlook]
> http://www.slovaktech.com
> Author: Professional Programming Outlook 2007.
> Reminder Manager, Extended Reminders, Attachment Options.
> http://www.slovaktech.com/products.htm
>
>
> "John Erickson" <(E-Mail Removed)> wrote in message
> news:53B04674-9152-4014-8DD7-(E-Mail Removed)...
> >I have some new info. I just started my testing on Outlook 2002 and my
> > context menu problem doesn't occur there. My 3 added buttons appear on the
> > context menu ALL the time. Not just the first time. I'm using the exact
> > same
> > code as I am for Outlook 2000. Any idea what is different in Outlook 2000
> > that's making my added buttons only appear the first time? Or better yet
> > any
> > ideas on a work around?
> >
> > John
> >
> > "John Erickson" wrote:
> >
> >> Hi,
> >>
> >> I think I know what you are probably going to say to this, but I thought
> >> I'd
> >> give it a shot anyway. I read all the other messages about Context menus
> >> and
> >> how they are unsupport, but there's this hack. I've been trying to use
> >> the
> >> hack for my Outlook 2000 add-in, but I'm having a really strange problem.
> >> I
> >> track down the "Context Menu", then I find the CommandBarPopup on it that
> >> I
> >> want to add 3 buttons to. I'm able to do all that and my new buttons work
> >> fine. I can click on them and my event gets triggered and everything is
> >> wonderful. The thing I can't explain is that my new buttons work the
> >> first
> >> time the context menu is displayed, but 2nd and subsequent times my
> >> buttons
> >> are missing. When I look at the context menu collection on the 2nd and
> >> subsequent attempts to bring it up, the controls I added to the context
> >> menu
> >> are still there. They're enabled, visible, have a height and a width, but
> >> they just don't show up. I've attempted to use the Delete method on my
> >> buttons and re-add them, but I can't seem to get that to work. The delete
> >> doesn't seem to do anything. Is there some other call I need to make to
> >> have
> >> the delete method work? Anyone have a clue how to fix this? I'd be happy
> >> to
> >> share code on it, but it's somewhat lengthy.
> >>
> >> John

>
>

 
Reply With Quote
 
Ken Slovak - [MVP - Outlook]
Guest
Posts: n/a
 
      28th Aug 2009
I use the Reset() method of the CommandBar to clear the user added controls
before I add them again in OnUpdate().

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"John Erickson" <(E-Mail Removed)> wrote in message
newsB9AD729-D35E-4FCB-A44D-(E-Mail Removed)...
> That's what I'm attempting to do. I'm pretty sure my Unadvise is working
> properly. Then I'm using the Delete method (in reverse item# order in case
> Delete changes the item numbering as I'm traversing the controls
> collection).
> Is the Office::CommandBarControl:elete method the proper way to remove
> the
> buttons I added on the first context display? I'm asking because it
> doesn't
> seem to actually remove the controls even though it succeeds. What's the
> real
> meaning of the bool argument in that method? There's a method called
> __NewEnum (or something to that effect) should I be using that or some
> other
> call after the Deletes to rebuild the controls collection? It's just
> really
> odd that the same code works fine in Outlook 2002 but doesn't in Outlook
> 2000.
>
> John


 
Reply With Quote
 
John Erickson
Guest
Posts: n/a
 
      29th Aug 2009
Thanks again Ken! That got me there. One note though. In my case since I was
adding buttons to a sub-menu (CommandBarPopup), it took a couple coding
attempts on my part. Initially I had been deleting the added buttons from the
collection in the CommandBarPopup (the Junk E-mail sub-menu in my case), so I
simply did the Reset() call you recommended on that CommandBarPopup object.
That resulted in the same behaviour. My added buttons appeared on the first
context menu, but not subsequent ones. In order to finally fix the problem I
had to move the Reset() up a level to the CommandBar representing the
"Context Menu". Once I did that, my added buttons now appear ALL the time. I
appreciate the guidence.

John

"Ken Slovak - [MVP - Outlook]" wrote:

> I use the Reset() method of the CommandBar to clear the user added controls
> before I add them again in OnUpdate().
>
> --
> Ken Slovak
> [MVP - Outlook]
> http://www.slovaktech.com
> Author: Professional Programming Outlook 2007.
> Reminder Manager, Extended Reminders, Attachment Options.
> http://www.slovaktech.com/products.htm
>
>
> "John Erickson" <(E-Mail Removed)> wrote in message
> newsB9AD729-D35E-4FCB-A44D-(E-Mail Removed)...
> > That's what I'm attempting to do. I'm pretty sure my Unadvise is working
> > properly. Then I'm using the Delete method (in reverse item# order in case
> > Delete changes the item numbering as I'm traversing the controls
> > collection).
> > Is the Office::CommandBarControl:elete method the proper way to remove
> > the
> > buttons I added on the first context display? I'm asking because it
> > doesn't
> > seem to actually remove the controls even though it succeeds. What's the
> > real
> > meaning of the bool argument in that method? There's a method called
> > __NewEnum (or something to that effect) should I be using that or some
> > other
> > call after the Deletes to rebuild the controls collection? It's just
> > really
> > odd that the same code works fine in Outlook 2002 but doesn't in Outlook
> > 2000.
> >
> > John

>
>

 
Reply With Quote
 
nikhil
Guest
Posts: n/a
 
      4th Sep 2009
Hello,

I am doing similar kind of thing that John ericskon is talking about.
The only difference is that i am adding menu items in the main context menu.
The problem that i am facing is, when i right click on a mail item my menu
items
are getting inserted & are working fine all the time.But when i right click
on a
non-mail item or a mail item(with attachment) outlook simply crashes.
slovak sir can you please giude me on this.

nikhil

"John Erickson" wrote:

> Thanks again Ken! That got me there. One note though. In my case since I was
> adding buttons to a sub-menu (CommandBarPopup), it took a couple coding
> attempts on my part. Initially I had been deleting the added buttons from the
> collection in the CommandBarPopup (the Junk E-mail sub-menu in my case), so I
> simply did the Reset() call you recommended on that CommandBarPopup object.
> That resulted in the same behaviour. My added buttons appeared on the first
> context menu, but not subsequent ones. In order to finally fix the problem I
> had to move the Reset() up a level to the CommandBar representing the
> "Context Menu". Once I did that, my added buttons now appear ALL the time. I
> appreciate the guidence.
>
> John
>
> "Ken Slovak - [MVP - Outlook]" wrote:
>
> > I use the Reset() method of the CommandBar to clear the user added controls
> > before I add them again in OnUpdate().
> >
> > --
> > Ken Slovak
> > [MVP - Outlook]
> > http://www.slovaktech.com
> > Author: Professional Programming Outlook 2007.
> > Reminder Manager, Extended Reminders, Attachment Options.
> > http://www.slovaktech.com/products.htm
> >
> >
> > "John Erickson" <(E-Mail Removed)> wrote in message
> > newsB9AD729-D35E-4FCB-A44D-(E-Mail Removed)...
> > > That's what I'm attempting to do. I'm pretty sure my Unadvise is working
> > > properly. Then I'm using the Delete method (in reverse item# order in case
> > > Delete changes the item numbering as I'm traversing the controls
> > > collection).
> > > Is the Office::CommandBarControl:elete method the proper way to remove
> > > the
> > > buttons I added on the first context display? I'm asking because it
> > > doesn't
> > > seem to actually remove the controls even though it succeeds. What's the
> > > real
> > > meaning of the bool argument in that method? There's a method called
> > > __NewEnum (or something to that effect) should I be using that or some
> > > other
> > > call after the Deletes to rebuild the controls collection? It's just
> > > really
> > > odd that the same code works fine in Outlook 2002 but doesn't in Outlook
> > > 2000.
> > >
> > > John

> >
> >

 
Reply With Quote
 
Ken Slovak - [MVP - Outlook]
Guest
Posts: n/a
 
      4th Sep 2009
If you are going to hijack other threads at least provide enough information
for your question to be answered. I have no idea what your code is doing,
what version of Outlook, whether it's VBA or addin code or in what language,
or much of anything else other than your code isn't working right.

Are you assuming a mail item and not testing for it before instantiating a
mail item object?

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"nikhil" <(E-Mail Removed)> wrote in message
news:53C4D3D2-DF90-4BFC-B36D-(E-Mail Removed)...
> Hello,
>
> I am doing similar kind of thing that John ericskon is talking about.
> The only difference is that i am adding menu items in the main context
> menu.
> The problem that i am facing is, when i right click on a mail item my menu
> items
> are getting inserted & are working fine all the time.But when i right
> click
> on a
> non-mail item or a mail item(with attachment) outlook simply crashes.
> slovak sir can you please giude me on this.
>
> nikhil


 
Reply With Quote
 
nikhil
Guest
Posts: n/a
 
      5th Sep 2009
hello sir,
thanks for your reply.
m extremely sorry for the lack of information.
I have written a Add-in for this purpose in VC++/ATL.
The same code is working fine with the Outlook XP & Outlook 2003.
But the problem is occuring in case of Outlook 2000.
Before doing this i refered following link which also contains your reply :
http://www.gtro.com/delphi/spamfilter_e.php
I am following exactly similar steps which are discussed above(handling
OnUpdate event).
My observation is mail item's(with attachment ) context menu contains more
menu items than a normal mail item's context menu does have.
so may be the case which is discussed in above link is occuring.
Don't know what exactly is happening as m just a begginer in this field.
here's my pseudo code for it:

//Everything is done in OnUpdate()
1. Enumerating CommandBars collection to locate "Context Menu".
2. spCtxtMenuCmdBar->Reset();//before exceutign this code it's crashing.
spCtxtMenuCmdBar->get_Protection(&OldCmdBarProtection);
spCtxtMenuCmdBar->put_Protection(msoBarNoProtectio);
3. Regular code for adding button into it & advise click event for it.
4. restore old protection.

Nikhil.

"Ken Slovak - [MVP - Outlook]" wrote:

> If you are going to hijack other threads at least provide enough information
> for your question to be answered. I have no idea what your code is doing,
> what version of Outlook, whether it's VBA or addin code or in what language,
> or much of anything else other than your code isn't working right.
>
> Are you assuming a mail item and not testing for it before instantiating a
> mail item object?
>
> --
> Ken Slovak
> [MVP - Outlook]
> http://www.slovaktech.com
> Author: Professional Programming Outlook 2007.
> Reminder Manager, Extended Reminders, Attachment Options.
> http://www.slovaktech.com/products.htm
>
>
> "nikhil" <(E-Mail Removed)> wrote in message
> news:53C4D3D2-DF90-4BFC-B36D-(E-Mail Removed)...
> > Hello,
> >
> > I am doing similar kind of thing that John ericskon is talking about.
> > The only difference is that i am adding menu items in the main context
> > menu.
> > The problem that i am facing is, when i right click on a mail item my menu
> > items
> > are getting inserted & are working fine all the time.But when i right
> > click
> > on a
> > non-mail item or a mail item(with attachment) outlook simply crashes.
> > slovak sir can you please giude me on this.
> >
> > nikhil

>
>

 
Reply With Quote
 
Ken Slovak - [MVP - Outlook]
Guest
Posts: n/a
 
      8th Sep 2009
I have no idea why you are having that problem. My suggestion would probably
be to not offer support for the context menus in Outlook 2000.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"nikhil" <(E-Mail Removed)> wrote in message
news57F543F-3A50-4237-97A4-(E-Mail Removed)...
> hello sir,
> thanks for your reply.
> m extremely sorry for the lack of information.
> I have written a Add-in for this purpose in VC++/ATL.
> The same code is working fine with the Outlook XP & Outlook 2003.
> But the problem is occuring in case of Outlook 2000.
> Before doing this i refered following link which also contains your reply
> :
> http://www.gtro.com/delphi/spamfilter_e.php
> I am following exactly similar steps which are discussed above(handling
> OnUpdate event).
> My observation is mail item's(with attachment ) context menu contains more
> menu items than a normal mail item's context menu does have.
> so may be the case which is discussed in above link is occuring.
> Don't know what exactly is happening as m just a begginer in this field.
> here's my pseudo code for it:
>
> //Everything is done in OnUpdate()
> 1. Enumerating CommandBars collection to locate "Context Menu".
> 2. spCtxtMenuCmdBar->Reset();//before exceutign this code it's crashing.
> spCtxtMenuCmdBar->get_Protection(&OldCmdBarProtection);
> spCtxtMenuCmdBar->put_Protection(msoBarNoProtectio);
> 3. Regular code for adding button into it & advise click event for it.
> 4. restore old protection.
>
> Nikhil.


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
One More Context Menu Question snesbit Microsoft Dot NET Framework Forms 1 8th Mar 2005 05:16 PM
context menu question Starbuck Microsoft C# .NET 1 28th Nov 2004 11:29 PM
context menu question Matty Anderson Windows XP Help 0 3rd Feb 2004 11:27 PM
context menu question Matty Anderson Windows XP General 0 2nd Feb 2004 11:16 PM
context menu question Matty Anderson Windows XP General 0 1st Feb 2004 02:26 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:28 PM.