Ejemplo n.º 1
0
def CreateExclusionName(name, flag):
	from wnd.api import winos
	if winos.IsNT():

		if flag=='desktop':
			## create a name exclusive to the current desktop
			#UOI_NAME     = 2
			hDesk= user32.GetThreadDesktop(kernel32.GetCurrentThreadId())
			
			dwLen= c_ulong()
			user32.GetUserObjectInformationA(hDesk, 2, None, 0, byref(dwLen))
			p = create_string_buffer('', size=dwLen.value)
			if user32.GetUserObjectInformationA(hDesk, 2, p, dwLen.value, byref(dwLen)):
				name = '%s-%s' % (name, p.value)
			user32.CloseDesktop(hDesk)
			return name

		elif flag== 'session':
			## create a name exclusive to the current session
			from wnd.api import privleges
			try:
				st= privleges.GetTokenStats(None)
				name = '%s-%s' % (name, st.AuthenticationId)
			except: pass
			return name
		
		elif flag == 'trustee':
			## create a name exclusive to the current, well trustee that is.  
			import os
			domain= os.getenv('USERDOMAIN')
			if domain:
				return '%s-%s' % (name, domain)
		
	# default
	return name	
Ejemplo n.º 2
0
    def __init__(self, size='small'):

        GPA = kernel32.GetProcAddress
        isNT = winos.IsNT()
        if isNT:
            ## ?? check what happens on successive inits
            ## should be the same handle returned, at least I hope so
            GPA.restype = WINFUNCTYPE(BOOL, BOOL)
            try:
                IconInit = GPA(shell32._handle, 660)
                IconInit(1)
            except:
                raise RuntimeError, "could not retrieve IconInit api"

        GPA.restype = WINFUNCTYPE(INT, POINTER(HANDLE), POINTER(HANDLE))
        try:
            SH_GetImageLists = GPA(shell32._handle, 71)
        except:
            raise RuntimeError, "could not retrieve shell_GetImageLists api"

        small = HANDLE()
        large = HANDLE()
        if not SH_GetImageLists(byref(large), byref(small)):
            raise RuntimeError, "could not retrieve system imagelist"

        if not (large.value and small.value):
            raise RuntimeError, "could not retrieve system imagelist"

        if size == 'small':
            self.handle = small.value
        else:
            self.handle = large.value
Ejemplo n.º 3
0
	def __init__(self, size='small'):
	
		GPA = kernel32.GetProcAddress
		isNT= winos.IsNT()
		if isNT:
			## ?? check what happens on successive inits
			## should be the same handle returned, at least I hope so
			GPA.restype = WINFUNCTYPE(BOOL, BOOL) 
			try:
				IconInit = GPA(shell32._handle, 660)
				IconInit(1)
			except:
				raise RuntimeError, "could not retrieve IconInit api"
			
		GPA.restype = WINFUNCTYPE(INT, POINTER(HANDLE), POINTER(HANDLE))
		try:
			SH_GetImageLists = GPA(shell32._handle, 71) 
		except:
			raise RuntimeError, "could not retrieve shell_GetImageLists api"
		
			
		small = HANDLE()
		large = HANDLE()
		if not SH_GetImageLists(byref(large), byref(small)):
			raise RuntimeError, "could not retrieve system imagelist"
		
		if not (large.value and small.value):
			raise RuntimeError, "could not retrieve system imagelist"
		
		if size=='small':
			self.handle= small.value
		else:
			self.handle= large.value
Ejemplo n.º 4
0
    def GetTextExtendM(self, *text):
        hDC = user32.GetDC(self.Hwnd)
        if hDC:
            WM_GETFONT = 49
            hFont = self.SendMessage(self.Hwnd, WM_GETFONT, 0, 0)
            if hFont: hOldFont = gdi32.SelectObject(hDC, hFont)
            rc = RECT()
            DT_CALCRECT = 1024
            maxL, maxT, maxR, maxB = 0, 0, 0, 0
            for i in text:

                result = user32.DrawTextA(hDC, i, len(i), byref(rc),
                                          DT_CALCRECT)
                maxL, maxT, maxR, maxB = max(maxL, rc.left), max(
                    maxT, rc.top), max(maxR, rc.right), max(maxB, rc.bottom)
                if not result:
                    if hFont: gdi32.SelectObject(hDC, hOldFont)
                    user32.ReleaseDC(self.Hwnd, hDC)
                    raise RuntimeError(
                        "could not retrieve text extend")  # WinError NT only
            user32.ReleaseDC(self.Hwnd, hDC)
            if hFont: gdi32.SelectObject(hDC, hOldFont)
            return maxR - maxL, maxB - maxT
            return rc.right - rc.left, rc.bottom - rc.top
        else:
            raise RuntimeError(
                "could not retrieve device context")  # WinError NT only
