Esempio n. 1
0
	def GetAreaTipText(self, Control, ID):
		ti = TOOLINFO()
		ti.hwnd = Control.Hwnd
		ti.uId  = ID
		ti.lpszText= addressof(self._client_buffer)
		self.SendMessage(self.Hwnd, self.Msg.TTM_GETTEXT, 0, byref(ti))
		return self._client_buffer.value
Esempio n. 2
0
 def GetAreaTipText(self, Control, ID):
     ti = TOOLINFO()
     ti.hwnd = Control.Hwnd
     ti.uId = ID
     ti.lpszText = addressof(self._client_buffer)
     self.SendMessage(self.Hwnd, self.Msg.TTM_GETTEXT, 0, byref(ti))
     return self._client_buffer.value
Esempio n. 3
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
Esempio n. 4
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
Esempio n. 5
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")
Esempio n. 6
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
Esempio n. 7
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
Esempio n. 8
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)			
Esempio n. 9
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)			
Esempio n. 10
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)			
Esempio n. 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)
Esempio n. 12
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
Esempio n. 13
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
Esempio n. 14
0
	def Page(self, dlg, *flags, **kwargs):
		
				
		if len(self._client_pages) +1 >= MAXPROPPAGES:
			raise RuntimeError, "maximum number of pages exceeded"
		
		
		p= PROPSHEETPAGE()
		p.dwFlags= PSP_DLGINDIRECT 
		#| PSP_USECALLBACK
		#p.pfnCallback= self._client_pChildCallback
		if flags:
			for i in flags:
				try: self._client_p.dwFlags |= FLAGS_PROPPAGE[i]
				except: raise ValueError, "invalid flag: %s" % i
			
		
		## resource buffer has to be writable, so set the it 
		## as attribute the structure carries along
		tpl= dlg.GetTemplate()
		if tpl==None:
			raise ValueError, "dialog does not contain template"
		p._pWritable= create_string_buffer(tpl)
		p.u1.pResource= addressof(p._pWritable)
		
		p.pfnDlgProc= dlg.GetDlgProc()

		icon = kwargs.get('icon', None)
		if icon:
			p.dwFlags |= PSP_USEHICON
			p.u3.hIcon= icon.handle

		title = kwargs.get('title', None)	## overwrites dlgbox title
		if title:
			p.dwFlags |= PSP_USETITLE
			p.pszTitle= title
		
		lParam= kwargs.get('lp', 0)
		
		## wizard only
		headerTitle = kwargs.get('headerTitle', None)
		if headerTitle:
			p.dwFlags |= PSP_USEHEADERTITLE
			p.pszHeaderTitle= headerTitle
		headerSubTitle = kwargs.get('headerSubTitle', None)
		if headerTitle:
			p.dwFlags |= PSP_USEHEADERSUBTITLE
			p.pszHeaderSubTitle= headerSubTitle

		self._client_pages.append(p)
Esempio n. 15
0
    def Page(self, dlg, *flags, **kwargs):

        if len(self._client_pages) + 1 >= MAXPROPPAGES:
            raise RuntimeError, "maximum number of pages exceeded"

        p = PROPSHEETPAGE()
        p.dwFlags = PSP_DLGINDIRECT
        #| PSP_USECALLBACK
        #p.pfnCallback= self._client_pChildCallback
        if flags:
            for i in flags:
                try:
                    self._client_p.dwFlags |= FLAGS_PROPPAGE[i]
                except:
                    raise ValueError, "invalid flag: %s" % i

        ## resource buffer has to be writable, so set the it
        ## as attribute the structure carries along
        tpl = dlg.GetTemplate()
        if tpl == None:
            raise ValueError, "dialog does not contain template"
        p._pWritable = create_string_buffer(tpl)
        p.u1.pResource = addressof(p._pWritable)

        p.pfnDlgProc = dlg.GetDlgProc()

        icon = kwargs.get('icon', None)
        if icon:
            p.dwFlags |= PSP_USEHICON
            p.u3.hIcon = icon.handle

        title = kwargs.get('title', None)  ## overwrites dlgbox title
        if title:
            p.dwFlags |= PSP_USETITLE
            p.pszTitle = title

        lParam = kwargs.get('lp', 0)

        ## wizard only
        headerTitle = kwargs.get('headerTitle', None)
        if headerTitle:
            p.dwFlags |= PSP_USEHEADERTITLE
            p.pszHeaderTitle = headerTitle
        headerSubTitle = kwargs.get('headerSubTitle', None)
        if headerTitle:
            p.dwFlags |= PSP_USEHEADERSUBTITLE
            p.pszHeaderSubTitle = headerSubTitle

        self._client_pages.append(p)
Esempio n. 16
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)))
Esempio n. 17
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)))
Esempio n. 18
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