Javaeye http://angeloce.iteye.com/admin/blogs/493681
============================================
There is a small requirement to display the balloon message on the tray icon created under wx. What is embarrassing is wx. taskbaricon is not like wx. window and so on have the gethandle method, and cannot directly obtain the handle. solution
1. Rewrite taskbaricon by yourself...
2. Directly traverse and find the handle (more common and troublesome ).
# Coding: cp936import win32guiimport win32conimport timeclass testtaskbaricon: def _ init _ (Self): # register a window class WC = win32gui. wndclass () hinst = WC. hinstance = win32gui. getmodulehandle (none) WC. lpszclassname = "pythontaskbardemo" WC. lpfnwndproc = {win32con. wm_destroy: Self. ondestroy,} classatom = win32gui. registerclass (WC) style = win32con. ws_overlapped | win32con. ws_sysmenu self. hwnd = win32gui. create Window (classatom, "Taskbar Demo", style, 0, 0, win32con. cw_usedefault, win32con. cw_usedefault, 0, 0, hinst, none) hicon = win32gui. loadicon (0, win32con. idi_application) nid = (self. hwnd, 0, win32gui. nif_icon, win32con. wm_user + 20, hicon, "Demo") win32gui. shell_policyicon (win32gui. nim_add, NID) def showmsg (self, title, MSG): # the original author used the shell_policyicona method to replace the wrapped shell_policyicon method # It is said that the win32gui structu cannot be used. Re, I was confused. # Compare the original code. nid = (self. hwnd, # handle 0, # Tray Icon ID win32gui. nif_info, # ID 0, # callback Message ID 0, # Tray Icon handle "testmessage", # icon string MSG, # balloon prompt string 0, # display time title, # The title win32gui is displayed. niif_info # indicates the icon used.) win32gui. shell_policyicon (win32gui. nim_modify, NID) def ondestroy (self, hwnd, MSG, wparam, lparam): nid = (self. hwnd, 0) win32gui. shell_policyicon (win32gui. nim_delete, NID) win32gui. postquitmessa Ge (0) # terminate the app. If _ name _ = '_ main _': t = testtaskbaricon () T. showmsg ("come out! "," Altman! ") Time. Sleep (5) win32gui. destroywindow (T. hwnd)
1. In addition to algorithm design, it is really easy to use python.
2. There is nothing to use python, and you have to use strange things, such
3. People who are not often familiar with Windows development will not be flustered until they keep up with msdn and Baidu/Google ..
If the program has been changed, reduce it as much as possible. For the original article, see:
Write http://www.3snews.net/html/50/550-20986.html