|
-
Oct 7th, 2005, 08:10 AM
#1
Thread Starter
Addicted Member
A sub menu problem
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:
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Type DRAWITEMSTRUCT
CtlType As Long
CtlID As Long
itemID As Long
itemAction As Long
itemState As Long
hwndItem As Long
hdc As Long
rcItem As RECT
itemData As Long
End Type
Private Declare Function ModifyMenu Lib "user32" Alias "ModifyMenuA" _
(ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long, _
ByVal wIDNewItem As Long, ByVal lpString As Any) As Long
Private Declare Function GetMenu Lib "user32" (ByVal Hwnd As Long) As Long
Private Declare Function GetMenuItemID Lib "user32" (ByVal hMenu As Long, _
ByVal nPos As Long) As Long
Private Declare Function GetSubMenu Lib "user32" (ByVal hMenu As Long, _
ByVal nPos As Long) As Long
Private Declare Function GetMenuItemRect Lib "user32" (ByVal Hwnd As Long, _
ByVal hMenu As Long, ByVal uItem As Long, lprcItem As RECT) As Long
Private Sub Form_Load()
Dim lngMenu As Long
Dim lngSubMenu As Long
Dim rcItem As RECT
'get menu handle
lngMenu = GetMenu(Me.Hwnd)
'get rectangle for the first item of the menu
Call GetMenuItemRect(Me.Hwnd, lngMenu, 0, rcItem)
'height of first item in pixels
Label1.Caption = rcItem.Bottom - rcItem.Top
Label2.Caption = rcItem.Left
End Sub
Thanks in advance,
Ron
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|