Solved

changing  a programs menu items

Posted on 2004-08-02
5
184 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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 Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

737 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