List Info

Thread: Transparent Windows - API failure




Transparent Windows - API failure
user name
2006-07-05 23:32:30

All,
      This is my first attempt with setting transparent backgrounds, so probably simple error.  I've had some success making Notepad transparent, but am getting no results against a Tkinter window.  Also, any workaround to using SetLayeredWindowAttributes on Win2000?  I noticed in the docs it's not in win32gui to prevent issues with NT?

    import win32con
    import win32gui
    import winxpgui

    # Assume you have a tk window open with hWND of 1050292
    # from tkinter import *
    # root = Tk()
    # root['bg'] = "white"

    hWND = 1050292
    win32gui.SetWindowLong (hWND, win32con.GWL_EXSTYLE, win32gui.GetWindowLong (hWND, win32con.GWL_EXSTYLE ) | win32con.WS_EX_LAYERED )

    winxpgui.SetLayeredWindowAttributes(hWND, bgColor, 50, win32con.LWA_COLORKEY|win32con.LWA_ALPHA)

Produces error̷0;

    Traceback (most recent call last):
      File "<pyshell#98&gt;", line 1, in ?
     &nbsp;  winxpgui.SetLayeredWindowAttributes(hWND, win32api.RGB(255, 255, 255), 50, win32con.LWA_COLORKEY|win32con.LWA_ALPHA)

    error: (0, 'SetLayeredWindowAttributes', 'No error message is available')

Thanks,

Bobby

Transparent Windows - API failure
user name
2006-07-06 06:52:32
> Also, any workaround to using
SetLayeredWindowAttributes on Win2000?
> I noticed in the docs it's not in win32gui to prevent
issues with NT?

Well - "prevent issues" actually translates to
"easier"   A better
work-around would be to have the C++ code use LoadLibrary,
and I'd be happy
to accept such patches.

> winxpgui.SetLayeredWindowAttributes(hWND, bgColor, 50,
win32con.LWA_COLORKEY|win32con.LWA_ALPHA) 
> Produces error... 
> Traceback (most recent call last): 
>   File "<pyshell#98>", line 1, in ? 
>     winxpgui.SetLayeredWindowAttributes(hWND,
win32api.RGB(255, 255, 255),
50, win32con.LWA_COLORKEY|win32con.LWA_ALPHA)
> error: (0, 'SetLayeredWindowAttributes', 'No error
message is available') 

I'm afraid all I can tell you is that the BOOL function
SetLayeredWindowAttributes failed, and it didn't call
SetLastError to offer
any clues as to why.  My only advice is to look wider than
the Python
universe to try and determine things that can cause the API
function to
fail, in anyone's language.

Cheers,

Mark.

_______________________________________________
Python-win32 mailing list
Python-win32python.org

http://mail.python.org/mailman/listinfo/python-win32
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )