Adding a button to another program's window

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?
kawaAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
jdyerConnect With a Mentor Commented:
Create a new dialog resource and place your button in it.

Then, enumerate all the windows on the desktop until you find the one you want.
Then instantiate a new dialog class given you dialog resource with the button on it.
Then set the owner to the overlapped window that you found with the enumeration. Of course this will only work as long as your application stays open. If your application dies, so does the child window.

I've done this before and it does work. However, more elegant solutions exist, I'm sure!

Regards,

 jdyer
0
 
duneramCommented:
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.
0
 
kawaAuthor Commented:
How to make a floating button? Got any sample code??
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
duneramCommented:
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.
0
 
gelbertCommented:
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
0
 
kawaAuthor Commented:
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?

0
 
duneramCommented:
Have you tried any of the things I suggested?
0
 
kawaAuthor Commented:
I am trying messageproc hook but it is not that easy. Is there a simpler way or a sample code for messageproc hook.  
0
 
duneramCommented:
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.
0
 
gelbertCommented:
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).
0
 
gelbertCommented:
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
0
 
paynCommented:
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...

0
 
kawaAuthor Commented:
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.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.