Solved

changing  a programs menu items

Posted on 2004-08-02
5
142 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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

772 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

9 Experts available now in Live!

Get 1:1 Help Now