Ejemplo n.º 5
0
	def SetItemImage(self, i, iImage):
		hd = HDITEM()
		hd.mask = hd.HDI_IMAGE
		hd.iImage= iImage
		if self.SendMessage(self.Hwnd, self.Msg.HDM_SETITEM, i, byref(hd)):
			return hd.iImage
		raise RuntimeError("could not set irtem image")
Ejemplo n.º 6
0
	def HilightItem(self, i):
		tci = TCITEM()
		tci.mask = tci.TCIF_STATE
		tci.dwStateMask= 2		# TCIS_HIGHLIGHTED
		tci.dwState= 2
		if not self.SendMessage(self.Hwnd, self.Msg.TCM_SETITEM, i, byref(tci)):
			raise RuntimeError("could set text")
Ejemplo n.º 7
0
	def SetBandChild(self, ID, Control):
		bi=REBARBANDINFO()
		bi.fMask = RBBIM_CHILD
		bi.hwndChild=Control.Hwnd
		if not self.SendMessage(self.Hwnd, self.Msg.RB_SETBANDINFO,
															self.IDToIndex(ID), byref(bi)):
			raise "could set band child"
Ejemplo n.º 8
0
	def SetBandMaximizedWidth(self, ID, n):
		bi=REBARBANDINFO()
		bi.cxIdeal = n 
		bi.fMask |= RBBIM_IDEALSIZE 
		if not self.SendMessage(self.Hwnd, self.Msg.RB_SETBANDINFO,
															self.IDToIndex(ID), byref(bi)):
			raise "could set band maximized size"
Ejemplo n.º 9
0
	def GetBandBackgroundImage(self, ID):
		bi=REBARBANDINFO()
		bi.fMask |= RBBIM_BACKGROUND
		if not self.SendMessage(self.Hwnd, self.Msg.RB_GETBANDINFO,
															self.IDToIndex(ID), byref(bi)):
			raise "could retrieve band background image"
		if bi.hbmBack:	return bi.hbmBack
Ejemplo n.º 10
0
	def IndexToID(self, i):
		bi=REBARBANDINFO()
		bi.fMask = RBBIM_ID 
		if not self.SendMessage(self.Hwnd, self.Msg.RB_GETBANDINFO,
															i, byref(bi)):
			raise "could retrieve band ID"
		return bi.wID
Ejemplo n.º 11
0
 def SetBandImage(self, ID, i):
     bi = REBARBANDINFO()
     bi.fMask = RBBIM_IMAGE
     bi.iImage = i
     if not self.SendMessage(self.Hwnd, self.Msg.RB_SETBANDINFO,
                             self.IDToIndex(ID), byref(bi)):
         raise "could set band image"
Ejemplo n.º 12
0
 def GetBandBackgroundImage(self, ID):
     bi = REBARBANDINFO()
     bi.fMask |= RBBIM_BACKGROUND
     if not self.SendMessage(self.Hwnd, self.Msg.RB_GETBANDINFO,
                             self.IDToIndex(ID), byref(bi)):
         raise "could retrieve band background image"
     if bi.hbmBack: return bi.hbmBack
Ejemplo n.º 13
0
 def SetBandBackgroundImage(self, ID, Bitmap):
     bi = REBARBANDINFO()
     bi.fMask = RBBIM_BACKGROUND
     bi.hbmBack = Bitmap.handle
     if not self.SendMessage(self.Hwnd, self.Msg.RB_SETBANDINFO,
                             self.IDToIndex(ID), byref(bi)):
         raise "could set band background image"
