473,714 Members | 2,351 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

UpdateLayeredWi ndow in pywin32


I am trying to making an On-Screen Display, which is implemented by
Basically I created a wx.Frame with style like

super(OSDBase, self).__init__( parent, id, title,
style = wx.STAY_ON_TOP |
self.SetTranspa rent(128)

But if I try to draw an image with alpha channel(like PNG format), I
always get
a background behind this image. But I don't want the background.

Then I read this article, http://www.codeproject.com/csharp/OSDwindow.asp
The demo program is written in C#. I understand that I need to use
UpdateLayeredWi ndow to update visual content of a layered window.

But I always got an error:

Traceback (most recent call last):
File "osd_post.p y", line 60, in <module>
File "osd_post.p y", line 56, in Update
pywintypes.erro r: (87, 'UpdateLayeredW indow', 'The parameter is

I am not sure did I use UpdateLayeredWi ndow correctly.

Any help would be appreciated.
My Python is 2.5, pywin32 is 210, wxPython is 2.8.1

UpdateLayeredWi ndow Function Help from MSDN:

UpdateLayeredWi ndow Function Help from pywin32:

My source code:

"""pyitctrl - OSD"""
# Created Date : 2007/03/14
# Author: livibetter

import wx, winxpgui, win32con

class OSDBase(wx.Fram e):
def __init__(self, parent, id, title):
super(OSDBase, self).__init__( parent, id, title,
style = wx.STAY_ON_TOP |
self.SetTranspa rent(128)

print hex(winxpgui.Ge tWindowLong(sel f.GetHandle(),
win32con.GWL_EX STYLE))
print winxpgui.GetLay eredWindowAttri butes(self.GetH andle())

self.img = wx.Image("icon. png")
self.bmp = self.img.Conver tToBitmap()
w, h = self.bmp.GetWid th(), self.bmp.GetHei ght()
self.SetClientS ize( (w, h) )

def Update(self):
print "Update"

screenDC = winxpgui.GetDC( winxpgui.GetDes ktopWindow())
print screenDC
cScreenDC = winxpgui.Create CompatibleDC(0)
print cScreenDC

(w, h) = self.GetSizeTup le()
bmp = wx.EmptyBitmap( w, h)
tmpDC = wx.MemoryDC()
tmpDC.SelectObj ect(bmp)
tmpDC.SetBackgr ound(wx.Brush(" BLACK"))
tmpDC.DrawBitma p(self.bmp,0,0, True)
del tmpDC

winxpgui.Select Object(cScreenD C, bmp.GetHandle() )

winxpgui.Update LayeredWindow(s elf.GetHandle() ,
self.GetPositio nTuple(),
self.GetSizeTup le(),
win32con.ULW_AL PHA)

app = wx.App(False)
osd = OSDBase(None, wx.ID_ANY, 'OSD Frame')


Apr 16 '07 #1
1 4907
I have found the cause

"Please note that after SetLayeredWindo wAttributes has been called,
subsequent UpdateLayeredWi ndow calls will fail until the layering
style bit is cleared and set again."
from http://msdn2.microsoft.com/en-us/lib...9.aspx#layered

But I still can't use winxpgui.Update LayeredWindow, Now I am using
ctypes to enable calling UpdateLayeredWi ndow, and this works.

Apr 17 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: Michael Jordan | last post by:
I'm hoping that someone here can give me some insight into a problem I'm running into with Python, pywin32 and Excel. All-in-all using Python and pywin32 is great but I've run into a strange problem with the range Offset property, I'm not getting the correct offset and the returned range is a single cell and not the same size as the original range. For example, when I enter the following lines of code in PythonWin : from...
by: Bob Chapman | last post by:
On two different Windows 98SE Systems, I have attempted to upgrade working Python 2.3.3 and win32all installations to Python 2.3.4. After what appeared to be successful installations of Python-2.3.4.exe, I next executed: > pywin32-201.win32-py2.3.exe as downloaded from SourceForge, in the belief that it was the appropriate companion for Python-2.3.4 (perhaps this is my mistake?). In both cases, the installed Pythonwin outputs the...
by: Philip Rittenhouse | last post by:
I was just wondering if there are any plans to support the CreateTypeLib2 API either instead of, or in addition to, the CreateTypeLib API. I am currently using pythoncom to generate type libraries, but I ran into an issue supporting optional parameters. After a lot of digging I discovered that the old CreateTypeLib API doesn't support them. I have currently built a custom version of pywin32 that uses the new CreateTypeLib2 API, and...
by: Aljosa Mohorovic | last post by:
which is last pywin32 that works on win95? i need it to access COM object and it needs to run on win95. version fox this mix would be nice, something like: python 2.3.4 -> which version pywin32 b 202 -> which version wxWindows -> which version pysqlite -> which version which version to use so this will work on windows 95. i know that win95 is no longer supported but there must be previous version
by: Egor Bolonev | last post by:
import os print os.listdir("\\\\delta\\public") outputs and import os print os.listdir("\\\\delta")
by: mg | last post by:
Hi all, I have reinstalled my Win32 computer last week and I did an update of the project PyWin32 to complete my Python installation. (I have to use sources from CVS for my project !) So, when I run 'python setup.py' in my PyWin32 directory, I have two problem : the version indacated in windows.h and some symbols who are not defined. See the trace :
by: Chris Lott | last post by:
Can someone elaborate for me what the pywin32 project is exactly? Is PythonWin a replacement for idle? More to the point, do I need to worry about this as I am learning about Python, since Idle and the Windows Installer seem to work fine on my XP box? c
by: sam | last post by:
Has anyone been able to access the source code for Pywin32 at sourceforge? I have been able to use TortouseCVS to access other CVS projects,but with the Pywin32 cvs site, I can not log in. Sam Schulenburg
by: vml | last post by:
Hello, I am trying to promote python in my job, my collegue only see matlab and microsoft scripting language. I understood that there willl be no backward compatibility between python 2.x and 3.0, does it means that: - my script using pywin32 for the COM layer and scipy for the maths won't work under 3.0
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.