Example #1
0
def ReadSnapshot(data):
    """extracts TBBUTTON and string array from the passed data."""

    error = True
    data = create_string_buffer(data)

    if len(data) > (len(SNAP_COOKIE) + 12):
        # test for cookie
        if data[:3] == SNAP_COOKIE:
            n = len(SNAP_COOKIE) + 1

            # version and sizeof
            ver = UINT.from_address(addressof(data) + n)
            n += 4
            szeof = UINT.from_address(addressof(data) + n)
            n += 4

            # get button array
            nButtons = UINT.from_address(addressof(data) + n)
            n += 4
            szeofBt = nButtons.value * sizeof(TBBUTTON)
            if len(data) > szeofBt + n:
                arrBt = (TBBUTTON * nButtons.value)()
                memmove(addressof(arrBt), addressof(data) + n, szeofBt)
                n += szeofBt

                # get text array
                cchText = UINT.from_address(int(addressof(data) + n))
                n += 4
                if len(data) == n + cchText.value + 1:
                    text = data[n:n + cchText.value]
                    error = False

    if error: raise ValueError("invalid data")
    return arrBt, text
Example #2
0
def ReadSnapshot(data):
	"""extracts TBBUTTON and string array from the passed data."""
		
	error = True
	data= create_string_buffer(data)
	
	if len(data) > (len(SNAP_COOKIE)+12):
		# test for cookie
		if data[:3]==SNAP_COOKIE:
			n= len(SNAP_COOKIE)+1
			
			# version and sizeof 
			ver= UINT.from_address(addressof(data)+n)
			n += 4
			szeof= UINT.from_address(addressof(data)+n)
			n += 4
			
			# get button array
			nButtons= UINT.from_address(addressof(data)+n)
			n += 4
			szeofBt= nButtons.value*sizeof(TBBUTTON)
			if len(data) > szeofBt+n:
				arrBt= (TBBUTTON*nButtons.value)()
				memmove(addressof(arrBt), addressof(data)+n, szeofBt)
				n+= szeofBt
				
				# get text array
				cchText= UINT.from_address(int(addressof(data)+n))
				n+= 4
				if len(data)== n + cchText.value+1:
					text= data[n:n+cchText.value]
					error= False
	
	if error: raise ValueError("invalid data")
	return arrBt, text
Example #3
0
 def __init__(self, cookie, buttons):
     self.cbSize = sizeof(self)
     self.type = cookie
     self.nButtons = len(self.arrButtons)
     self.arrButtons = buttons
     self.textBuffer = [
         None,
     ] * self.nButtons
Example #4
0
	def GetItemText(self, i):
		hd = HDITEM()
		hd.mask = hd.HDI_TEXT
		hd.pszText = addressof(self._client_buffer)
		hd.cchTextMax = sizeof(self._client_buffer)
		if self.SendMessage(self.Hwnd, self.Msg.HDM_GETITEM, i, byref(hd)):
			return self._client_buffer.value
		raise RuntimeError("could not retrive item text")
Example #5
0
	def GetItemText(self, i):
		tci = TCITEM()
		tci.mask = tci.TCIF_TEXT
		tci.pszText = addressof(self._client_buffer)
		tci.cchTextMax = sizeof(self._client_buffer)
		if not self.SendMessage(self.Hwnd, self.Msg.TCM_GETITEM, i, byref(tci)):
			raise RuntimeError("could not retrive text")
		return self._client_buffer.value
Example #6
0
	def _client_TruncText(self, text):
		"""Truncates text to _client_buffer. Return value is
		address of buffer."""
		n = len(text)
		szeof = sizeof(self._client_buffer) -1
		if n > szeof: text = '%s...\x00' % text[:szeof-3]
		else: text = '%s\x00' % text
		self._client_buffer.raw = text
		return addressof(self._client_buffer)			
