Results 1 to 7 of 7

Thread: Why is this not working? (GetSubMenu)

Threaded View

  1. #1

    Thread Starter
    PowerPoster VBDT's Avatar
    Join Date
    Sep 2005
    Location
    CA - USA
    Posts
    2,922

    Question Why is this not working? (GetSubMenu)

    Hi guys, I want to be able to get the menu and its submenu rectangles. I tried the code below but without success. I use “WindowFromPoint” to get the handle of the window that the mouse is on and use the “GetSubMenu” function to get the menu’s activated submenu. I successfully can retrieve the menu handle by using “WidowFromPoint” but the “GetSubMenu” function returns zero. Can some one take a look on this and tell what I am doing wrong. Thanks in advance.
    vb Code:
    1. Imports System.runtime.InteropServices
    2.  
    3. Public Class Form1
    4.  
    5.     Declare Function GetSubMenu Lib "user32" Alias "GetSubMenu" (ByVal hMenu As IntPtr, ByVal nPos As Integer) As IntPtr
    6.  
    7.     <DllImport("user32", EntryPoint:="WindowFromPoint")> _
    8.         Public Shared Function WindowFromPoint(ByVal xPoint As Integer, _
    9.         ByVal yPoint As Integer) As IntPtr
    10.     End Function
    11.  
    12.    End Class
    I call the functions in the keydown event.
    vb Code:
    1. Dim hwind As IntPtr = WindowFromPoint(Control.MousePosition.X, Control.MousePosition.Y) ' <-- returns the menu handl
    2. Console.WriteLine("Menu " & hwind.ToString)
    3. Dim hsubMenu As IntPtr = GetSubMenu(hwind, 0) ' <-- returns 0
    4. Console.WriteLine("SubMenu " & hsubMenu.ToString)

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