We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now


Adding a button to another program's window

kawa asked
Medium Priority
Last Modified: 2013-11-20
I developped an agent application and I want users to be able to call it from any other program.
Is it possible to add a button to another program's main window?
For example, I want to add a button to IE toolbar or office tool bar. Is there a standard way to do that in win95 and NT?

Any ideas?
Watch Question

You could have the button float on the desktop if you wished.

If you want to put a button in another application, you normally would install a messageproc hook on the particular window of interest (that means you are intercepting the normal callback for that window).    Then you create a new child (button) and associate it with that window.  In your hook, you would have code that handles the button and any other code you jsut pass it back to the original handler (you don't want to handle the other app's stuff).

In your handler, just have it postmessage back to your main app's window and here a Registered Windows message would cleanly do the trick.


How to make a floating button? Got any sample code??

If you put the button into a toolbar and then made the toolbar a child of the desktop you would be able to let it float.   You would probably have to muck around abit, but in the MFC is the code to make a floating toolbar:   CFrameWnd::FloatControlBar      

Otherwise, you could just create a little window (sans caption, or maybe a tiny caption) and put your button on it..

if you wished to make it a taskbar (which could attach to any side of the user's screen you can take a look at http://support.microsoft.com/download/support/mslfiles/Appbar.exe 

a sample program you can get from microsoft.

I think your solution is to create program which resides in the "system tray" as icon. You can respond to user click on this icon for example or display menu on right mouse click. Sample can be easily found on microsoft support forum or at www.codeguru.com


Thanks gelbert
I have my agent waiting in the "system tray" as icon. But my boss want it as a button in other applications. He saw it in web accelerators programs that automatecally add a button to IE tool bar. Now that he saw it, I cannot say it is not pooible. You know, he is the boss !!

Any other idea how this can be done?

Have you tried any of the things I suggested?


I am trying messageproc hook but it is not that easy. Is there a simpler way or a sample code for messageproc hook.  

Hooks can be nasty....  You will want to put your hook in a dll.  microsoft has an example of how to do this:  go to http://www.microsoft.com/win32dev/ui/hooks32.htm  there is a writeup on how to use them, plus a chunk of source and exe you can dowload to see how they work.

As long as your boss cares about MS products (IE, Office, ..) then try Add-Ins or use OLE (something like Purify when they integrate there debuger).

Try to use technique described in VC 5.0 help "Add-ins: Creating toolbar buttons", there a chance that other MS products supports these interfaces

Putting a button in every window is nearly impossible (at least if you want to be able to run under NT without being an administrator). Putting a button in every IE4/Explorer/Office98 window is probably much easier (you'll still have to have an administrator install the app, but anyone can then run it). You may even be able to just talk to the IWebBrowserApp interface or the related automation dispatch interface if all you care about is IE/Explorer, and you can similarly automate Office apps. IE will even give you irs HWND, at which point you can go wild and do whatever you want...

Unlock this solution and get a sample of our free trial.
(No credit card required)


Thanks to all who responded. I have many ideas to try.
About the add-ins all the help I found is about adding Add-ins to Devlope Studio. I will appreciate if some one give me a direction on how to do it with other applications even only MS applications.

I am now trying the other methods proposed here. Thanks for all of you again.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.