def _fn2handle(self,fn): if self.kind=='bitmap': try: self._handle = user32.LoadImage(0,windll.cstring(fn), IMAGE_BITMAP,0,0,LR_DEFAULTSIZE|LR_LOADFROMFILE) except: logTraceback(None) from anygui.backends.dwgui import _lastErrorMessage log(_lastErrorMessage())
def _wndproc(self, hwnd, msg, wParam, lParam): if _verbose: log("%s._wndproc called with %s,%s,%s,%s"%(self.__class__.__name__,hex(hwnd),hex(msg),hex(wParam),hex(lParam))) try: window = self.widget_map[hwnd] except: if _verbose: log("\tNO WINDOW TO DISPATCH???") return user32.DefWindowProc(hwnd, msg, wParam, lParam) try: _dispatch = self._dispatch.get(msg,_dispatch_DEFAULT) x = _dispatch(window,hwnd,msg,wParam,lParam) except: logTraceback(None,'_wndproc.1') if _verbose: log("\tdispatch %s to %s %s\n" % (_dispatch.__name__[9:],window.__class__.__name__,window),"\t ==>",x) return x
def _WM_COMMAND(self, hwnd, msg, wParam, lParam): if _verbose: log("ContainerMixin _WM_COMMAND called for %s"%self) # lParam: handle of control (or NULL, if not from a control) # HIWORD(wParam): notification code # LOWORD(wParam): id of menu item, control, or accelerator try: app = application() child_window = self.widget_map[lParam] except KeyError: if _verbose: log("NO SUCH CHILD WINDOW %s"%lParam) # we receive (when running test_textfield.py) # EN_CHANGE (0x300) and EN_UPDATE (0x400) notifications # here even before the call to CreateWindow returns. return -1 except: logTraceback(None) if _verbose: log("Dispatching to child %s"%child_window) return child_window._WM_COMMAND(hwnd, msg, wParam, lParam)
def getGeometry(self): if not self.widget: return 0,0,0,0 r = t_rect() user32.GetWindowRect(self.widget,r) l,t,r,b = r.rect w = r-l h = b-t if _verbose: log(str(self),'getGeometry',l,t,w,h) try: p = t_point() p.point = l,t user32.ScreenToClient(self.proxy.container.wrapper.widget,p) l,t = p.point if _verbose: log(' -->', l,t,w,h) except AttributeError: pass except: logTraceback(None) return l,t,w,h
def internalRun(self): if _verbose: log('internalRun:Begin',str(self)) class MSG(structob.struct_object): oracle = structob.Oracle ( 'windows message', 'Nlllllll', ('hwnd', 'message', 'wParam', 'lParam', 'time', 'x', 'y') ) msg = MSG() while user32.GetMessage(msg, 0, 0, 0): try: if _verbose: log('internalRun: loopstart',msg) user32.TranslateMessage(msg) user32.DispatchMessage(msg) if _verbose: log('internalRun: loopend') except: if _verbose: logTraceback(None) if _verbose: log('internalRun: finish')