Help me with placing button in another application's title bar.


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 6 of 6

Thread: Help me with placing button in another application's title bar.

  1. #1
    Join Date
    Jun 2006
    Posts
    29

    Help me with placing button in another application's title bar.

    Hello all!

    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.
    Attached Files Attached Files

  2. #2
    Join Date
    Oct 2005
    Location
    Maady
    Posts
    1,819
    First to get the caption of any form , in addition of the existed APIs in your app u need this :
    Private Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hWnd As Long) As Long

    and in your command1_click for example put this :
    Code:
       Dim Buffer As String, TextLength As Long
        TextLength& = GetWindowTextLength(WindowHandle&)
        Buffer$ = String(TextLength&, 0&)
        Call GetWindowText(WindowHandle&, Buffer$, TextLength& + 1)
        MsgBox Buffer$
    The msgbox will show the caption of the form focused on it, so u may make for example a select case Buffer$ :
    case untitled
    popup untitledMenu
    case *.txt
    popup XYZMenu
    and so on ...

    hope this helps..
    Note in case of this code individualy u need from the previous attachment this API :
    GetWindowText() ' more important than the listed API .
    and u need the "WindowHandle()" function .
    Programmer&Cracker CS
    MyBlog:Blog.Amahdy.com
    MyWebsite:www.Amahdy.com

  3. #3
    Join Date
    Jun 2006
    Posts
    29
    Quote Originally Posted by varsha123 View Post
    hi Ruturaaj,

    you have some solution for this Please provide me.
    Hi!

    Yes, I managed to derive a solution for this problem; but it's long back now and I will need to find the code on my Home Machine. Please give me a day's time and I will get back to you with further information. I hope I will find it in my deep folder structure somewhere.

    I just tell you what I did ... I constantly monitor the active window and then get the size of current active window. Then with some manipulations, I "approximate" the position of new button and create an API Window with CreateWindow and add a Button to it at runtime. Then, I just synchronize this newly created button with the active window which gives the "feel" of placing a button in the title bar of third party window. Needless to say, you have to set the Window Class of your newly created API window very carefully and also need to make it a child process of current active window so then any message boxes or any Modal windows shown by that third party application goes smooth; else our button appears over these windows and it certainly looks odd.

    I hope this description will help you; I will try my best to find the code in my code archive; if I get it then I will surely share that with you. In the mean time, you may proceed with the logic flow that I've described above. This has worked for me, hopefully you will be able to make it to work it for you, too.

    Happy Coding!

    Ruturaaj.

  4. #4
    Join Date
    Dec 2008
    Posts
    8

    Help me with placing button in another application's title bar.

    Hi,

    Thanks for your reply.
    I read your steps. I will try to follow same step. but if you will able to find the source code then that will be more easier for me to understand.

    I think your inserted external button using new window instead exsting window. Can we directly add buttons onto active windows title bar.

    How to make new window as a child process of current active window ?

    Please help me!!!!!

    Thanks & Regards
    Varsha

  5. #5
    Join Date
    Dec 2008
    Posts
    8

    Help me with placing button in another application's title bar.

    Hi,


    Thanks for your reply.

    I want to insert custom button onto title bar of external window. But I don't have access to that window.

    Can I add this buttons using VC++.
    I am new to VC++.
    "I want to insert button on every active external window and on click event I want to check some functionality".

    If you have any sample code or tutorial. please provide me.
    If possible please tell me, what are the functions useful for that?

    I tried to create custom window using createwindow() function.
    How to hide title bar of that window?
    How to set that window as top of external window's title bar?


    Please provide me some help related to this .


    Thanks & Regards

    Varsha

  6. #6
    Join Date
    Dec 2008
    Posts
    8

    Help for "How to create buttons onto titlebar of any active window?"

    Hi,


    I tried your steps. But in my code I have some problem.
    1] When I tried to draw button using WM_PAINT of custom application window proc then button shown flickring effect.
    2] I set the position of custom window using SetWindowPos with hWndInsertAfter=HWND_TOP then It changes its zorder or inactivated after some time with some window event like resize and titlebar mousedown.

    I want to add buttons onto any active window.

    I attached my code with this mail which is created in VC++ VS2003.

    Please replacethe threadId of SetWindowsHookEx function which in main.c's
    winmain function to the any active window threadId using SPY++ of Visual studio tools.


    Please tell my code is worng or right and how to solve above problems.

    Thanks & Regards
    Varsha
    Attached Files Attached Files
    Last edited by varsha123; 12-17-2008 at 01:58 AM.

Similar Threads

  1. Replies: 0
    Last Post: 04-07-2006, 07:33 PM
  2. Need help with calculator...
    By 2eXtreme in forum Java
    Replies: 0
    Last Post: 04-05-2006, 07:38 AM
  3. button listener not working
    By DrunkinP in forum Java
    Replies: 0
    Last Post: 03-31-2005, 09:36 AM
  4. Replies: 0
    Last Post: 03-17-2005, 11:47 AM
  5. add a buttonm in the title bar
    By MaRiŲ in forum VB Classic
    Replies: 4
    Last Post: 06-09-2002, 06:32 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center