SetLayeredWindow

Hi all,

I'm trying out the SetLayeredWindowAttributes command to make a test window semi-transparent (before i start doing it in a proper app).

I'm following the MS sample and it work...that is until i move and drop the window then the style is removed. I've tried re-setting the style on LButton up but it doesnt seem to work.

Does anyone have any ideas?

Its a new MFC Dialgo project and OnInitDlg i've got:

// Set WS_EX_LAYERED on this window
::SetWindowLong(this->m_hWnd, GWL_EXSTYLE, GetWindowLong(this->m_hWnd, GWL_EXSTYLE) | WS_EX_LAYERED);

// Make this window 70% alpha
SetLayeredWindowAttributes(this->m_hWnd, 0, (255 * 70) / 100, LWA_ALPHA);

Oh, also I have the relevent #defines to be using SetLayeredWindows.

One last thing does anyone have any examples of how to use UpdateLayeredWindows its mentioned all over the place but i cant find a single example.

thanks all,

Chris.
[1016 byte] By [chris_gay] at [2007-11-18 19:17:06]
# 1 Re: SetLayeredWindow
That should work.

Just to make sure, i've created a little test MFC diag app and pasted your two lines of code and it works perfectly. (Except that SetLayeredWindowAttributes should be ::SetLayeredWindowAttributes).

With "i move and drop the window" you do mean moving the window via the titlebar, do you?
Marc G at 2007-11-11 1:17:58 >
# 2 Re: SetLayeredWindow
Doh! Your reply reached my just 10mins too late, i've went and done it with UpdateLayeredWindows.

I'm going to go back and try it with ::Set... just incase it was that which i guess it could well be.

the other thing i noticed is that it all seemed to work better without the title bar and things, but i can see why.

Oh I did mean moving the window around with the title bar. When i picked the window up using its title bar it kept its transparency but as soon as i released the mouse button it lost it and went back to being a solid dialog.

All very strange, i'm going to experriement some more, but now i've gotta work out how to do nice antialiased edges on shaped windows using this LayeredWindows malarky...

ah the fun :-)

Chris.

p.s. thanks v-much for the speedy post!
chris_gay at 2007-11-11 1:19:01 >