Update of /cvsroot/wnd/wnd/wnd/api
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24691
Modified Files:
resources.py win.py winpath.py
Added Files:
clipboard.py handles.py
Log Message:
bit of this and a bit of that
Index: winpath.py
===================================================================
RCS file: /cvsroot/wnd/wnd/wnd/api/winpath.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** winpath.py 17 May 2005 20:05:33 -0000 1.2
--- winpath.py 2 Jul 2005 08:54:11 -0000 1.3
***************
*** 33,37 ****
"""
! from ctypes import windll, create_string_buffer, string_at
shlwapi= windll.shlwapi
--- 33,39 ----
"""
! from ctypes import (windll,
! create_string_buffer,
! string_at)
shlwapi= windll.shlwapi
***************
*** 39,43 ****
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
-
def AddBackslash(path):
p= create_string_buffer(path, size=len(path)+1)
--- 41,44 ----
--- NEW FILE: handles.py ---
import thread
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
class Handles(object):
def __init__(self, initval=0):
self.handles= [initval, ]
self.lock= thread.allocate_lock()
def GetHandles(self):
#self.lock.acquire()
handles= self.handles[:]
#self.lock.release()
return handles
def Close(self, handle):
#self.lock.acquire()
try:
self.handles.remove(handle)
except:
self.lock.release()
raise ValueError, "no handle found to close"
#self.lock.release()
def New(self):
#self.lock.acquire()
result= None
tmp_h= self.GetHandles()
s= len(self.handles)
for n, i in enumerate(tmp_h):
if n+1 < s:
if self.handles[n+1] > i+1:
self.handles.insert(n+1, i+1)
result= i+1
break
else:
self.handles.append(i+1)
result= i+1
#self.lock.release()
return result
--- NEW FILE: clipboard.py ---
"""clipboard the ole way
TODO
SetClipboardViewer
"""
from wnd.api.ole.wintypes import (ole32,
user32,
byref,
POINTER,
pointer)
from wnd.api.ole.dataobject import (DataObject,
DataObjectPointer,
IDataObject)
from wnd.api.clipformats import (cf,
GetFormatName,
GetFrameworkName,
GetFormatNameN,
GetFrameworkNameN,
RegisterClipboardFormat,)
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
def Clear():
result= False
if user32.OpenClipboard(None):
if user32.EmptyClipboard():
result= True
user32.CloseClipboard()
return result
def IsFormatAvailable(format):
return bool(user32.IsClipboardFormatAvailable(format.fmt.cfFormat))
def GetDataObject():
dataobject = DataObjectPointer()
ole32.OleGetClipboard(dataobject.ptr)
return dataobject
def SetDataObject(dataobject):
ole32.OleSetClipboard(0)
result = ole32.OleSetClipboard(dataobject.GetComPointer())
def Flush():
return not ole32.OleFlushClipboard()
def IsClipboard(dataobject):
return not ole32.OleIsCurrentClipboard(dataobject.GetComPointer())
Index: resources.py
===================================================================
RCS file: /cvsroot/wnd/wnd/wnd/api/resources.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** resources.py 15 May 2005 09:17:35 -0000 1.2
--- resources.py 2 Jul 2005 08:54:11 -0000 1.3
***************
*** 6,15 ****
EnumResNames returns the identifyers of resources not their names
for default resources so you can not use it in calls to functions
- like this '#resid'. Even worse, I never made it to get the damn
- MAKEINTRESOURCE makro to work. Could anyone enlighten me ??
- MAKEINTRESOURCE(i) (LPTSTR) ((DWORD) ((WORD) (i)))
- def MAKEINTRESOURCE(i):
-
"""
--- 6,10 ----
Index: win.py
===================================================================
RCS file: /cvsroot/wnd/wnd/wnd/api/win.py,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** win.py 29 Apr 2005 15:19:57 -0000 1.1.1.1
--- win.py 2 Jul 2005 08:54:11 -0000 1.2
***************
*** 41,45 ****
if n:
p = create_string_buffer(n+ 1)
! caption = user32.GetWindowTextA(hwnd, p, n)
return p.value
--- 41,45 ----
if n:
p = create_string_buffer(n+ 1)
! caption = user32.GetWindowTextA(hwnd, p, n+1)
return p.value
|