Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 193
  • Last Modified:

changing a programs menu items

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
karthic420
Asked:
karthic420
  • 2
1 Solution
 
zzzzzoocCommented:
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
 
zzzzzoocCommented:
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now