Help me with placing button in another applications title bar.
I'm facing a problem in my current project and I'm not finding a way out for it. Please help me guys to get the solution for my problem ...
What I'm looking for is ... place a Command Button in the title bar of current Active window IF the title of that window matches the predefined criteria. Forget about the last IF part for a moment. The main thing that I'm not able to do is ... place a command button in another application's title bar.
The theme is ... my application will be running in the system tray and it will monitor the Active window. If the title of that window matches the criteria then it will place a button to the left of Minimize button on that application's title bar. For example, suppose my predefined criteria is "IF window Title has Notepad then place the button in Notepad application's title bar." So, my application will be running in System Tray and it will monitor each Active Window. If the current Active Window is Notepad then it will attempt to place the button in title bar of that Notepad window. When Notepad window is closed then it should be closed without crash and the button will be obviously removed from title bar. When I click this button while it's placed on Title bar of Notepad, it should open a small Popup menu which will be different and depends what caption Notepad window has. If it's "Untitled - Notepad" then some other Menu; else if it's "Quotation.txt - Notepad" then some other menu and so on. So, main thing is that I need to be able to address click events of different instances of this button as it's likely that two Notepad windows are open at the same time.
I searched on Planet Source Code and VBCode.com websites for some hint. I could find a code which places a button in the title bar ... but that's in the title bar of Owner Form's and not another application's title bar. I have altered one code that I found on Planet Source Code website which is attached to this message. Please have a look at it. Firstly, I thought that if I change the HWND property of Window in Sub-classing to the HWND of current Active Window then I will be able to achieve what I'm looking for. But it did not work! Right now I don't have any clue as how to proceed with this!
Please guide me on this issue. If you have any code/tutorials or any link that you feel it will be valuable for me then please let me know.
Waiting for your reply ...
Regards,
Ruturaaj.

