# Ruby win32api call getMenuItemInfo

**URL:** <https://www.ruby-forum.com/t/ruby-win32api-call-getmenuiteminfo/159635>\
**Category:** Ruby\
**Created:** [February 6, 2009, 3:34pm UTC](https://www.ruby-forum.com/t/ruby-win32api-call-getmenuiteminfo/159635 "2009-02-06T15:34:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![battreal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/a9a28c/32.png) [@battreal](https://www.ruby-forum.com/u/battreal)\
**Post date:** [February 6, 2009, 3:34pm UTC](https://www.ruby-forum.com/t/ruby-win32api-call-getmenuiteminfo/159635/1 "2009-02-06T15:34:23Z")

</div>

Hi all,

I have successfully managed to implement the following apis

findWindow=Win32API.new(“user32.dll”, “FindWindow”, [‘P’,‘P’], ‘N’)  
sendMessage=Win32API.new(“user32.dll”, “SendMessage”,[‘N’,‘N’,‘N’,‘P’],  
‘N’)  
getMenu=Win32API.new(“user32.dll”, “GetMenu”, [‘N’], ‘N’)  
getMenuItemCount=Win32API.new(“user32.dll”, “GetMenuItemCount”,[‘N’],  
‘N’)  
getSubMenu=Win32API.new(“user32.dll”, “GetSubMenu”, [‘N’,‘N’], ‘N’)  
deleteMenu=Win32API.new(“user32.dll”, “DeleteMenu”, [‘N’,‘N’,‘N’,],‘N’)  
drawMenuBar=Win32API.new(“user32.dll”, “DrawMenuBar”, [‘N’], ‘N’)  
setWindowLong=Win32API.new(“user32.dll”, “SetWindowLong”,[‘N’,‘N’,‘N’],  
‘N’)

but am unable to get getMenuItemInfo to work, this is because it takes a  
type structure and boolean as parameters and i can’t figure it out…

this is what i have

getMenuItemInfo =Win32API.new(“user32.dll”, “GetMenuItemInfo”,  
[‘L’,‘L’,‘NEED’,‘NEED’], ‘L’)

the api is as follows…

BOOL GetMenuItemInfo(  
HMENU hMenu,  
UINT uItem,  
BOOL fByPosition,  
LPMENUITEMINFO lpmii  
);

typedef struct tagMENUITEMINFO {  
UINT cbSize;  
UINT fMask;  
UINT fType;  
UINT fState;  
UINT wID;  
HMENU hSubMenu;  
HBITMAP hbmpChecked;  
HBITMAP hbmpUnchecked;  
ULONG\_PTR dwItemData;  
LPTSTR dwTypeData;  
UINT cch;  
HBITMAP hbmpItem;  
} MENUITEMINFO, \*LPMENUITEMINFO;

any help greatly appreciated…

Thanks

Ted

---

<div class="post-metadata">

**Author:** ![battreal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/a9a28c/32.png) [@battreal](https://www.ruby-forum.com/u/battreal)\
**Post date:** [March 10, 2009, 4:40am UTC](https://www.ruby-forum.com/t/ruby-win32api-call-getmenuiteminfo/159635/2 "2009-03-10T04:40:43Z")

</div>

Ted Baker wrote:

> Hi all,
> 
> I have successfully managed to implement the following apis
> 
> findWindow=Win32API.new(“user32.dll”, “FindWindow”, [‘P’,‘P’], ‘N’)  
> sendMessage=Win32API.new(“user32.dll”,  
> “SendMessage”,[‘N’,‘N’,‘N’,‘P’],  
> ‘N’)  
> getMenu=Win32API.new(“user32.dll”, “GetMenu”, [‘N’], ‘N’)  
> getMenuItemCount=Win32API.new(“user32.dll”, “GetMenuItemCount”,[‘N’],  
> ‘N’)  
> getSubMenu=Win32API.new(“user32.dll”, “GetSubMenu”, [‘N’,‘N’], ‘N’)  
> deleteMenu=Win32API.new(“user32.dll”, “DeleteMenu”,  
> [‘N’,‘N’,‘N’,],‘N’)  
> drawMenuBar=Win32API.new(“user32.dll”, “DrawMenuBar”, [‘N’], ‘N’)  
> setWindowLong=Win32API.new(“user32.dll”,  
> “SetWindowLong”,[‘N’,‘N’,‘N’],  
> ‘N’)
> 
> but am unable to get getMenuItemInfo to work, this is because it  
> takes a  
> type structure and boolean as parameters and i can’t figure it out…
> 
> this is what i have
> 
> getMenuItemInfo =Win32API.new(“user32.dll”, “GetMenuItemInfo”,  
> [‘L’,‘L’,‘NEED’,‘NEED’], ‘L’)
> 
> the api is as follows…
> 
> BOOL GetMenuItemInfo(  
> HMENU hMenu,  
> UINT uItem,  
> BOOL fByPosition,  
> LPMENUITEMINFO lpmii  
> );
> 
> typedef struct tagMENUITEMINFO {  
> UINT cbSize;  
> UINT fMask;  
> UINT fType;  
> UINT fState;  
> UINT wID;  
> HMENU hSubMenu;  
> HBITMAP hbmpChecked;  
> HBITMAP hbmpUnchecked;  
> ULONG\_PTR dwItemData;  
> LPTSTR dwTypeData;  
> UINT cch;  
> HBITMAP hbmpItem;  
> } MENUITEMINFO, \*LPMENUITEMINFO;
> 
> any help greatly appreciated…
> 
> Thanks
> 
> Ted

Very late reply.

You should have been directed towards Ruby/DL in the  
standard library.

This is now preferred to Win32API which is in the process  
of being obsoleted.

[http://www.jbrowse.com/text/rdl\_en.html](http://www.jbrowse.com/text/rdl_en.html)

daz
