 |
|
 |
Thx for simple n straight code.
|
|
|
|
 |
|
 |
If the application is windows media player and the player is playing some media files such as .wmv,it can not transparetn.how to resolve it ?
seasoft
|
|
|
|
 |
|
 |
Thanks for sharing your project.
Dr.Luiji
Trust and you'll be trusted.
Cryptography API: The Next Generation (CNG) - How to crypt documents with C++ programming, here.
|
|
|
|
 |
|
 |
Hello everyone,
I found a critical issue while using this technique of layered windows.
When the dialog is being loaded if you lock the computer and then unlock after a second , the complete dialog is blackened. Is there any code fix for this with any one.
appreciate your help
venki
venki
|
|
|
|
 |
|
 |
Can we have 100% opaque window text while 70% transparent window background?
Is that possible ? I don't see an easy solution, it may require a manual implementation.
1. Either the window text color(which is black, usually) goes transparent *together with* the window background color, by using SetLayeredWindowAttributes(hWnd, 0,255 * 0.30, LWA_ALPHA);
The higher the transparency, the more invisible the text becomes...
2. Or the window text color is 100% opaque and the window background color is 100% transparent, by using SetLayeredWindowAttributes(hWnd, rgbTransparentBackcolor,0, LWA_COLORKEY);
-- modified at 5:47 Wednesday 31st May, 2006
|
|
|
|
 |
|
 |
Hi,
I am having problems overlapping Translucent windows over any DirectX window.
It flickers crazily whether I put the timer as suggested in this code or whether I dont put the timer and follow the simple rules of MSDN.
This happened on my both computers at home - ATI Rage Turbo Pro card and also Intel Integrated Gfx.
Any suggestions? This is very urgent please. I have a deliverable by the end of the year
Thank you
|
|
|
|
 |
|
 |
Doesn't DirectX itself provide some sort of translucent objects?
|
|
|
|
 |
|
 |
who can solve this problem...
why SetLayeredWindowAttributes can't used in 8 bits(256) color quality.
please tell me, thanks.
|
|
|
|
 |
|
 |
Hello,
Great article by the way. However I was wondering how can this be translated to VB.NET? I was looking for something like this seems like forever. Everything I tried, basically from changing opacity with timer to Windowtransition() API, never never seems to be working properly. If this can be ported to VB.NET that would be great. Thanks.
|
|
|
|
 |
|
 |
Sorry, no idea. Anyone?
Regards, Kirill
|
|
|
|
 |
|
 |
After a bit of hair-pulling I have finally figured it out myself:
Public Structure RECT
Public left As Integer
Public top As Integer
Public right As Integer
Public bottom As Integer
End Structure
Public Const LWA_ALPHA As Short = 2
Public Const LWA_BOTH As Short = 3
Public Const WS_EX_LAYERED As Integer = &H80000
Public Const GWL_EXSTYLE As Short = -20
Private Const RDW_UPDATENOW As Integer = &H100
Private Const RDW_INVALIDATE As Integer = &H1
Private Const RDW_ALLCHILDREN As Integer = &H80
Private Const RDW_ERASE As Integer = &H4
Public Declare Function Sleep Lib "kernel32" (ByVal dwMilliseconds As Integer) As Integer
Public Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Integer, ByVal color As Integer, ByVal x As Byte, ByVal alpha As Integer) As Boolean
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Integer, ByVal nIndex As Integer, ByVal dwNewLong As Integer) As Integer
Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Integer, ByVal nIndex As Integer) As Integer
Public Declare Function RedrawWindow Lib "user32" Alias "RedrawWindow" (ByVal hwnd As IntPtr, ByRef lprcUpdate As RECT, ByVal hrgnUpdate As IntPtr, ByVal fuRedraw As Integer) As Integer
Public Declare Function GetWindowRect Lib "user32" Alias "GetWindowRect" (ByVal hwnd As IntPtr, ByRef rect As RECT) As Integer
Public Sub SetTranslucent(ByRef ThehWnd As Integer, ByRef nTrans As Short)
'SetWindowLong and SetLayeredWindowAttributes are API functions, see MSDN for details
Dim AlphaAttrib As Integer = GetWindowLong(ThehWnd, GWL_EXSTYLE)
SetWindowLong(ThehWnd, GWL_EXSTYLE, AlphaAttrib Or WS_EX_LAYERED)
SetLayeredWindowAttributes(ThehWnd, RGB(255, 255, 0), nTrans, LWA_ALPHA)
End Sub
Public Function FadeIn(Optional ByVal Min As Integer = 0, Optional ByVal Max As Integer = 255)
Dim tR As New RECT
GetWindowRect(Handle, tR)
tR.right -= tR.left
tR.left = 0
tR.bottom -= tR.top
tR.top = 0
For I As Integer = Min To Max Step 16
RedrawWindow(Me.Handle, tR, IntPtr.Zero, RDW_UPDATENOW)
SetTranslucent(Me.Handle.ToInt32, I)
Sleep(16)
Next
End Function
Public Function FadeOut(Optional ByVal Min As Integer = 0, Optional ByVal Max As Integer = 255)
Dim tR As New RECT
GetWindowRect(Handle, tR)
tR.right -= tR.left
tR.left = 0
tR.bottom -= tR.top
tR.top = 0
For I As Integer = Max To Min Step -16
RedrawWindow(Me.Handle, tR, IntPtr.Zero, RDW_INVALIDATE)
SetTranslucent(Me.Handle.ToInt32, I)
Sleep(16)
Next
End Function
And then you could use the FadeOut() function in the Closing event of some dialog window or form, or use the FadeIn() function to fade in he form. Set the transparency to 0 before the form is shown and then set the form to visible and then use FadeIn() to smoothly fade in the form or some dialog window. Enjoy the code.
|
|
|
|
 |
