<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<TITLE>Nachricht</TITLE>
<META content="MSHTML 6.00.2800.1106" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=275524512-14092004><FONT face=Arial color=#0000ff size=2>Thank
you very much for your Pointer, Mark. With "AnimateWindow" I was able to google
it up ...</FONT></SPAN></DIV>
<DIV><SPAN class=275524512-14092004><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=275524512-14092004><FONT face=Arial color=#0000ff size=2>I took
also some Ctypes-Receipe out of the windows-cookbook, and ... for everyone to
enjoy or not:</FONT></SPAN></DIV>
<DIV><SPAN class=275524512-14092004><FONT face=Arial color=#0000ff size=2># -*-
coding: LATIN-1 -*-<BR>import win32con<BR>import sys<BR>from ctypes import
*<BR>import time<BR>import threading</FONT></SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN class=275524512-14092004><FONT face=Arial color=#0000ff
size=2>WNDPROC = WINFUNCTYPE(c_long, c_int, c_uint, c_int,
c_int)</FONT></SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN class=275524512-14092004><FONT face=Arial color=#0000ff size=2>class
WNDCLASS(Structure):<BR> _fields_ = [('style',
c_uint),<BR>
('lpfnWndProc',
WNDPROC),<BR>
('cbClsExtra',
c_int),<BR>
('cbWndExtra',
c_int),<BR>
('hInstance',
c_int),<BR>
('hIcon',
c_int),<BR>
('hCursor',
c_int),<BR>
('hbrBackground',
c_int),<BR>
('lpszMenuName',
c_char_p),<BR>
('lpszClassName', c_char_p)]</FONT></SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN class=275524512-14092004><FONT face=Arial color=#0000ff size=2>class
RECT(Structure):<BR> _fields_ = [('left',
c_long),<BR>
('top',
c_long),<BR>
('right',
c_long),<BR>
('bottom', c_long)]</FONT></SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN class=275524512-14092004><FONT face=Arial color=#0000ff size=2>class
PAINTSTRUCT(Structure):<BR> _fields_ = [('hdc',
c_int),<BR>
('fErase',
c_int),<BR>
('rcPaint',
RECT),<BR>
('fRestore',
c_int),<BR>
('fIncUpdate',
c_int),<BR>
('rgbReserved', c_char * 32)]</FONT></SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN class=275524512-14092004><FONT face=Arial color=#0000ff size=2>class
POINT(Structure):<BR> _fields_ = [('x',
c_long),<BR>
('y', c_long)]<BR> <BR>class
MSG(Structure):<BR> _fields_ = [('hwnd',
c_int),<BR>
('message',
c_uint),<BR>
('wParam',
c_int),<BR>
('lParam',
c_int),<BR>
('time',
c_int),<BR>
('pt', POINT)]</FONT></SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN class=275524512-14092004><FONT face=Arial color=#0000ff size=2>def
ErrorIfZero(handle):<BR> if handle ==
0:<BR> raise
WinError<BR>
else:<BR> return
handle</FONT></SPAN></DIV>
<DIV> </DIV><SPAN class=275524512-14092004>
<DIV><BR><FONT face=Arial color=#0000ff size=2>class
TrayNotifcation(object):<BR> def __init__(self,
text='',breite=250,hoehe=60):<BR>
self.maxx=windll.user32.GetSystemMetrics(win32con.SM_CXMAXIMIZED)<BR>
self.maxy=windll.user32.GetSystemMetrics(win32con.SM_CYMAXIMIZED)<BR>
self.text=text<BR>
self.breite=breite<BR>
self.hoehe=hoehe</FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV><FONT face=Arial color=#0000ff
size=2> CreateWindowEx =
windll.user32.CreateWindowExA<BR>
CreateWindowEx.argtypes = [c_int, c_char_p, c_char_p, c_int, c_int, c_int,
c_int, c_int, c_int, c_int, c_int,
c_int]<BR> CreateWindowEx.restype =
ErrorIfZero<BR>
<BR> # Ctypes may already have
something like this...?<BR> def
makeCOLORREF(red, green,
blue):<BR>
return red + (green << 8) + (blue <<
16)<BR> myBrush =
windll.gdi32.CreateSolidBrush(makeCOLORREF(220, 255,
220))<BR>
<BR> # Define Window
Class<BR> wndclass =
WNDCLASS()<BR> wndclass.style =
win32con.CS_HREDRAW | win32con.CS_VREDRAW
<BR> wndclass.lpfnWndProc =
WNDPROC(self.WndProc)<BR>
wndclass.cbClsExtra = wndclass.cbWndExtra =
0<BR> wndclass.hInstance =
windll.kernel32.GetModuleHandleA(c_int(win32con.NULL))<BR>
wndclass.hIcon = windll.user32.LoadIconA(c_int(win32con.NULL),
c_int(win32con.IDI_APPLICATION))<BR>
wndclass.hCursor = windll.user32.LoadCursorA(c_int(win32con.NULL),
c_int(win32con.IDC_ARROW))<BR>
#wndclass.hbrBackground =
windll.gdi32.GetStockObject(c_int(win32con.WHITE_BRUSH))<BR>
wndclass.hbrBackground =myBrush <BR>
wndclass.lpszMenuName = None<BR>
wndclass.lpszClassName =
"TrayNotiWin"<BR> # Register Window
Class<BR> if not
windll.user32.RegisterClassA(byref(wndclass)):<BR>
raise WinError()<BR> # Create
Window<BR> self.hwnd =
CreateWindowEx(0,#DWORD
dwExStyle,<BR>
wndclass.lpszClassName,#LPCTSTR
lpClassName,<BR>
"Python Window", #LPCTSTR
lpWindowName,<BR>
win32con.WS_POPUPWINDOW, #DWORD
dwStyle,<BR>
self.maxx-self.breite,#
x<BR>
self.maxy-self.hoehe,#
y<BR>
self.breite,#
breite<BR>
self.hoehe,#
höhe<BR>
win32con.NULL,#HWND
hWndParent,<BR>
win32con.NULL,#HMENU
hMenu,<BR>
wndclass.hInstance,#HINSTANCE
hInstance,<BR>
win32con.NULL#LPVOID
lpParam<BR>
)<BR> <BR> def
notify(self,text=None):<BR> if
text:<BR>
self.text=text<BR>
windll.user32.ShowWindow(c_int(self.hwnd),
c_int(win32con.SW_SHOWNORMAL))<BR>
windll.user32.UpdateWindow(c_int(self.hwnd))<BR>
<BR> #print
self.hwnd<BR> class
killer(threading.Thread):<BR>
def
run(my):<BR>
time.sleep(1.8)<BR>
windll.user32.ShowWindow(c_int(self.hwnd),c_int(win32con.SW_HIDE))<BR>
killer().start()</FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV><FONT face=Arial color=#0000ff size=2> def
close(self):<BR>
windll.user32.PostMessageA(self.hwnd, win32con.WM_CLOSE, 0, 0)</FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV><FONT face=Arial color=#0000ff size=2> def
__del__(self):<BR> """Fenster
entfernen"""<BR>
windll.user32.PostMessageA(self.hwnd, win32con.WM_CLOSE, 0, 0)</FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV><FONT face=Arial color=#0000ff size=2>
<BR> def WndProc(self,hwnd, message, wParam,
lParam):<BR> ps =
PAINTSTRUCT()<BR> rect =
RECT()<BR> if message ==
win32con.WM_PRINTCLIENT:<BR>
hdc=wParam<BR>
#print "wm_printclient
erhalten"<BR>
windll.user32.GetClientRect(c_int(hwnd),
byref(rect))<BR>
windll.gdi32.SetBkMode(hdc,win32con.TRANSPARENT)<BR>
rect.top=rect.top+4<BR>
rect.left=rect.left+4<BR>
windll.user32.DrawTextA(c_int(hdc),<BR>
self.text,<BR>
c_int(-1), byref(rect),
<BR>
win32con.DT_TOP)<BR> elif message ==
win32con.WM_SHOWWINDOW:<BR>
#print "ShowWindow
erhalten"<BR>
bShown =
wParam<BR> if
bShown:<BR>
windll.user32.AnimateWindow(c_int(hwnd),c_int(280),c_int(win32con.AW_SLIDE|win32con.AW_VER_NEGATIVE))<BR>
else:<BR>
windll.user32.AnimateWindow(c_int(hwnd),c_int(280),c_int(win32con.AW_SLIDE|win32con.AW_VER_POSITIVE|win32con.AW_HIDE))<BR>
return 0<BR>
<BR> elif message ==
win32con.WM_PAINT:<BR>
#print "Paint
bekommen"<BR>
hdc = windll.user32.BeginPaint(c_int(hwnd),
byref(ps))<BR>
windll.user32.GetClientRect(c_int(hwnd),
byref(rect))<BR>
windll.user32.DrawTextA(c_int(hdc),<BR>
self.text,<BR>
c_int(-1), byref(rect),
<BR>
win32con.DT_TOP)<BR>
windll.user32.EndPaint(c_int(hwnd),
byref(ps))<BR>
return 0<BR> elif message ==
win32con.WM_DESTROY:<BR>
#print
"wmdestroy"<BR>
windll.user32.PostQuitMessage(0)<BR>
return 0<BR> <BR>
return windll.user32.DefWindowProcA(c_int(hwnd), c_int(message), c_int(wParam),
c_int(lParam))</FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV><BR><FONT face=Arial color=#0000ff size=2>if
__name__=="__main__":<BR> nt=TrayNotifcation("hey, hey,
wickie")<BR> nt.notify()<BR>
<BR> <BR> class
waiter(threading.Thread):<BR> def
run(self):<BR>
time.sleep(3)<BR>
nt.close()<BR> waiter().start()<BR>
<BR> <BR> msg = MSG()<BR>
pMsg = pointer(msg)<BR> NULL =
c_int(win32con.NULL)<BR> while windll.user32.GetMessageA(
pMsg, NULL, 0, 0) != 0:<BR>
windll.user32.TranslateMessage(pMsg)<BR>
windll.user32.DispatchMessageA(pMsg)<BR> print "das war
es"<BR>
nt.close()<BR> <BR></FONT></SPAN><SPAN
class=513520714-13092004><SPAN class=275524512-14092004><FONT face=Arial
color=#0000ff size=2> </FONT></SPAN></SPAN></DIV>
<DIV><SPAN class=513520714-13092004><SPAN
class=275524512-14092004> </SPAN></SPAN></DIV></BODY></HTML>