Hey,

I posted a question in api yesterday, but the one person that responded
didn't have the time to help much. This is a more simple version of the
same question. If I'm not suppose to ask basically the same question in
another forum, then let me know and I will remove it. This is really bugging
me!

Here we go...


mnuMain
....mnuOpen

In the code below, I can get the height of the main menu, and the
.left position of the text. If you click on mnuMain, the first item is
mnuOpen. Here's the question...

How can I retrieve the same information for mnuOpen as I did
for mnuMain?

VB Code:
  1. Private Type RECT
  2.         Left As Long
  3.         Top As Long
  4.         Right As Long
  5.         Bottom As Long
  6. End Type
  7.  
  8. Private Type DRAWITEMSTRUCT
  9.         CtlType As Long
  10.         CtlID As Long
  11.         itemID As Long
  12.         itemAction As Long
  13.         itemState As Long
  14.         hwndItem As Long
  15.         hdc As Long
  16.         rcItem As RECT
  17.         itemData As Long
  18. End Type
  19.  
  20. Private Declare Function ModifyMenu Lib "user32" Alias "ModifyMenuA" _
  21. (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long, _
  22. ByVal wIDNewItem As Long, ByVal lpString As Any) As Long
  23. Private Declare Function GetMenu Lib "user32" (ByVal Hwnd As Long) As Long
  24. Private Declare Function GetMenuItemID Lib "user32" (ByVal hMenu As Long, _
  25. ByVal nPos As Long) As Long
  26. Private Declare Function GetSubMenu Lib "user32" (ByVal hMenu As Long, _
  27. ByVal nPos As Long) As Long
  28. Private Declare Function GetMenuItemRect Lib "user32" (ByVal Hwnd As Long, _
  29. ByVal hMenu As Long, ByVal uItem As Long, lprcItem As RECT) As Long
  30.  
  31. Private Sub Form_Load()
  32.     Dim lngMenu As Long
  33.     Dim lngSubMenu As Long
  34.     Dim rcItem As RECT
  35.    
  36.     'get menu handle
  37.     lngMenu = GetMenu(Me.Hwnd)
  38.    
  39.     'get rectangle for the first item of the menu
  40.     Call GetMenuItemRect(Me.Hwnd, lngMenu, 0, rcItem)
  41.  
  42.     'height of first item in pixels
  43.     Label1.Caption = rcItem.Bottom - rcItem.Top
  44.     Label2.Caption = rcItem.Left
  45. End Sub

Thanks in advance,
Ron