Example #7
0
	def _client_TruncText(self, text):
		"""Truncates text to _client_buffer. Return value is
		the address of the buffer."""
		n = len(text)
		szeof = sizeof(self._client_buffer) -1
		if n > szeof: text = '%s...\x00' % text[:szeof-3]
		else: text = '%s\x00' % text
		self._client_buffer.raw = text
		return addressof(self._client_buffer)			
Example #8
0
	def GetBandTitle(self, ID):
		bi=REBARBANDINFO()
		bi.fMask = RBBIM_TEXT
		bi.lpText = addressof(self._client_buffer)
		bi.cch = sizeof(self._client_buffer) - 1
		if not self.SendMessage(self.Hwnd, self.Msg.RB_GETBANDINFO,
															self.IDToIndex(ID), byref(bi)):
			raise "could retrieve band title"
		return self._client_buffer.value
Example #9
0
	def SetImagelist(self, Imagelist):
		if Imagelist== None:
			handle= 0
		else:
			handle= Imagelist.handle
		
		rbi=REBARINFO(sizeof(REBARINFO), RBIM_IMAGELIST, handle)
		if not self.SendMessage(self.Hwnd, self.Msg.RB_SETBARINFO, 0, byref(rbi)):
				raise "could not set imagelist"
Example #10
0
 def GetBandTitle(self, ID):
     bi = REBARBANDINFO()
     bi.fMask = RBBIM_TEXT
     bi.lpText = addressof(self._client_buffer)
     bi.cch = sizeof(self._client_buffer) - 1
     if not self.SendMessage(self.Hwnd, self.Msg.RB_GETBANDINFO,
                             self.IDToIndex(ID), byref(bi)):
         raise "could retrieve band title"
     return self._client_buffer.value
Example #11
0
    def _client_TruncText(self, text):
        """Truncates text to _client_buffer. Return value is
		the address of the buffer."""
        text = text.replace('\t', " " * self._client_tabwidth)
        n = len(text)
        szeof = sizeof(self._client_buffer) - 1
        if n > szeof: text = '%s...\x00' % text[:szeof - 3]
        else: text = '%s\x00' % text
        self._client_buffer.raw = text + '\x00'
        return addressof(self._client_buffer)
Example #12
0
	def _client_TruncText(self, text):
		"""Truncates text to _client_buffer. Return value is
		the address of the buffer."""
		text= text.replace('\t', " "*self._client_tabwidth)
		n = len(text)
		szeof = sizeof(self._client_buffer) -1
		if n > szeof: text = '%s...\x00' % text[:szeof-3]
		else: text = '%s\x00' % text
		self._client_buffer.raw = text + '\x00'
		return addressof(self._client_buffer)			
Example #13
0
    def SetImagelist(self, Imagelist):
        if Imagelist == None:
            handle = 0
        else:
            handle = Imagelist.handle

        rbi = REBARINFO(sizeof(REBARINFO), RBIM_IMAGELIST, handle)
        if not self.SendMessage(self.Hwnd, self.Msg.RB_SETBARINFO, 0,
                                byref(rbi)):
            raise "could not set imagelist"
Example #14
0
	def GetEditControl(self, *flags):
		# get the editbox for the combo and subclass it
		p=create_string_buffer(5)
		flag= False
		for i in self.ChildWindows():
			if user32.GetParent(i)==self.Hwnd:
				user32.GetClassNameA(i, p, sizeof(p))
				if p.value.lower()=="edit":
					flag= True
					break
		if flag: 
			txt= TextinFromHandle(i, 'subclass', *flags)
			fw.SetFlagMsgReflect(txt, False)
			return txt
		
		raise RuntimeError("could not retrieve edit control")
