Solved

changing  a programs menu items

Posted on 2004-08-02
5
162 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Validating VB6 Function 19 59
Run code from text file in vb 1 65
Spell Check in VB6 13 114
Problem to With line 4 57
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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…
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…

803 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