def Tile(self, flag='vertical'): if flag=='vertical': flag= 0 # MDITILE_VERTICAL if flag=='horizontal': flag= 1 # MDITILE_HORIZONTAL #elif flag=='zorder': flag= 4 # MDITILE_ZORDER ## ?? WM_MDITILE = 550 if not user32.SendMessageA(self.Hwnd, WM_MDITILE, flag, 0): raise "could not tile windows"
def PressButton(self, button): if self.Hwnd: try: iButton = PROP_BUTTONS.index(button) except: raise ValueError, "invalid burron: %s" % button user32.SendMessageA(self.Hwnd, PSM_PRESSBUTTON, iButton, 0)
def RemovePage(self, i): if self.Hwnd: user32.SendMessageA(self.Hwnd, PSM_REMOVEPAGE, i, 0) try: del self._client_pages[i] except: raise ValueError, "no such page: %s" % i
def GetTabControl(self): if self.Hwnd: result = user32.SendMessageA(self.Hwnd, PSM_GETTABCONTROL, 0, 0) if result: from wnd.controls import tab t = tab.TabFromHandle(result) fw.SetFlagMsgReflect(t, False) return t
def SetSelection(self, pIdlOrPath): if not self.Hwnd: raise "dialog box is not running" if isinstance(pIdlOrPath, (str, unicode)): p=create_string_buffer(pIdlOrPath) flag=1 else: p=byref(pIdlOrPath) flag=0 user32.SendMessageA(self.Hwnd, BFFM_SETSELECTIONA , flag, p)
def AddPage(self, dlg, *flags, **kwargs): ## the propsheet takes care about the handle of the page if self.Hwnd: self._client_page(dlg, *flags, **kwargs) hPage = comctl32.CreatePropertySheetPage( byref(self._client_pages[-1])) if hPage: user32.SendMessageA(self.Hwnd, PSM_ADDPAGE, 0, hPage) return True return False
def IsDialogReflectMessage(hwnd, msg, wp, lp, dlgmode): #print dlgmode ## TODO: test ## filter WM_COMMAND for dialog boxes if msg == 273: # WM_COMMAND #print wp, lp if lp: if dlgmode == 'modeless': return ReflectMessage(hwnd, lp, msg, wp, lp) if lp != 1: # IDOK if lp != 2: # IDCANCEL #DM_GETDEFID = WM_USER + 0 result = user32.SendMessageA(hwnd, 1024, 0, 0) if HIWORD(result) == 21323: # DC_HASDEFID defID = user32.GetDlgItem(hwnd, LOWORD(result)) if defID != lp: return ReflectMessage(hwnd, lp, msg, wp, lp) else: return ReflectMessage(hwnd, lp, msg, wp, lp) elif msg == 276: # WM_HSCROLL if lp: return ReflectMessage(hwnd, lp, msg, wp, lp) elif msg == 277: # WM_VSCROLL if lp: return ReflectMessage(hwnd, lp, msg, wp, lp) elif msg == 78: # WM_NOTIFY nm = NMHDR.from_address(lp) return ReflectMessage(hwnd, nm.hwndFrom, msg, wp, lp) elif msg == 43: # WM_DRAWITEM # NOTE # can not reflect to comboboxes (ODT_COMBOBOX) # they do block all messages here # ?? do it anyway return ReflectMessage(hwnd, user32.GetDlgItem(hwnd, wp), msg, wp, lp) elif msg == 44: # WM_MEASUREITEN # NOTE # can not reflect to comboboxes (ODT_COMBOBOX) # they do block all messages here # ?? do it anyway return ReflectMessage(hwnd, user32.GetDlgItem(hwnd, wp), msg, wp, lp) return None
def Destroy(self): """Destroys the accelerator table.""" if self.handle: if self._client_hwndParent: mn= WND_MENU(self.handle, fw.MNUT_ACCEL, fw.MNUF_REMOVE) user32.SendMessageA(self._client_hwndParent, fw.WND_WM_NOTIFY, fw.WND_NM_MENU, byref(nm)) TrackHandler.Unregister('acceleratortables', self.handle) if not user32.DestroyAcceleratorTable(self.handle): raise RuntimeError("could not destroy accelerator table") self.handle = 0 self._client_hwndParent = None
def IconArrange(self): user32.SendMessageA(self.Hwnd, WM_MDIICONARRANGE, 0, 0)
def SetTitle(self, title, proptitle=False): #PSH_PROPTITLE = 0x00000001 if self.Hwnd: user32.SendMessageA(self.Hwnd, PSM_SETTITLE, proptitle and 1 or 0, title)
def Cascade(self, skipdisabled=True): if skipdisabled: flag= 2 # MDITILE_SKIPDISABLED else: flag= 0 WM_MDICASCADE = 551 if not user32.SendMessageA(self.Hwnd, WM_MDICASCADE, flag, 0): raise "could not cascade windows"
def IsMaximized(self, hwnd): b= BOOL() user32.SendMessageA(self.Hwnd, WM_MDIGETACTIVE, 0, byref(b)) return bool(b.value)
def Restore(self, hwnd): user32.SendMessageA(self.Hwnd, WM_MDIRESTORE, hwnd, 0)
def SelectHwnd(self, hwnd): if self.Hwnd: return bool(user32.SendMessageA(self.Hwnd, PSM_SETCURSEL, 0, hwnd))
def Maximize(self, hwnd): user32.SendMessageA(self.Hwnd, WM_MDIMAXIMIZE, hwnd, 0)
def Reboot(self): if self.Hwnd: user32.SendMessageA(self.Hwnd, PSM_REBOOTSYSTEM, 0, 0) self._client_fReboot = 'reboot'
def ActivatePrevious(self, hwnd=None): user32.SendMessageA(self.Hwnd, WM_MDINEXT, hwnd and hwnd or 0, 1)
def CopyData(hwndSource, hwndDest, lp, data, reserved=0): p = create_string_buffer(SZ_GUID_COPYDATA + data) ## do not include NULL byte in cbData cd = COPYDATASTRUCT(MAKELONG(lp, reserved), sizeof(p) - 1, addressof(p)) return bool( user32.SendMessageA(hwndDest, WM_COPYDATA, hwndSource, byref(cd)))
def Restart(self): if self.Hwnd: user32.SendMessageA(self.Hwnd, PSM_RESTARTWINDOWS, 0, 0) self._client_fReboot = 'restart'
def QuerySiblings(self, param1, param2): result = user32.SendMessageA(self.Hwnd, PSM_QUERYSIBLINGS, param1, param2)
def SetFinishText(self, text): if self.Hwnd: user32.SendMessageA(self.Hwnd, PSM_SETFINISHTEXT, 0, text)
def GetCurrentPage(self): if self.Hwnd: return user32.SendMessageA(self.Hwnd, PSM_GETCURRENTPAGEHWND, 0, 0)
def ReflectMessage(hwnd, hwndTo, msg, wp, lp): msgr = WND_MSGREFLECT(hwnd, msg, wp, lp) result = user32.SendMessageA(hwndTo, WND_WM_NOTIFY, WND_NM_MSGREFLECT, addressof(msgr)) if msgr.fReturn: return result
def Destroy(self, hwnd): user32.SendMessageA(self.Hwnd, WM_MDIDESTROY, hwnd, 0)
def Activate(self, hwnd): return user32.SendMessageA(self.Hwnd, WM_MDIACTIVATE, hwnd, 0)
def Select(self, i): if self.Hwnd: return bool(user32.SendMessageA(self.Hwnd, PSM_SETCURSEL, i, 0))
def EnableOK(self): """Enables the OK button""" if not self.Hwnd: raise "dialog box is not running" user32.SendMessageA(self.Hwnd, BFFM_ENABLEOK , 0, 1)
def GetActive(self): return user32.SendMessageA(self.Hwnd, WM_MDIGETACTIVE, 0, 0)
def SetStatusText(self, text): """Sets the status text.""" if not self.Hwnd: raise "dialog box is not running" p=create_string_buffer(text) user32.SendMessageA(self.Hwnd, BFFM_SETSTATUSTEXTA, 0, p)
def ActivateNext(self, hwnd=None): user32.SendMessageA(self.Hwnd, WM_MDINEXT, hwnd and hwnd or 0, 0)