Solved

Adding a button to another program's window

Posted on 1998-07-22
13
228 Views
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?
0
Comment
Question by:kawa
  • 4
  • 4
  • 3
  • +2
13 Comments
 
LVL 2

Expert Comment

by:duneram
ID: 1319629
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
 

Author Comment

by:kawa
ID: 1319630
How to make a floating button? Got any sample code??
0
 
LVL 2

Expert Comment

by:duneram
ID: 1319631
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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 8

Expert Comment

by:gelbert
ID: 1319632
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
 

Author Comment

by:kawa
ID: 1319633
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
 
LVL 2

Expert Comment

by:duneram
ID: 1319634
Have you tried any of the things I suggested?
0
 

Author Comment

by:kawa
ID: 1319635
I am trying messageproc hook but it is not that easy. Is there a simpler way or a sample code for messageproc hook.  
0
 
LVL 2

Expert Comment

by:duneram
ID: 1319636
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
 
LVL 8

Expert Comment

by:gelbert
ID: 1319637
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
 
LVL 8

Expert Comment

by:gelbert
ID: 1319638
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
 
LVL 1

Expert Comment

by:payn
ID: 1319639
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
 
LVL 1

Accepted Solution

by:
jdyer earned 60 total points
ID: 1319640
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
 

Author Comment

by:kawa
ID: 1319641
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

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question