Ejemplo n.º 14
0
 def GetBandColors(self, ID):
     bi = REBARBANDINFO()
     bi.fMask = RBBIM_COLORS
     if not self.SendMessage(self.Hwnd, self.Msg.RB_GETBANDINFO,
                             self.IDToIndex(ID), byref(bi)):
         raise "could retrieve band colors"
     return bi.clrFore, bi.clrBack
Ejemplo n.º 15
0
 def SetBandTitle(self, ID, title):
     bi = REBARBANDINFO()
     bi.fMask = RBBIM_TEXT
     bi.lpText = self._client_TruncText(title)
     if not self.SendMessage(self.Hwnd, self.Msg.RB_SETBANDINFO,
                             self.IDToIndex(ID), byref(bi)):
         raise "could set band title"
Ejemplo n.º 16
0
 def IndexToID(self, i):
     bi = REBARBANDINFO()
     bi.fMask = RBBIM_ID
     if not self.SendMessage(self.Hwnd, self.Msg.RB_GETBANDINFO, i,
                             byref(bi)):
         raise "could retrieve band ID"
     return bi.wID
Ejemplo n.º 17
0
 def GetVisibleMonthRange(self):
     st1 = SYSTEMTIME()
     st2 = SYSTEMTIME()
     arrSt = (SYSTEMTIME * 2)(st1, st2)
     result = self.SendMessage(self.Hwnd, self.Msg.MCM_GETMONTHRANGE,
                               GMR_VISIBLE, byref(arrSt))
     return result, st1, st2
Ejemplo n.º 18
0
def GetVertScrollInfo(Window):
	sci=SCROLLINFO()
	sci.fMask=SIF_ALL
	if not user32.GetScrollInfo(Window.Hwnd, 
				SB_VERT, byref(sci)):
			raise RuntimeError("could not retrieve vert scrollinfo")	
	return sci.nMin, sci.nMax, sci.nPage, sci.nPos, sci.nTrackPos 
Ejemplo n.º 19
0
 def GetBandControlSize(self, ID):
     bi = REBARBANDINFO()
     bi.fMask = RBBIM_CHILDSIZE
     if not self.SendMessage(self.Hwnd, self.Msg.RB_GETBANDINFO,
                             self.IDToIndex(ID), byref(bi)):
         raise "could retrieve band control size"
     return bi.cxMinChild, bi.cyMinChild
Ejemplo n.º 20
0
	def GetBandColors(self, ID):
		bi=REBARBANDINFO()
		bi.fMask = RBBIM_COLORS
		if not self.SendMessage(self.Hwnd, self.Msg.RB_GETBANDINFO,
															self.IDToIndex(ID), byref(bi)):
			raise "could retrieve band colors"
		return bi.clrFore, bi.clrBack
Ejemplo n.º 21
0
 def GetBandMaximizedWidth(self, ID):
     bi = REBARBANDINFO()
     bi.fMask |= RBBIM_IDEALSIZE
     if not self.SendMessage(self.Hwnd, self.Msg.RB_GETBANDINFO,
                             self.IDToIndex(ID), byref(bi)):
         raise "could retrieve band maximized size"
     return bi.cxIdeal
Ejemplo n.º 22
0
	def GetBandControlSize(self, ID):
		bi=REBARBANDINFO()
		bi.fMask = RBBIM_CHILDSIZE
		if not self.SendMessage(self.Hwnd, self.Msg.RB_GETBANDINFO,
															self.IDToIndex(ID), byref(bi)):
			raise "could retrieve band control size"
		return bi.cxMinChild, bi.cyMinChild
Ejemplo n.º 23
0
 def SetBandMaximizedWidth(self, ID, n):
     bi = REBARBANDINFO()
     bi.cxIdeal = n
     bi.fMask |= RBBIM_IDEALSIZE
     if not self.SendMessage(self.Hwnd, self.Msg.RB_SETBANDINFO,
                             self.IDToIndex(ID), byref(bi)):
         raise "could set band maximized size"
