Example #1
0
 def _register_class(self):
     if _verbose: log('Application._register_class:start',str(self))
     class WNDCLASS(structob.struct_object):
         oracle = structob.Oracle (
             'window class information',
             'Nllllllllll',
             ('style',
              'lpfnWndProc',
              'cls_extra',
              'wnd_extra',
              'hInst',
              'hIcon',
              'hCursor',
              'hbrBackground',
              'menu_name',
              'lpzClassName',
              )
             )
     self._class_name = windll.cstring("dw.anygui.PythonWindow")
     self.__wndproc = gencb.generated_callback('llll',self._wndproc)
     # register a window class for our windows.
     wc = WNDCLASS()
     wc.hbrBackground = COLOR_BTNFACE + 1
     wc.hCursor = user32.LoadCursor(0, IDC_ARROW)
     wc.hIcon = user32.LoadIcon(0, IDI_APPLICATION)
     wc.lpzClassName = self._class_name.address()
     wc.lpfnWndProc = self.__wndproc.address
     wc.hInst = kernel32.GetModuleHandle(0)
     self._wc = wc
     user32.UnregisterClass(wc.lpzClassName,0)
     self.__class__._wndclass = user32.RegisterClass(wc)
     assert self.__class__._wndclass, "RegisterClass --> %d=%s ie\n%s" % (GetLastError(), hex(GetLastError()), _lastErrorMessage())
     if _verbose: log('Application._register_class:end',str(self))
Example #2
0
 def _register_class(self):
     if _verbose: log('Application._register_class:start',str(self))
     class WNDCLASS(structob.struct_object):
         oracle = structob.Oracle (
             'window class information',
             'Nllllllllll',
             ('style',
              'lpfnWndProc',
              'cls_extra',
              'wnd_extra',
              'hInst',
              'hIcon',
              'hCursor',
              'hbrBackground',
              'menu_name',
              'lpzClassName',
              )
             )
     self._class_name = windll.cstring("dw.manygui.PythonWindow")
     self.__wndproc = gencb.generated_callback('llll',self._wndproc)
     # register a window class for our windows.
     wc = WNDCLASS()
     wc.hbrBackground = COLOR_BTNFACE + 1
     wc.hCursor = user32.LoadCursor(0, IDC_ARROW)
     wc.hIcon = user32.LoadIcon(0, IDI_APPLICATION)
     wc.lpzClassName = self._class_name.address()
     wc.lpfnWndProc = self.__wndproc.address
     wc.hInst = kernel32.GetModuleHandle(0)
     self._wc = wc
     user32.UnregisterClass(wc.lpzClassName,0)
     self.__class__._wndclass = user32.RegisterClass(wc)
     assert self.__class__._wndclass, "RegisterClass --> %d=%s ie\n%s" % (GetLastError(), hex(GetLastError()), _lastErrorMessage())
     if _verbose: log('Application._register_class:end',str(self))
Example #3
0
 def widgetFactory(self,*args,**kws):
     app = application()
     if self.proxy.container and hasattr(self.proxy.container,'wrapper'):
         parent = self.proxy.container.wrapper.widget
     else:
         parent = 0
     t = self._wndclass
     if t is None:
         self._i_wndclass = 0
     elif type(t) is type(''):
         self._i_wndclass = windll.cstring(t)
     elif type(t) is type(0):
         self._i_wndclass = t
     widget = user32.CreateWindowEx(self._win_style_ex,
                                      self._i_wndclass,
                                      0,
                                      self._win_style,
                                      0,
                                      0,
                                      10,
                                      10,
                                      parent,
                                      0, # hMenu
                                      0, # hInstance
                                      0)
     app.widget_map[widget] = self
     return widget
Example #4
0
 def widgetFactory(self,*args,**kws):
     app = application()
     if self.proxy.container and hasattr(self.proxy.container,'wrapper'):
         parent = self.proxy.container.wrapper.widget
     else:
         parent = 0
     t = self._wndclass
     if t is None:
         self._i_wndclass = 0
     elif type(t) is type(''):
         self._i_wndclass = windll.cstring(t)
     elif type(t) is type(0):
         self._i_wndclass = t
     widget = user32.CreateWindowEx(self._win_style_ex,
                                      self._i_wndclass,
                                      0,
                                      self._win_style,
                                      0,
                                      0,
                                      10,
                                      10,
                                      parent,
                                      0, # hMenu
                                      0, # hInstance
                                      0)
     app.widget_map[widget] = self
     return widget