Example #15
0
	def GetIconIndex(self, path, *flags):
		flag = 16384  # SHGFI_SYSICONINDEX
		for i in flags:
			try: flag |= FILEINFO_FLAGS[i]
			except: raise ValueError("invalid flag: %s" % i)
					
		fileattributes = 0
		if path[0]=='*':
			fileattributes = 128	# FILE_ATTRIBUTE_NORMAL
			flag |= 16					# SHGFI_USEFILEATTRIBUTES 
		
		if path=='directory':
			fileattributes = 16	# FILE_ATTRIBUTE_DIRECTORY
			flag |= 16				# SHGFI_USEFILEATTRIBUTES 
		
		fi = SHFILEINFO()
		if not shell32.SHGetFileInfoA(path, fileattributes, byref(fi), sizeof(SHFILEINFO), flag):
			raise RuntimeError("could not retrieve icon")
		return fi.iIcon
Example #16
0
    def GetIconIndex(self, path, *flags):
        flag = 16384  # SHGFI_SYSICONINDEX
        for i in flags:
            try:
                flag |= FILEINFO_FLAGS[i]
            except:
                raise ValueError("invalid flag: %s" % i)

        fileattributes = 0
        if path[0] == '*':
            fileattributes = 128  # FILE_ATTRIBUTE_NORMAL
            flag |= 16  # SHGFI_USEFILEATTRIBUTES

        if path == 'directory':
            fileattributes = 16  # FILE_ATTRIBUTE_DIRECTORY
            flag |= 16  # SHGFI_USEFILEATTRIBUTES

        fi = SHFILEINFO()
        if not shell32.SHGetFileInfoA(path, fileattributes, byref(fi),
                                      sizeof(SHFILEINFO), flag):
            raise RuntimeError("could not retrieve icon")
        return fi.iIcon
Example #17
0
	def GetImagelist(self):
		rbi=REBARINFO(sizeof(REBARINFO), RBIM_IMAGELIST, 0)
		if not self.SendMessage(self.Hwnd, self.Msg.RB_GETBARINFO, 0, byref(rbi)):
				raise "could not retrieve imagelist"
		if rbi.himl: return rbi.himl
Example #18
0
	def __init__(self): self.cbSize=sizeof(self)
					
class REBARINFO(Structure):
Example #19
0
	def __init__(self): self.cbSize = sizeof(self)
	
	def SetClassName(self, name):
Example #20
0
 def GetImagelist(self):
     rbi = REBARINFO(sizeof(REBARINFO), RBIM_IMAGELIST, 0)
     if not self.SendMessage(self.Hwnd, self.Msg.RB_GETBARINFO, 0,
                             byref(rbi)):
         raise "could not retrieve imagelist"
     if rbi.himl: return rbi.himl
Example #21
0
	def __init__(self):
		self.cbSize = sizeof(self)
Example #22
0
	def __init__(self):
		self.dwSize= sizeof(self)
Example #23
0
	def __init__(self): self.cbSize=sizeof(self)


SIF_RANGE           = 1
Example #24
0
	def GetText(self):
		p=create_string_buffer(self.GetTextLen()+1)
		user32.GetWindowTextA(self.Hwnd, p, sizeof(p))
		return p.value
Example #25
0
 def GetText(self):
     p = create_string_buffer(self.GetTextLen() + 1)
     user32.GetWindowTextA(self.Hwnd, p, sizeof(p))
     return p.value
Example #26
0
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)))
Example #27
0
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)))
Example #28
0
 def GetTextMax(self):
     return sizeof(self._client_buffer) - 1
Example #29
0
 def __init__(self):
     self.cbSize = sizeof(self)
Example #30
0
	def GetTextMax(self):
		return sizeof(self._client_buffer) -1
Example #31
0
 def __init__(self):
     self.dwSize = sizeof(self)
Example #32
0
		def __init__(self, cookie, buttons): 
			self.cbSize= sizeof(self)
			self.type= cookie
			self.nButtons= len(self.arrButtons)
			self.arrButtons= buttons
			self.textBuffer= [None, ]*self.nButtons
Example #33
0
	def __init__(self): self.cbSize=sizeof(self)
			
class TBADDBITMAP(Structure):