Ejemplo n.º 24
0
	def SetBandHeaderSize(self, ID, n):
		bi=REBARBANDINFO()
		bi.cxHeader = n
		bi.fMask |= RBBIM_HEADERSIZE
		if not self.SendMessage(self.Hwnd, self.Msg.RB_SETBANDINFO,
															self.IDToIndex(ID), byref(bi)):
			raise "could set band header size"
Ejemplo n.º 25
0
 def GetBandHeaderSize(self, ID):
     bi = REBARBANDINFO()
     bi.fMask |= RBBIM_HEADERSIZE
     if not self.SendMessage(self.Hwnd, self.Msg.RB_GETBANDINFO,
                             self.IDToIndex(ID), byref(bi)):
         raise "could retrieve band header size"
     return bi.cxHeader
Ejemplo n.º 26
0
	def SetBandLparam(self, ID, lp):
		bi=REBARBANDINFO()
		bi.lParam = lp
		bi.fMask = RBBIM_LPARAM
		if not self.SendMessage(self.Hwnd, self.Msg.RB_SETBANDINFO,
															self.IDToIndex(ID), byref(bi)):
			raise "could set band lParam"
Ejemplo n.º 27
0
 def SetBandHeaderSize(self, ID, n):
     bi = REBARBANDINFO()
     bi.cxHeader = n
     bi.fMask |= RBBIM_HEADERSIZE
     if not self.SendMessage(self.Hwnd, self.Msg.RB_SETBANDINFO,
                             self.IDToIndex(ID), byref(bi)):
         raise "could set band header size"
Ejemplo n.º 28
0
	def SetItemLparam(self, i, lp):
		hd = HDITEM()
		hd.mask = hd.HDI_LPARAM
		hd.lParam= lp
		if self.SendMessage(self.Hwnd, self.Msg.HDM_SETITEM, i, byref(hd)):
			return hd.lParam
		raise RuntimeError("could not set lParam")
Ejemplo n.º 29
0
 def GetBandChild(self, ID):
     bi = REBARBANDINFO()
     bi.fMask = RBBIM_CHILD
     if not self.SendMessage(self.Hwnd, self.Msg.RB_GETBANDINFO,
                             self.IDToIndex(ID), byref(bi)):
         raise "could retrieve band child"
     if bi.hwndChild: return bi.hwndChild
Ejemplo n.º 30
0
	def SetItemWidth(self, i, n):
		hd = HDITEM()
		hd.mask = hd.HDI_WIDTH
		hd.cxy= n
		if self.SendMessage(self.Hwnd, self.Msg.HDM_SETITEM, i, byref(hd)):
			return hd.iImage
		raise RuntimeError("could not set item width")
Ejemplo n.º 31
0
 def SetBandChild(self, ID, Control):
     bi = REBARBANDINFO()
     bi.fMask = RBBIM_CHILD
     bi.hwndChild = Control.Hwnd
     if not self.SendMessage(self.Hwnd, self.Msg.RB_SETBANDINFO,
                             self.IDToIndex(ID), byref(bi)):
         raise "could set band child"
Ejemplo n.º 32
0
	def GetTime(self):
		st=SYSTEMTIME()
		result= self.SendMessage(self.Hwnd,
				self.Msg.DTM_GETSYSTEMTIME, 0, byref(st))
		if result==GDT_ERROR: raise "could not retrive time"
		if result==GDT_VALID:
			return st
Ejemplo n.º 33
0
 def SetBandWidth(self, ID, n):
     bi = REBARBANDINFO()
     bi.fMask = RBBIM_SIZE
     bi.cx = n
     if not self.SendMessage(self.Hwnd, self.Msg.RB_SETBANDINFO,
                             self.IDToIndex(ID), byref(bi)):
         raise "could set band width"
Ejemplo n.º 34
0
 def GetMonthRange(self, visible=True):
     st1 = SYSTEMTIME()
     st2 = SYSTEMTIME()
     arrSt = (SYSTEMTIME * 2)(st1, st2)
     result = self.SendMessage(self.Hwnd, self.Msg.MCM_GETMONTHRANGE,
                               GMR_DAYSTATE, byref(arrSt))
     return result, st1, st2
