Esempio n. 1
0
 def enable(self, val=True):
     tbbi = TBBUTTONINFO()
     tbbi.cbSize = sizeof(tbbi)
     tbbi.dwMask = TBIF_STATE | 0x80000000
     if val:
         tbbi.fsState = TBSTATE_ENABLED
     else:
         tbbi.fsState = TBSTATE_INDETERMINATE
     SendMessage(self.cb_hWnd, WM_USER + 64, self.index, byref(tbbi))
Esempio n. 2
0
    def __create_menubar(self, action, menu, has_sip):
        mbi = SHMENUBARINFO()
        mbi.cbSize = sizeof(SHMENUBARINFO)
        mbi.hwndParent = self._w32_hWnd
        mbi.hInstRes = GetModuleHandle(0)

        slots = []

        empty = True
        has_action = False
        has_menu = False

        if (action is None) and (menu is None):
            mbi.dwFlags = SHCMBF_EMPTYBAR

        else:
            empty = False
            temp_menu = Menu()
            i = 0
            if action is not None:
                label, cb = action
                action_item = temp_menu.append(label, callback=cb)
                #self.action = CommandBarAction(item, 0)
            else:
                action_item = temp_menu.append("", enabled=False)

            if menu is not None:
                sub_menu = PopupMenu()
                temp_menu.append_menu(menu, sub_menu)
                has_menu = True

            mbi.dwFlags = SHCMBF_HMENU
            mbi.nToolBarId = temp_menu._hmenu

        if not has_sip:
            mbi.dwFlags |= SHCMBF_HIDESIPBUTTON
        SHCreateMenuBar(byref(mbi))
        self._mb_hWnd = mbi.hwndMB

        if not empty:
            self.cb_action = CommandBarAction(mbi.hwndMB, 0, action_item)

            if has_menu:
                tbbi = TBBUTTONINFO()
                tbbi.cbSize = sizeof(tbbi)
                tbbi.dwMask = 0x10 | 0x80000000
                SendMessage(mbi.hwndMB, WM_USER + 63, 1, byref(tbbi))
                hMenu = tbbi.lParam
                self.cb_menu = CommandBarMenu(mbi.hwndMB, 0, hMenu)

        rc = RECT()
        GetWindowRect(self._w32_hWnd, byref(rc))
        rcmb = RECT()
        GetWindowRect(self._mb_hWnd, byref(rcmb))
        rc.bottom -= (rcmb.bottom - rcmb.top)
        self.move(rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top)
Esempio n. 3
0
 def set_text(self, txt):
     tbbi = TBBUTTONINFO()
     tbbi.cbSize = sizeof(tbbi)
     tbbi.dwMask = TBIF_TEXT | 0x80000000
     tbbi.pszText = unicode(txt)
     SendMessage(self.cb_hWnd, WM_USER + 64, self.index, byref(tbbi))