Esempio n. 1
0
    def _read_item(self):
        """Read the menu item info

        See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/resources/menus/menureference/menufunctions/getmenuiteminfo.asp
        for more information."""
        menu_info  = win32structures.MENUITEMINFOW()
        menu_info.cbSize = ctypes.sizeof (menu_info)
        menu_info.fMask = \
            win32defines.MIIM_CHECKMARKS | \
            win32defines.MIIM_ID | \
            win32defines.MIIM_STATE | \
            win32defines.MIIM_SUBMENU | \
            win32defines.MIIM_TYPE #| \
            #MIIM_FTYPE #| \
            #MIIM_STRING
            #MIIM_DATA | \

        ret = win32functions.GetMenuItemInfo (
            self.menu,
            self.index,
            True,
            ctypes.byref(menu_info))

        if not ret:
            raise ctypes.WinError()

        return menu_info
Esempio n. 2
0
    def Text(self):
        "Return the state of this menu item"

        info = self._read_item()
        # if there is text
        if info.cch:
            # allocate a buffer
            buffer_size = info.cch+1
            text = ctypes.create_unicode_buffer(buffer_size)

            # update the structure and get the text info
            info.dwTypeData = ctypes.addressof(text)
            info.cch = buffer_size

            win32functions.GetMenuItemInfo (
                self.menu,
                self.index,
                True,
                ctypes.byref(info))

            text = text.value
        else:
            text = ''

        return text