|
 |
it only can action for a Dialog window, but it can't do anything for a subwindow(control) in a dialog, what i'm doing?
Help me~~~, thanx.
|
|
|
|
 |
|
 |
As of the Platform SDK doc for "Layered Windows",
"... Note that WS_EX_LAYERED cannot be used for child windows."
You might want to look at
http://msdn.microsoft.com/library/en-us/winui/winui/windowsuserinterface/windowing/windows/windowfeatures.asp?frame=true#layered
Maybe there's another approach that does not use layered windows - like the AnimateWindow API?
Kirill
|
|
|
|
 |
|
 |
what does child window mean?
can i use SetLayeredWindowAttributes function in my derived control? sure about this control is to be shown in a parent window. Or do u have any idea about common control's transparency?
|
|
|
|
 |
|
 |
I think, "child window" in this case indeed means any window that has a parent other than NULL. Then, a control that's inside a dialog definitely would be a child window. I've tried it myself - the code does not work with controls.
The documentation for AnimateWindow says something about WM_PRINT and WM_PRINTCLIENT messages that could be used to render a control to a device context. Maybe that helps.
Kirill
Kirill
|
|
|
|
 |
|
 |
This only will compile if the Window version defs are setup correctly Win2000/XP when using a full MFC app generated by AppWizard.
The other way in MFC app is to use the user.dll's SetLayeredWindowAttributes export.
I don't about compiling it for non-MFC apps.
|
|
|
|
 |
|
 |
I wrote:
The other way in MFC app is to use the user.dll's SetLayeredWindowAttributes export.
It should be user32.dll...
|
|
|
|
 |
|
 |
Because you run a very tight scope when you change the window transparency, combined with a "sleep" period, your app will run very slow on old machines and/or big windows. You need very much CPU resources.
So you can't say how long the fading time is. It is very annoying if one window of your app fades very fast (small window) and another window fades in very slow (large window). With "AnimateWindow" the fading time is guaranteed. If the computer isn't fast enough for displaying all the fading steps, he just skips some frames...
What you can do is after fading in with "AnimateWindow" is just sending an "Invalidate()" afterwards... not very nice, but then the controls are displayed correctly. A very bad thing is, as you said, that you can't realize transparency with "AnimateWindow"...
CU
|
|
|
|
 |
|
 |
One fix is to have a worker thread or timer that waits for the InitDialog() or WM_INITDIALOG is finshed adding any items to control that use item i.e. tree, list, and combo. When InitDialog() or WM_INITDIALOG end the dialog show not be shown if WS_VISIBLE is applied then hide the dialog.
AnimateWindow() should be use like Mykel said in the timer or thread for window size consideration.
Mykel wrote:
What you can do is after fading in with "AnimateWindow" is just sending an "Invalidate()" afterwards... not very nice, but then the controls are displayed correctly. A very bad thing is, as you said, that you can't realize transparency with "AnimateWindow"...
After AnimateWindow() is called the window is visible still at 100% faded-in and if you want 90% fade-in you can insert code after AnimateWindow in the timer or thread to fade-out 10% or you have to use use as present in Kirill Müller article.
With this fix the all controls should look the same as they would during AnimateWindow() as they would if you displayed the dialog with any fade-in or the dialog being transparent.
|
|
|
|
 |
|
 |
Well, there is a simple solution for the first problem. You'll need a timer and the ::GetTickCount() API:
- Move the code for fade-in to a TimerProc procedure.
- Remove the ::Sleep and the for loop.
- Calculate the current alpha as a function of the time interval elapsed since the start of the animation, e.g. (TimeElapsed * FinalAlpha) / AnimationTime.
- In the WM_INITDIALOG handler, call ::SetTimer for this timer procedure with a timer interval of 1ms (3rd parameter).
Hope that helps.
Kirill
|
|
|
|
 |
|
 |
Do I need platform SDK to compile this project?
|
|
|
|
 |
|
 |
The code should compile under VC++ 6.0 with SP5 installed. Of course, the simplest solution is to install the newest Platform SDK.
Kirill
|
|
|
|
 |