Solved

changing  a programs menu items

Posted on 2004-08-02
5
153 Views
Last Modified: 2010-05-02
i was wondering a way to watch other opened windows, and if juust opened, then it would add an item to the right of thier file/edit/view/help menu, .. maybve a small image..

for example, in my internetexplorer, i have file, edit, view, favorites, tool, help.
and i would like to add a new menu item to the right of that (maybve called custom), or an small image they could click, to get other tools.
I dont want to just add an item to the help or tools menu option, i want to create a whole new option, for every running program.


would i have to add or change thier menu using some api? or com interface...

how?

robert
0
Comment
Question by:karthic420
  • 2
5 Comments
 
LVL 17

Accepted Solution

by:
zzzzzooc earned 500 total points
ID: 11705962
Complicated situation. You're going to have a lot of work ahead of you for this.

You'll have to enumerate through every top-level window, add the menus and then sub-class that window to receive events from it. Since you'll be sub-classing windows that don't belong to your process, the call-back procedure has to exist within a DLL to be accessed by any process. Also, there will be cases where you can't add menu-items to certain windows.

Since most of these have been covered by me already, I'll just post links to older questions I answered.

Adding menus with sub-menus..
http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20788535.html

Cross-process subclassing..
http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_21064319.html

I didn't want to look for the window-enumeration question(s) so here's a new example..

Form1:
-------------------
Option Explicit

Private Declare Function GetClassName Lib "User32" Alias "GetClassNameA" (ByVal hWnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Private Declare Function GetWindow Lib "User32" (ByVal hWnd As Long, ByVal wCmd As Long) As Long

Private Const GW_HWNDFIRST   As Long = 0
Private Const GW_HWNDNEXT    As Long = 2
Private Const GW_CHILD       As Long = 5
Private Sub Form_Load()
    Call WindowFind
End Sub
Private Sub WindowClass(ByVal lngHandle As Long, ByRef strClass As String)
    Dim strBuff As String, intLen As Integer
    strBuff = Space(256)
    intLen = GetClassName(lngHandle, strBuff, Len(strBuff))
    If intLen > 0 Then
        strClass = Left(strBuff, intLen)
    End If
End Sub
Private Sub WindowFind()
    Dim lngHandle As Long, strClass As String
    lngHandle = GetWindow(Me.hWnd, GW_HWNDFIRST)
    Do Until lngHandle = 0
        Call WindowClass(lngHandle, strClass)
        Debug.Print "Handle: " & lngHandle, , "Class:" & strClass
        lngHandle = GetWindow(lngHandle, GW_HWNDNEXT)
        DoEvents
    Loop
End Sub


0
 
LVL 17

Expert Comment

by:zzzzzooc
ID: 12388588
Suggestion: Accept zzzzzooc (logic and samples provided should be enough) / PAQ & No Refund (they never replied)

You can judge which one suits if they don't reply.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

919 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

15 Experts available now in Live!

Get 1:1 Help Now