[python-win32] Using win32 Function GetMenuItemInfo

Fabricio Guzman fguzman_slotown at yahoo.com
Sat Aug 21 01:11:39 CEST 2004


Henrik,

I tried using the built-in buffer function:
>>> buff = 'MyString'
>>> buff = buffer(buff)
>>> win32gui.GetMenuItemInfo(131917, 0, 57600, buff)

and received the following error:
>>> TypeError: buffer is read-only

According to the documentation on buffer(), the
function only exists for backward compatability.  I
can't find any other built-in buffer function. How are
buffers created with modern python?

Thanks for all the help
-Fabricio 

--- "Weber, Henrik" <henrik.weber at sdm.de> wrote:

> > Caution: I'm as newbeeish as they come, read at
> your
> > own risk :-)
> >
> > I'm trying to use the win32 function
> GetMenuItemInfo. 
> > How do I set up the fourth argument in this
> function. 
> > The documentation says the fourth argument should
> be
> > "A string or buffer in the format of a
> MENUITEMINFO
> > structure."
> >
> > I don't know what this means.  Here's what I've
> tried
> > to no avail:
> > buff = 'MyString'
> > win32gui.GetMenuItemInfo(131917, 0, 57600, buff)
> >
> > This gives me the following error message:
> > TypeError: Cannot use string as modifiable buffer
> 
> Well, in Python strings are immutable, so you cannot
> use a string if you want to write something into it.
> Also, if it wants a MENUITEMINFO structure, you need
> to supply something that has the size of that
> structure. You could use a buffer (create with the
> buffer built-in function) or maybe an array. After
> calling GetMenuItemInfo you can unpack the result
> with the struct module.
> 
> You can find a description of the structure at
>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/WinUI/WindowsUserInterface/Resources/Menus/MenuReference/MenuStructures/MENUITEMINFO.asp
> 
> If you are trying to extract a string from a menu
> item, see what the description says about the
> dwTypeData member. You'll have to play around with
> pointers a bit. Maybe the ctypes module can help you
> out there.
> 
> Have fun!
> --
> Henrik
> _______________________________________________
> Python-win32 mailing list
> Python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32
> 



		
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!
http://promotions.yahoo.com/new_mail 


More information about the Python-win32 mailing list