Ejemplo n.º 35
0
 def SetBandLparam(self, ID, lp):
     bi = REBARBANDINFO()
     bi.lParam = lp
     bi.fMask = RBBIM_LPARAM
     if not self.SendMessage(self.Hwnd, self.Msg.RB_SETBANDINFO,
                             self.IDToIndex(ID), byref(bi)):
         raise "could set band lParam"
Ejemplo n.º 36
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
Ejemplo n.º 37
0
 def SetAreaTipText(self, Control, ID, text):
     ti = TOOLINFO()
     ti.uFlags = TTF_SUBCLASS
     ti.hwnd = Control.Hwnd
     ti.uId = ID
     ti.lpszText = self._client_TruncText(text)
     self.SendMessage(self.Hwnd, self.Msg.TTM_UPDATETIPTEXT, 0, byref(ti))
Ejemplo n.º 38
0
	def SetBandTitle(self, ID, title):
		bi=REBARBANDINFO()
		bi.fMask = RBBIM_TEXT
		bi.lpText = self._client_TruncText(title)
		if not self.SendMessage(self.Hwnd, self.Msg.RB_SETBANDINFO,
															self.IDToIndex(ID), byref(bi)):
			raise "could set band title"		
Ejemplo n.º 39
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
Ejemplo n.º 40
0
	def SetBandBackgroundImage(self, ID, Bitmap):
		bi=REBARBANDINFO()
		bi.fMask = RBBIM_BACKGROUND
		bi.hbmBack=Bitmap.handle
		if not self.SendMessage(self.Hwnd, self.Msg.RB_SETBANDINFO,
															self.IDToIndex(ID), byref(bi)):
			raise "could set band background image"
Ejemplo n.º 41
0
	def __init__(self, hwndParent, hMenu, x, y, w, h, *styles):
		
		self.Msg= Msgs
		self.Style= Styles
		
		self.pChildProc= WNDPROC(self.ChildProc)
		self._client_fMessageSend= False
		self._client_MDIChildren= []	
	
		iStyles = self.ParseStyles(styles, 					
								style=1073741824|268435456|33554432|67108864)
		self._base_style = [iStyles[3], iStyles[4]]	# base/clientstyle
				
		cs= CLIENTCREATESTRUCT(hMenu, fw.WND_ID_MDICHILD_MIN)
			
		# create the MDI-client
		## default  WS_CHILD|WS_VISIBLE|WS_CLIPCHILDREN|
		## WS_CLIPSIBLINGS|WS_HSCROLL|WS_VSCROLL
		#iStyles= 1073741824|268435456|33554432|67108864|1048576|2097152
		hwnd=user32.CreateWindowExA(
							iStyles[1],"mdiclient",'',iStyles[0],	x,y,w,h,
							hwndParent,fw.ID.New(),0,byref(cs))
		if not hwnd: raise "could not create MDIFrame"

		control.ControlFromHandle.__init__(self, hwnd, 'nosubclass')
Ejemplo n.º 42
0
	def SetBandImage(self, ID, i):
		bi=REBARBANDINFO()
		bi.fMask = RBBIM_IMAGE
		bi.iImage=i
		if not self.SendMessage(self.Hwnd, self.Msg.RB_SETBANDINFO,
															self.IDToIndex(ID), byref(bi)):
			raise "could set band image"
Ejemplo n.º 43
0
 def SetParts(self, *parts):
     if len(parts) > 255:
         raise RuntimeError("too many parts")
     n = len(parts)
     arr = (c_int * n)(*parts)
     if not self.SendMessage(self.Hwnd, self.Msg.SB_SETPARTS, n, byref(arr)):
         raise RuntimeError("could not set parts")
Ejemplo n.º 44
0
	def GetBandMaximizedWidth(self, ID):
		bi=REBARBANDINFO()
		bi.fMask |= RBBIM_IDEALSIZE 
		if not self.SendMessage(self.Hwnd, self.Msg.RB_GETBANDINFO,
															self.IDToIndex(ID), byref(bi)):
			raise "could retrieve band maximized size"
		return bi.cxIdeal