Example #5
0
 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 manygui.backends.dwgui import _lastErrorMessage 
             log(_lastErrorMessage())
Example #6
0
 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())
Example #7
0
def _lastErrorMessage(n=None):
    msg = windll.cstring('',512)
    kernel32.FormatMessageA(
            FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
            0,
            n is None and GetLastError() or n,
            0,
            msg.address(),
            len(msg)-1,
            0
            )
    return repr(msg)[1:-1]
Example #8
0
def _lastErrorMessage(n=None):
    msg = windll.cstring('',512)
    kernel32.FormatMessageA(
            FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
            0,
            n is None and GetLastError() or n,
            0,
            msg.address(),
            len(msg)-1,
            0
            )
    return repr(msg)[1:-1]
def setText(text):
    """\
Place string onto clipboard (CF_TEXT format)
	"""
    text = windll.cstring(text)
    hGlobalMemory = kernel32.GlobalAlloc(GHND, len(text) + 1)
    lpGlobalMemory = kernel32.GlobalLock(hGlobalMemory)
    lpGlobalMemory = kernel32.lstrcpy(lpGlobalMemory, text)
    kernel32.GlobalUnlock(hGlobalMemory)
    if user32.OpenClipboard(0):
        user32.EmptyClipboard()
        user32.SetClipboardData(CF_TEXT, hGlobalMemory)
        user32.CloseClipboard()
def setText(text):
	"""\
Place string onto clipboard (CF_TEXT format)
	"""
	text = windll.cstring(text)
	hGlobalMemory = kernel32.GlobalAlloc(GHND, len(text)+1)
	lpGlobalMemory = kernel32.GlobalLock(hGlobalMemory)
	lpGlobalMemory = kernel32.lstrcpy(lpGlobalMemory, text)
	kernel32.GlobalUnlock(hGlobalMemory)
	if user32.OpenClipboard(0):
		user32.EmptyClipboard()
		user32.SetClipboardData(CF_TEXT, hGlobalMemory)
		user32.CloseClipboard()
Example #11
0
 def setTitle(self,title):
     if self.widget and title:
         user32.SetWindowTextA(self.widget, windll.cstring(title))
Example #12
0
 def setItems(self,items):
     if not self.widget: return
     user32.SendMessage(self.widget, LB_RESETCONTENT, 0, 0)
     for item in map(str, list(items)):
         # FIXME: This doesn't work! Items get jumbled...
         user32.SendMessage(self.widget, LB_ADDSTRING, 0, windll.cstring(item))
Example #13
0
 def _getText(self):
     'return native text'
     n = user32.GetWindowTextLength(self.widget)
     t = windll.cstring('',n+1)
     r = user32.GetWindowText(self.widget,t.address(),n+1)
     return t.trunc()
Example #14
0
 def setText(self,text):
     if not self.widget: return
     if _verbose: log("%s.SetWindowText('%s'(%s)) hwnd=%s(%s) self=%s" % (self.__class__.__name__,text,type(text),self.widget,type(self.widget),self))
     user32.SetWindowTextA(self.widget,windll.cstring(_to_native(text)))
Example #15
0
 def setTitle(self,title):
     if self.widget and title:
         user32.SetWindowTextA(self.widget, windll.cstring(title))
Example #16
0
 def setItems(self,items):
     if not self.widget: return
     user32.SendMessage(self.widget, LB_RESETCONTENT, 0, 0)
     for item in map(str, list(items)):
         # FIXME: This doesn't work! Items get jumbled...
         user32.SendMessage(self.widget, LB_ADDSTRING, 0, windll.cstring(item))
Example #17
0
 def _getText(self):
     'return native text'
     n = user32.GetWindowTextLength(self.widget)
     t = windll.cstring('',n+1)
     r = user32.GetWindowText(self.widget,t.address(),n+1)
     return t.trunc()
Example #18
0
 def setText(self,text):
     if not self.widget: return
     if _verbose: log("%s.SetWindowText('%s'(%s)) hwnd=%s(%s) self=%s" % (self.__class__.__name__,text,type(text),self.widget,type(self.widget),self))
     user32.SetWindowTextA(self.widget,windll.cstring(_to_native(text)))