Results 1 to 37 of 37

Thread: Adding submenus to external programs

  1. #1

    Thread Starter
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Adding submenus to external programs

    This code relies on a related thread, Subclass External Programs done for you. Download that hook control and dll.

    This example adds a menu item under the file menu item in the Notepad application. It then waits for a user to click the new menu item and responds with our own messagebox.

    Open a new project, add a command button and a hookcontrol to the form. Rename the hookcontrol to Hook.


    VB Code:
    1. Option Explicit
    2.  
    3. Const MENUID = 56 'our unique identifier
    4. Dim hWndSubMenu As Long
    5. 'Forgot these declares in a previous post
    6. Private Type MENUITEMINFO
    7.     cbSize As Long
    8.     fMask As Long
    9.     fType As Long
    10.     fState As Long
    11.     wID As Long
    12.     hSubMenu As Long
    13.     hbmpChecked As Long
    14.     hbmpUnchecked As Long
    15.     dwItemData As Long
    16.     dwTypeData As String
    17.     cch As Long
    18. End Type
    19.  
    20. Private Const MIIM_STATE = &H1
    21. Private Const MIIM_ID = &H2
    22. Private Const MIIM_STRING = &H40
    23. Private Const MIIM_FTYPE = &H100
    24.  
    25. Private Const MFT_SEPARATOR = &H800
    26. Private Const MFT_STRING = &H0
    27. Private Const MFS_ENABLED = &H0
    28. Private Const MFS_CHECKED = &H8
    29.  
    30. Private Const WM_COMMAND = &H111
    31. Private Const MF_BYCOMMAND = &H0&
    32.  
    33. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _
    34.     ByVal lpClassName As String, _
    35.     ByVal lpWindowName As String _
    36. ) As Long
    37.  
    38. Private Declare Function GetMenu Lib "user32" ( _
    39.     ByVal hwnd As Long _
    40. ) As Long
    41.  
    42. Private Declare Function GetSubMenu Lib "user32" ( _
    43.     ByVal hMenu As Long, _
    44.     ByVal nPos As Long _
    45. ) As Long
    46.  
    47. Private Declare Function RemoveMenu Lib "user32" ( _
    48.     ByVal hMenu As Long, _
    49.     ByVal nPosition As Long, _
    50.     ByVal wFlags As Long _
    51. ) As Long
    52.  
    53. Private Declare Function GetMenuItemCount Lib "user32.dll" ( _
    54.     ByVal hMenu As Long _
    55. ) As Long
    56.  
    57. Private Declare Function InsertMenuItem Lib "user32.dll" Alias "InsertMenuItemA" ( _
    58.     ByVal hMenu As Long, _
    59.     ByVal uItem As Long, _
    60.     ByVal fByPosition As Long, _
    61.     lpmii As MENUITEMINFO _
    62. ) As Long
    63.  
    64. Private Declare Function DrawMenuBar Lib "user32" ( _
    65.     ByVal hwnd As Long _
    66. ) As Long
    67.  
    68. Private Sub Command1_Click()
    69. Dim hWndNotepad As Long
    70. Dim hWndMenu As Long
    71. Dim count As Long
    72. Dim mii As MENUITEMINFO
    73. Dim appCaption As String
    74.  
    75. 'Get a handle to Notepad
    76. appCaption = "Untitled - Notepad"
    77. hWndNotepad = FindWindow(vbNullString, appCaption)
    78. While hWndNotepad = 0
    79.     If MsgBox("Open Notepad", vbOKCancel) = vbCancel Then Exit Sub
    80.     hWndNotepad = FindWindow(vbNullString, appCaption)
    81. Wend
    82.  
    83. 'Get handle to Notepad's main menu
    84. hWndMenu = GetMenu(hWndNotepad)
    85.  
    86. 'Get handle to 'File' submenu
    87. hWndSubMenu = GetSubMenu(hWndMenu, 0)
    88.  
    89. 'Get number of items in sub menu
    90. count = GetMenuItemCount(hWndSubMenu)
    91.  
    92. 'Setup data structure for InsertMenuItem call
    93.     With mii
    94.         .cbSize = Len(mii)
    95.         .fMask = MIIM_STATE Or MIIM_ID Or MIIM_STRING Or MIIM_FTYPE
    96.         .fType = MFT_STRING
    97.         .fState = MFS_ENABLED
    98.         .wID = MENUID 'our unique identifier
    99.         .dwTypeData = "My New Menu"
    100.         .cch = Len(.dwTypeData)
    101.     End With
    102.    
    103.     ' Add this to the menu.
    104.     Call InsertMenuItem(hWndSubMenu, count + 1, 1, mii)
    105.     Call DrawMenuBar(hWndNotepad)
    106.    
    107.  
    108. 'Now set up hook, we want to monitor the WM_COMMAND message
    109.  With Hook
    110.     .TargethWnd = hWndNotepad
    111.     .AddMessage WM_COMMAND, "WM_COMMAND"
    112.     .SetHook
    113.  End With
    114. End Sub
    115.  
    116.  
    117. Private Sub Form_Unload(Cancel As Integer)
    118. 'remove our hook
    119.  Hook.RemoveAllHooks
    120. 'remove our menu item
    121.  Call RemoveMenu(hWndSubMenu, MENUID, MF_BYCOMMAND)
    122. End Sub
    123.  
    124. Private Sub Hook_PostedMessage(uMsg As Long, wParam As Long, lParam As Long)
    125. 'here is where our messages will arrive
    126. 'look for our special menu ID
    127.  If (wParam And &HFFFF) = MENUID Then
    128.     'our menu item has been selected
    129.     MsgBox "Why did you do that?"
    130.  End If
    131. End Sub
    Last edited by moeur; Mar 18th, 2005 at 09:14 AM. Reason: Fix bug

  2. #2
    Hyperactive Member
    Join Date
    Nov 2003
    Location
    In Front of my computer...
    Posts
    367

    Re: Adding submenus to external programs

    I love all this hooking stuff
    awesome! nice job moeur
    Born to help others
    (If I've been helpful then please rate my post. Thanks)

    call me EJ or be slapped!

  3. #3
    New Member
    Join Date
    Mar 2005
    Posts
    13

    Re: Adding submenus to external programs

    Hello,

    I'm using VB.NET and can't seem to get a valid return for:

    GetSubMenu(GetMenu(hwnd), menuID)

    Is it the menuID (.wID = menuID) that is used as the 2nd parameter for that function, or the position on the menu that the menu you want the submenu from is located?

    Thanks.

  4. #4

    Thread Starter
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Adding submenus to external programs

    GetSubMenu(GetMenu(hwnd), MenuID)
    In this case MenuID specifies the zero-based relative position in the specified menu of an item that activates a drop-down menu or submenu.

    Did you first try the code on Notepad as written above to verify it is working?

  5. #5
    New Member
    Join Date
    Mar 2005
    Posts
    13

    Re: Adding submenus to external programs

    Great, thanks. It works fine with Notepad, and I've also managed to make it work with the other program I needed it for (thanks to your help). But my problem is, I have added the menu to the new program using InsertMenuItem, so it is not registering as a submenu. I need to add a submenu to it as well.

    Thanks for your speedy reply.

  6. #6

    Thread Starter
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Adding submenus to external programs

    But my problem is, I have added the menu to the new program using InsertMenuItem, so it is not registering as a submenu. I need to add a submenu to it as well.
    So, do you have a solution or is there still a question?

  7. #7
    New Member
    Join Date
    Mar 2005
    Posts
    13

    Re: Adding submenus to external programs

    Quote Originally Posted by moeur
    So, do you have a solution or is there still a question?
    My main issue is how I can modify the characteristics of these submenu items when they have been added.

    Like uncheck a checked menu item?

    Thanks
    Last edited by Johno; Mar 18th, 2005 at 08:37 AM.

  8. #8

    Thread Starter
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Adding submenus to external programs

    So, it worked OK with Notepad, but when you try the exact same thing on another program, it doesn't work?
    What is this other program?

  9. #9
    New Member
    Join Date
    Mar 2005
    Posts
    13

    Re: Adding submenus to external programs

    I'm starting to confuse myself now, lol. I changed that post to another issue I'm having.

    Well, I am actually trying to add a completely new menu option, with sub menu items. I couldn't manage it with the InsertMenuItem function, so I have resorted back to an old method of using the CreatePopup function. (that was my issue earlier, I was trying to add submenu items to a menu I had inserted into the main menu of another program, but I have gone back to an older method i used to use)

    But I need to interact with these submenu items, by disabling them, enabling them, changing check boxes etc.

    Sorry, lol.

  10. #10
    New Member
    Join Date
    Mar 2005
    Posts
    13

    Re: Adding submenus to external programs

    .SetHook PostedMessages

    Is this the name of the function to send the hook data to? I seem to get an error saying it cannot be assigned values. Also, in my application "PostedMessages" is not declared as anything.
    Last edited by Johno; Mar 18th, 2005 at 08:55 AM.

  11. #11

    Thread Starter
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Adding submenus to external programs

    Whoops
    I updated the hook control but didn't change this post.
    The .SetHook function no longer requires any parameters
    I modified the above code to reflect this.

  12. #12
    New Member
    Join Date
    Mar 2005
    Posts
    13

    Re: Adding submenus to external programs

    Quote Originally Posted by moeur
    Whoops
    I updated the hook control but didn't change this post.
    The .SetHook function no longer requires any parameters
    I modified the above code to reflect this.
    Hehe, that's fine. It still doesn't seem to be helping much though. Will it work in VB.NET? I do know that AddressOf now returns a delegate data type, so it can no longer return numeric values for parameters that the API often needs.

    I can't seem to find a way to hook in VB.NET, I've been looking for weeks .

  13. #13
    New Member
    Join Date
    Mar 2005
    Posts
    13

    Re: Adding submenus to external programs

    Hook.TargethWnd = GetMenu(FindWindow(vbNullString, "MSN Messenger (BETA)")).ToInt32
    Hook.AddMessage(&H111, "WM_COMMAND")
    Hook.SetHook()

    'Hook.SetHook()' - returns:

    An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in axinterop.hookctrl.dll

    Additional information: Invalid procedure call or argument

  14. #14

    Thread Starter
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Adding submenus to external programs

    I'm not at all familiar with .NET
    Hook.TargethWnd = GetMenu(FindWindow(vbNullString, "MSN Messenger (BETA)"))
    Should be
    Hook.TargethWnd = FindWindow(vbNullString, "MSN Messenger (BETA)")

  15. #15
    New Member
    Join Date
    Mar 2005
    Posts
    13

    Re: Adding submenus to external programs

    VB Code:
    1. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _
    2.         ByVal lpClassName As String, _
    3.         ByVal lpWindowName As String _
    4.     ) As IntPtr
    5.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    6.         Hook.TargethWnd = FindWindow(vbNullString, "MSN Messenger (BETA)").toInt32
    7.         Hook.AddMessage(&H111, "WM_COMMAND")
    8.         Hook.SetHook()
    9.  
    10.     End Sub
    11.     Public Sub Hook_PostedMessage(ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long)
    12.         MsgBox("")
    13.     End Sub

    Doesn't return an error anymore now, but Hook_PostedMessage never gets triggered.

    '(vbNullString, "MSN Messenger (BETA)").toInt32' returns the valid window handle ID.

    Am I missing something extra? I have added the OCX to the program, and put the MainHook.dll in the root folder.
    Last edited by Hack; Oct 10th, 2005 at 07:59 AM.

  16. #16
    New Member
    Join Date
    Mar 2005
    Posts
    3

    Re: Adding submenus to external programs

    i can't get WM_CLOSE to work, i need to know when notepad.exe is closing and change the wmsg...

    anyone?

  17. #17

    Thread Starter
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Adding submenus to external programs

    Unfortunately the WM_CLOSE and WM_DESTROY are sent messages so you cannot change them.
    When the target App receives a WM_DESTROY message, it notifies the hook control that the target App is shutting down and the control raises an UnHook event.
    So, you'll be notified when the App is shutting down, but can do nothing about it.

  18. #18
    New Member
    Join Date
    Mar 2005
    Posts
    3

    Re: Adding submenus to external programs

    Ok, now i can't hook cmd.exe ... you know hot to do it?

  19. #19

    Thread Starter
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Adding submenus to external programs

    Consoles are handled in a special way.
    see msdn: http://msdn.microsoft.com/library/de..._reference.asp

  20. #20
    New Member
    Join Date
    Jul 2005
    Posts
    15

    Re: Adding submenus to external programs

    I can't make this code work. I have removed the message hooking to try and locate where the process is failing.

    It seems to be on the InsertMenuItem call. All the handles are showing as more than 0 but the insertmenuitem returns 0. I'm using Win95 (not my decision) and Word 97 VBA...
    VB Code:
    1. Option Explicit
    2.  
    3. Const MENUID = 56 'our unique identifier
    4. Dim hWndSubMenu As Long
    5. 'Forgot these declares in a previous post
    6. Private Type MENUITEMINFO
    7.     cbSize As Long
    8.     fMask As Long
    9.     fType As Long
    10.     fState As Long
    11.     wID As Long
    12.     hSubMenu As Long
    13.     hbmpChecked As Long
    14.     hbmpUnchecked As Long
    15.     dwItemData As Long
    16.     dwTypeData As String
    17.     cch As Long
    18. End Type
    19.  
    20. Private Const MIIM_STATE = &H1
    21. Private Const MIIM_ID = &H2
    22. Private Const MIIM_STRING = &H40
    23. Private Const MIIM_FTYPE = &H100
    24.  
    25. Private Const MFT_SEPARATOR = &H800
    26. Private Const MFT_STRING = &H0
    27. Private Const MFS_ENABLED = &H0
    28. Private Const MFS_CHECKED = &H8
    29.  
    30. Private Const WM_COMMAND = &H111
    31. Private Const MF_BYCOMMAND = &H0&
    32.  
    33. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _
    34.     ByVal lpClassName As String, _
    35.     ByVal lpWindowName As String _
    36. ) As Long
    37.  
    38. Private Declare Function GetMenu Lib "user32" ( _
    39.     ByVal hwnd As Long _
    40. ) As Long
    41.  
    42. Private Declare Function GetSubMenu Lib "user32" ( _
    43.     ByVal hMenu As Long, _
    44.     ByVal nPos As Long _
    45. ) As Long
    46.  
    47. Private Declare Function RemoveMenu Lib "user32" ( _
    48.     ByVal hMenu As Long, _
    49.     ByVal nPosition As Long, _
    50.     ByVal wFlags As Long _
    51. ) As Long
    52.  
    53. Private Declare Function GetMenuItemCount Lib "user32.dll" ( _
    54.     ByVal hMenu As Long _
    55. ) As Long
    56.  
    57. Private Declare Function InsertMenuItemA Lib "user32.dll" ( _
    58.     ByVal hMenu As Long, _
    59.     ByVal uItem As Long, _
    60.     ByVal fByPosition As Long, _
    61.     lpmii As MENUITEMINFO _
    62. ) As Long
    63.  
    64. Private Declare Function DrawMenuBar Lib "user32" ( _
    65.     ByVal hwnd As Long _
    66. ) As Long
    67.  
    68. Private Sub Command1_Click()
    69. Dim hWndNotepad As Long
    70. Dim hWndMenu As Long
    71. Dim count As Long
    72. Dim mii As MENUITEMINFO
    73. Dim appCaption As String
    74.  
    75. 'Get a handle to Notepad
    76. appCaption = "Untitled - Notepad"
    77. hWndNotepad = FindWindow(vbNullString, appCaption)
    78. While hWndNotepad = 0
    79.     If MsgBox("Open Notepad", vbOKCancel) = vbCancel Then Exit Sub
    80.     hWndNotepad = FindWindow(vbNullString, appCaption)
    81. Wend
    82.  
    83. 'Get handle to Notepad's main menu
    84. hWndMenu = GetMenu(hWndNotepad)
    85.  
    86. 'Get handle to 'File' submenu
    87. hWndSubMenu = GetSubMenu(hWndMenu, 0)
    88.  
    89. 'Get number of items in sub menu
    90. count = GetMenuItemCount(hWndSubMenu)
    91.  
    92. 'Setup data structure for InsertMenuItem call
    93.     With mii
    94.         .cbSize = Len(mii)
    95.         .fMask = MIIM_STATE Or MIIM_ID Or MIIM_STRING Or MIIM_FTYPE
    96.         .fType = MFT_STRING
    97.         .fState = MFS_ENABLED
    98.         .wID = MENUID 'our unique identifier
    99.         .dwTypeData = "My New Menu"
    100.         .cch = Len(.dwTypeData)
    101.     End With
    102.    
    103.     ' Add this to the menu.
    104.     If InsertMenuItemA(hWndSubMenu, count + 1, 1, mii) <> 0 Then
    105.         MsgBox "Menu Created"
    106.     Else: MsgBox "Menu Creation Failed"
    107.     End If
    108.     Call DrawMenuBar(hWndNotepad)
    109.    
    110. End Sub
    Last edited by Hack; Oct 10th, 2005 at 08:00 AM.

  21. #21

    Thread Starter
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Adding submenus to external programs

    Sugar,

    Please go back and edit your post. place vbcode tags around your code to make it easier for me to read. such as:

    [VBCODE] your code goes here [/VBCODE]

    Next, I would go through the documentation for all the API calls you made and see if they are supported under Win95. You can find an alphabetical list of all the functions at
    http://msdn.microsoft.com/library/de...ical_order.asp

    After doing these two things if you still have a question let me know and I'll be glad to help.

  22. #22
    No place like 127.0.0.1 eyeRmonkey's Avatar
    Join Date
    Jul 2005
    Location
    Blissful Oblivion
    Posts
    2,306

    Re: Adding submenus to external programs

    Welcome to the forums sugarflux!

    Please edit your reply and add [vbcode] [/vbcode] around your code. It makes it a lot easier to read. Thanks.

    EDIT: Oops, double posted ontop of you moeur.
    Last edited by eyeRmonkey; Jul 21st, 2005 at 11:19 AM.
    Visual Studio 2005 Professional Edition (.NET Framework 2.0)
    ~ VB .NET Links: Visual Basic 6 to .NET Function Equivalents (Thread) | Refactor! (White Paper) | Easy Control for Wizard Forms | Making A Proper UI For WinForms | Graphics & GDI+ Tutorial | Websites For Free Icons
    ~ QUOTE: Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. -Rich Cook

    ~ eyeRmonkey.com

  23. #23
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Adding submenus to external programs

    Added the code tags.

  24. #24
    New Member
    Join Date
    Oct 2005
    Posts
    3

    Unhappy Re: Adding submenus to external programs

    I have tried the code , it works fine with notepad ,wordpad etc. However I cannot get it work with Excel , Winword. Those applications use floating menu bars.

    Getmenu function says "GetMenu does not work on floating menu bars. Floating menu bars are custom controls that mimic standard menus; they are not menus. To get the handle for a floating menu bar, use the Active Accessibility APIs."

    It also does not work with VBasic IDE. I have checked the floating menu bar has a class name of MsoCommandBar and its parent is MsoCommandBarDock.

    Any idea how to get menus from floating menu bars? Thanks...

  25. #25

    Thread Starter
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Adding submenus to external programs

    Quote Originally Posted by cssriraman
    I just see your thread Adding submenus to external programs. It is excellant code.

    I need small help from you.

    1. In that thread you added a menu in File menu of Notepad. How can I add a menu in Edit Menu of Notepad.

    2. I just want to click/executre the File -> Open menu in Notepad.

    Please help me!

    Thanks in advance.

    CS.
    CS,

    I don't like to answer these things in PM so I'm posting your question here so others can benefit.

    To change the code sot that the new menu item appears under the Edit menu rather than the File menu simply change this line
    VB Code:
    1. hWndSubMenu = GetSubMenu(hWndMenu, 1) 'use 0 for file menu and 1 for edit menu
    I hope this answers your question.

  26. #26
    Frenzied Member cssriraman's Avatar
    Join Date
    Jun 2005
    Posts
    1,465

    Re: Adding submenus to external programs

    Thanks,

    How can I click the File -> Open menu?

    Thanks in advance,
    CS

  27. #27

    Thread Starter
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Adding submenus to external programs

    try this
    VB Code:
    1. Option Explicit
    2.  
    3. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _
    4.     ByVal lpClassName As String, _
    5.     ByVal lpWindowName As String _
    6. ) As Long
    7.  
    8. Private Declare Function SetForegroundWindow Lib "user32" ( _
    9.     ByVal hwnd As Long _
    10. ) As Long
    11.  
    12. Private Sub Command1_Click()
    13. Dim hWndNotepad As Long
    14. Dim appCaption As String
    15. Dim appClass As String
    16.  
    17. 'Get a handle to Notepad
    18. appCaption = "Untitled - Notepad"
    19. appClass = "Notepad"
    20. hWndNotepad = FindWindow(appClass, vbNullString)
    21. If hWndNotepad = 0 Then
    22.     If MsgBox("Open Notepad?", vbOKCancel) = vbCancel Then Exit Sub
    23.     Shell "Notepad.exe"
    24.     While hWndNotepad = 0
    25.         hWndNotepad = FindWindow(vbNullString, appCaption)
    26.         DoEvents
    27.     Wend
    28. End If
    29.  
    30. 'make it the active window
    31. If SetForegroundWindow(hWndNotepad) = 0 Then
    32.     MsgBox "SetForegroundWindow failed"
    33.     Exit Sub
    34. End If
    35.  
    36. SendKeys "%fo"
    37.  
    38. End Sub

  28. #28
    Frenzied Member cssriraman's Avatar
    Join Date
    Jun 2005
    Posts
    1,465

    Re: Adding submenus to external programs

    Thanks! Is there any way without using sendkeys?

    because, sendkeys are not working sometimes.
    CS

  29. #29

    Thread Starter
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Adding submenus to external programs

    is the problem that there is no keyboard shortcut for the menu?

  30. #30
    Frenzied Member cssriraman's Avatar
    Join Date
    Jun 2005
    Posts
    1,465

    Re: Adding submenus to external programs

    Yes. I cannot use shortcut keys as you said for a software. Using mouse only I can use that software. With notepad no issues.
    CS

  31. #31
    Addicted Member thamizhinpan's Avatar
    Join Date
    Dec 2005
    Location
    TE
    Posts
    243

    Re: Adding submenus to external programs

    Quote Originally Posted by moeur
    This code relies on a related thread, Subclass External Programs done for you. Download that hook control and dll.

    This example adds a menu item under the file menu item in the Notepad application. It then waits for a user to click the new menu item and responds with our own messagebox.

    Open a new project, add a command button and a hookcontrol to the form. Rename the hookcontrol to Hook.
    Can you explain what is the hookcontrol
    If above question or answer will help to you
    Don't forget to rate me
    தமிழ்இன்பன்

  32. #32

    Thread Starter
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Adding submenus to external programs

    Did you read the thread I referred to? It is very in depth.

  33. #33
    Frenzied Member cssriraman's Avatar
    Join Date
    Jun 2005
    Posts
    1,465

    Re: Adding submenus to external programs

    Quote Originally Posted by cssriraman
    Thanks,

    How can I click the File -> Open menu?

    Thanks in advance,
    Can someone help me on that.

    I would like to achieve that without using sendkeys.
    CS

  34. #34

    Thread Starter
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Adding submenus to external programs

    Please post this question as a new thread in the regular forums not here.

  35. #35
    Frenzied Member cssriraman's Avatar
    Join Date
    Jun 2005
    Posts
    1,465

    Re: Adding submenus to external programs

    Thanks for the update.
    CS

  36. #36
    Hyperactive Member Private_sub's Avatar
    Join Date
    Nov 2005
    Location
    +31
    Posts
    368

    Re: Adding submenus to external programs

    Hi!
    Maybe a stupid question, but how do I "install" the DLL?
    Because it gives this error:
    File not found: MainHook.Dll

    Thanx

  37. #37

    Thread Starter
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Adding submenus to external programs

    put it in your Windows system32 directory or in the executable directory

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width