Solved

Adding a button to another program's window

Posted on 1998-07-22
13
195 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
 
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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
how to monitor remote shell execution on linux 9 93
while loop over for loop 7 79
NotAlone Challenge 20 72
sumHeights2  challenge 7 76
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

757 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now