A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Add-ins for Outlook
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Intercepting click event of built-in button



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old September 12th 07, 09:24 AM posted to microsoft.public.outlook.program_addins
Thomson Mui
external usenet poster
 
Posts: 2
Default Intercepting click event of built-in button

Hi,

I'm using VB6 to write an Outlook Add-in for Outlook 2003. I need to
intercept the click event of some built-in buttons from the Explore object
because the Outlook object model does not have all the events I need.

The problem is if I have multiple explorers running, the click event will be
triggered multiple times, when the button is pressed once. I know I need to
set the .tag property to some unique value to avoid the event being trigged
more than once, if it is a new button, but the trick does not work for
built-in button controls.

I have a class to wrap the explorer collection and the class has it's own
variable to hold the button object

My code looks like this:


Set oBtnHelp = oExplorer.CommandBars("Standard").Controls("Help")
oBtnHelp.tag = "some unique value for each explorer"
......
......
Private Sub oBtnHelp_Click(ByVal Ctrl As Office.CommandBarButton,
CancelDefault As Boolean)
'Do something for this event
End Sub

Could anyone show me what I need to do to fix the issue?

Thanks,
Thomson


Ads
  #2  
Old September 12th 07, 03:00 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Intercepting click event of built-in button

You can't set the properties on built-in buttons that would enable avoiding
this, so you have to use something like flags to avoid the problem. Set a
global flag when the click is first handled and let the other handlers test
for that flag. Use something like a timer to clear the flag after a short
period of time so the next legitimate click is then handled.

--
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


"Thomson Mui" wrote in message
...
Hi,

I'm using VB6 to write an Outlook Add-in for Outlook 2003. I need to
intercept the click event of some built-in buttons from the Explore object
because the Outlook object model does not have all the events I need.

The problem is if I have multiple explorers running, the click event will
be
triggered multiple times, when the button is pressed once. I know I need
to
set the .tag property to some unique value to avoid the event being
trigged
more than once, if it is a new button, but the trick does not work for
built-in button controls.

I have a class to wrap the explorer collection and the class has it's own
variable to hold the button object

My code looks like this:


Set oBtnHelp = oExplorer.CommandBars("Standard").Controls("Help")
oBtnHelp.tag = "some unique value for each explorer"
.....
.....
Private Sub oBtnHelp_Click(ByVal Ctrl As Office.CommandBarButton,
CancelDefault As Boolean)
'Do something for this event
End Sub

Could anyone show me what I need to do to fix the issue?

Thanks,
Thomson



  #3  
Old September 13th 07, 07:14 AM posted to microsoft.public.outlook.program_addins
Thomson Mui
external usenet poster
 
Posts: 2
Default Intercepting click event of built-in button

Thanks alot. I will try your suggestion.


"Ken Slovak - [MVP - Outlook]" wrote in message
...
You can't set the properties on built-in buttons that would enable

avoiding
this, so you have to use something like flags to avoid the problem. Set a
global flag when the click is first handled and let the other handlers

test
for that flag. Use something like a timer to clear the flag after a short
period of time so the next legitimate click is then handled.

--
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


"Thomson Mui" wrote in message
...
Hi,

I'm using VB6 to write an Outlook Add-in for Outlook 2003. I need to
intercept the click event of some built-in buttons from the Explore

object
because the Outlook object model does not have all the events I need.

The problem is if I have multiple explorers running, the click event

will
be
triggered multiple times, when the button is pressed once. I know I

need
to
set the .tag property to some unique value to avoid the event being
trigged
more than once, if it is a new button, but the trick does not work for
built-in button controls.

I have a class to wrap the explorer collection and the class has it's

own
variable to hold the button object

My code looks like this:


Set oBtnHelp = oExplorer.CommandBars("Standard").Controls("Help")
oBtnHelp.tag = "some unique value for each explorer"
.....
.....
Private Sub oBtnHelp_Click(ByVal Ctrl As Office.CommandBarButton,
CancelDefault As Boolean)
'Do something for this event
End Sub

Could anyone show me what I need to do to fix the issue?

Thanks,
Thomson





  #4  
Old September 17th 07, 10:29 AM posted to microsoft.public.outlook.program_addins
Michael[_4_]
external usenet poster
 
Posts: 4
Default Intercepting click event of built-in button

An additional thing you could give a try is to get the explorers.count
and then count the events triggered by the relevant button. Once the
explorers.count has been reached you can get ready for the next click event.
Finally you can mix this with the previous suggestions from Ken just in
case one event will not be fired for an unknown reason...

happy coding!

-Michael

Thomson Mui schrieb:
Thanks alot. I will try your suggestion.


"Ken Slovak - [MVP - Outlook]" wrote in message
...
You can't set the properties on built-in buttons that would enable

avoiding
this, so you have to use something like flags to avoid the problem. Set a
global flag when the click is first handled and let the other handlers

test
for that flag. Use something like a timer to clear the flag after a short
period of time so the next legitimate click is then handled.

--
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


"Thomson Mui" wrote in message
...
Hi,

I'm using VB6 to write an Outlook Add-in for Outlook 2003. I need to
intercept the click event of some built-in buttons from the Explore

object
because the Outlook object model does not have all the events I need.

The problem is if I have multiple explorers running, the click event

will
be
triggered multiple times, when the button is pressed once. I know I

need
to
set the .tag property to some unique value to avoid the event being
trigged
more than once, if it is a new button, but the trick does not work for
built-in button controls.

I have a class to wrap the explorer collection and the class has it's

own
variable to hold the button object

My code looks like this:


Set oBtnHelp = oExplorer.CommandBars("Standard").Controls("Help")
oBtnHelp.tag = "some unique value for each explorer"
.....
.....
Private Sub oBtnHelp_Click(ByVal Ctrl As Office.CommandBarButton,
CancelDefault As Boolean)
'Do something for this event
End Sub

Could anyone show me what I need to do to fix the issue?

Thanks,
Thomson




 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Outlook 2007 Appointment built-in control id for Send button GR Add-ins for Outlook 0 May 22nd 07 09:26 PM
An event raise twice when click the button. David Add-ins for Outlook 0 July 16th 06 12:25 PM
click a button on the toolbar (via VBA?) Dan Outlook and VBA 7 May 2nd 06 09:35 AM
click a button on the toolbar (via VBA?) Dan Outlook - General Queries 2 May 1st 06 01:39 PM
form and event click ivanoe Outlook - Using Forms 1 January 17th 06 08:40 PM


All times are GMT +1. The time now is 09:18 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.