Ejemplo n.º 45
0
	def Write(self):
		self.stream = IStreamImpl()
		result =comctl32.ImageList_Write(self.handle, byref(self.stream.IStream))
		del self.stream.IStream
		if not result: raise RuntimeError("could not write imagelist")
		#self.stream = None
		return self.stream.data
Ejemplo n.º 46
0
	def GetBandHeaderSize(self, ID):
		bi=REBARBANDINFO()
		bi.fMask |= RBBIM_HEADERSIZE
		if not self.SendMessage(self.Hwnd, self.Msg.RB_GETBANDINFO,
															self.IDToIndex(ID), byref(bi)):
			raise "could retrieve band header size"
		return bi.cxHeader 
Ejemplo n.º 47
0
	def __init__(self, bytes):
		self.stream = IStreamImpl(bytes)
		handle = comctl32.ImageList_Read(byref(self.stream.IStream))
		if not handle: raise RuntimeError("could not create imagelist from bytes")
		DisposableImagelist.__init__(self, handle)
		del self.stream.IStream
		del self.stream
Ejemplo n.º 48
0
	def GetBandChild(self, ID):
		bi=REBARBANDINFO()
		bi.fMask = RBBIM_CHILD
		if not self.SendMessage(self.Hwnd, self.Msg.RB_GETBANDINFO,
															self.IDToIndex(ID), byref(bi)):
			raise "could retrieve band child"
		if bi.hwndChild: return bi.hwndChild
Ejemplo n.º 49
0
	def GetMonthRange(self, visible=True):
		st1=SYSTEMTIME()
		st2=SYSTEMTIME()
		arrSt=(SYSTEMTIME*2)(st1, st2)
		result=self.SendMessage(self.Hwnd,
				self.Msg.MCM_GETMONTHRANGE, GMR_DAYSTATE, byref(arrSt))
		return result, st1, st2
Ejemplo n.º 50
0
	def SetBandWidth(self, ID, n):
		bi=REBARBANDINFO()
		bi.fMask =  RBBIM_SIZE
		bi.cx = n
		if not self.SendMessage(self.Hwnd, self.Msg.RB_SETBANDINFO,
															self.IDToIndex(ID), byref(bi)):
			raise "could set band width"
Ejemplo n.º 51
0
	def IsPushed(self, i):
		tci = TCITEM()
		tci.mask = tci.TCIF_STATE
		tci.dwStateMask= 1		# TCIS_BUTTONPRESSED
		if not self.SendMessage(self.Hwnd, self.Msg.TCM_GETITEM, i, byref(tci)):
			raise RuntimeError("could retrieve item info")
		return bool(tci.dwState)
Ejemplo n.º 52
0
	def HitTest(self):
		pt = POINT()
		if not user32.GetCursorPos(byref(pt)):
			raise WinError(GetLastError())
		hittest = self.DefWindowProc(self.Hwnd, self.Msg.WM_NCHITTEST, 0, MAKELONG(pt.x, pt.y))
		try: return HT_FLAGS[hittest]
		except: return 'unknown'
Ejemplo n.º 53
0
	def IsHilighted(self, i):
		tci = TCITEM()
		tci.mask = tci.TCIF_STATE
		tci.dwStateMask= 2		# TCIS_HIGHLIGHTED
		if not self.SendMessage(self.Hwnd, self.Msg.TCM_GETITEM, i, byref(tci)):
			raise RuntimeError("could retrieve item info")
		return bool(tci.dwState)
Ejemplo n.º 54
0
	def GetVisibleMonthRange(self):
		st1=SYSTEMTIME()
		st2=SYSTEMTIME()
		arrSt=(SYSTEMTIME*2)(st1, st2)
		result=self.SendMessage(self.Hwnd,
				self.Msg.MCM_GETMONTHRANGE, GMR_VISIBLE, byref(arrSt))
		return result, st1, st2
Ejemplo n.º 55
0
	def PushItem(self, i):
		tci = TCITEM()
		tci.mask = tci.TCIF_STATE
		tci.dwStateMask= 1		# TCIS_BUTTONPRESSED
		tci.dwState= 1
		if not self.SendMessage(self.Hwnd, self.Msg.TCM_SETITEM, i, byref(tci)):
			raise RuntimeError("could push item")